summary refs log tree commit diff
diff options
context:
space:
mode:
authoroga <oga>2008-01-16 11:39:20 +0000
committeroga <oga>2008-01-16 11:39:20 +0000
commit7fb2664f92a087762ab58158ab5c4f7c442bcd1b (patch)
tree3a933e2d545f729de0a4340161f080c762693619
parent1eed217b1c54d32d3c9269be79c3cb298b4b2805 (diff)
downloadcwm-7fb2664f92a087762ab58158ab5c4f7c442bcd1b.tar.gz
cwm-7fb2664f92a087762ab58158ab5c4f7c442bcd1b.tar.xz
cwm-7fb2664f92a087762ab58158ab5c4f7c442bcd1b.zip
huge amount of cleanup and dead code removal.
full description of changes:
-remove fontlist, and all associated structures/calls, it's not needed.
 this also removes any doubt about leftover 9wm code (the list was
 borrowed from it). Since cwm now uses Xft for everything, the legacy
 font handling is just not needed.
-add /* FALLTHROUGH */ comments into grab_{label,menu}. I actually
 didn't intend grab_menu to be a fallthrough, but it actually works quite
 well there, so remove the extra rectangle drawing. I love it when that
 happens.
-remove a couple of unused prototypes that were obviously missed
 before.
-remove a bunch of commented out or if 0ed out code. It doesn't look to
 be coming back anytime soon.
-several functions returned an int, but this was never checked. most of
 them only failed if they failed to grab the pointer (thus the internal
 state didn't change), so just make them void and return early if this is
 the case.
-remove several unused functions and some useless variables.

knocks something like 200bytes off the stripped binary size for me.

ok marc@, tested by several others.
-rw-r--r--calmwm.c45
-rw-r--r--calmwm.h11
-rw-r--r--client.c36
-rw-r--r--conf.c30
-rw-r--r--grab.c18
-rw-r--r--group.c31
-rw-r--r--kbfunc.c1
-rw-r--r--search.c6
-rw-r--r--util.c7
-rw-r--r--xevents.c2
-rw-r--r--xutil.c21
11 files changed, 22 insertions, 186 deletions
diff --git a/calmwm.c b/calmwm.c
index 5c91b2f..49584a1 100644
--- a/calmwm.c
+++ b/calmwm.c
@@ -22,7 +22,6 @@
 #include "calmwm.h"
 
 Display				*X_Dpy;
-XFontStruct			*X_Font;
 
 Cursor				 Cursor_move;
 Cursor				 Cursor_resize;
@@ -47,15 +46,6 @@ char                            *DefaultFontName;
 #define gray_height 2
 static char gray_bits[] = {0x02, 0x01};
 
-/* List borrowed from 9wm/rio */
-char *tryfonts[] = {
-	"9x15bold",
-	"*-lucidatypewriter-bold-*-14-*-75-*",
-	"*-lucidatypewriter-medium-*-12-*-75-*",
-	"fixed",
-	"*",
-	NULL,
-};
 
 static void _sigchld_cb(int);
 
@@ -140,15 +130,6 @@ x_setup(char *display_name)
 
 	Doshape = XShapeQueryExtension(X_Dpy, &Shape_ev, &i);
 
-	i = 0;
-	while ((fontname = tryfonts[i++]) != NULL) {
-		if ((X_Font = XLoadQueryFont(X_Dpy, fontname)) != NULL)
-			break;
-	}
-
-	if (fontname == NULL)
-		errx(1, "Couldn't load any fonts.");
-
 	Nscreens = ScreenCount(X_Dpy);
 	for (i = 0; i < (int)Nscreens; i++) {
 		XMALLOC(sc, struct screen_ctx);
@@ -158,13 +139,12 @@ x_setup(char *display_name)
 
 	Cursor_move = XCreateFontCursor(X_Dpy, XC_fleur);
 	Cursor_resize = XCreateFontCursor(X_Dpy, XC_bottom_right_corner);
-	/* (used to be) XCreateFontCursor(X_Dpy, XC_hand1); */
 	Cursor_select = XCreateFontCursor(X_Dpy, XC_hand1);
 	Cursor_default = XCreateFontCursor(X_Dpy, XC_X_cursor);
 	Cursor_question = XCreateFontCursor(X_Dpy, XC_question_arrow);
 }
 
-int
+void
 x_setupscreen(struct screen_ctx *sc, u_int which)
 {
 	XColor tmp;
@@ -196,10 +176,6 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
 	TAILQ_FOREACH(kb, &Conf.keybindingq, entry)
 		xu_key_grab(sc->rootwin, kb->modmask, kb->keysym);
 
-	/* Special -- for alt state. */
-/* 	xu_key_grab(sc->rootwin, 0, XK_Alt_L); */
-/* 	xu_key_grab(sc->rootwin, 0, XK_Alt_R); */
-
 	sc->blackpixl = BlackPixel(X_Dpy, sc->which);
 	sc->whitepixl = WhitePixel(X_Dpy, sc->which);
 	sc->bluepixl = sc->fccolor.pixel;
@@ -223,32 +199,21 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
 	gv.function = GXxor;
 	gv.line_width = 1;
 	gv.subwindow_mode = IncludeInferiors;
-	gv.font = X_Font->fid;
 
 	sc->gc = XCreateGC(X_Dpy, sc->rootwin,
 	    GCForeground|GCBackground|GCFunction|
-	    GCLineWidth|GCSubwindowMode|GCFont, &gv);
-
-#ifdef notyet
-	gv2.foreground = sc->blackpixl^sc->cyanpixl;
-	gv2.background = sc->cyanpixl;
-	gv2.function = GXxor;
-	gv2.line_width = 1;
-	gv2.subwindow_mode = IncludeInferiors;
-	gv2.font = X_Font->fid;
-#endif
+	    GCLineWidth|GCSubwindowMode, &gv);
 
 	sc->hlgc = XCreateGC(X_Dpy, sc->rootwin,
 	    GCForeground|GCBackground|GCFunction|
-	    GCLineWidth|GCSubwindowMode|GCFont, &gv);
+	    GCLineWidth|GCSubwindowMode, &gv);
 
 	gv1.function = GXinvert;
 	gv1.subwindow_mode = IncludeInferiors;
 	gv1.line_width = 1;
-	gv1.font = X_Font->fid;
 
 	sc->invgc = XCreateGC(X_Dpy, sc->rootwin,
-	    GCFunction|GCSubwindowMode|GCLineWidth|GCFont, &gv1);
+	    GCFunction|GCSubwindowMode|GCLineWidth, &gv1);
 
 	font_init(sc);
 	DefaultFont = font_getx(sc, DefaultFontName);
@@ -290,7 +255,7 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
 
 	XSync(X_Dpy, False);
 
-	return (0);
+	return;
 }
 
 char *
diff --git a/calmwm.h b/calmwm.h
index dd9371c..e4f463d 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -311,8 +311,7 @@ int input_keycodetrans(KeyCode, u_int, enum ctltype *, char *, int);
 int   x_errorhandler(Display *, XErrorEvent *);
 void  x_setup(char *display_name);
 char *x_screenname(int);
-void  x_loop(void);
-int   x_setupscreen(struct screen_ctx *, u_int);
+void  x_setupscreen(struct screen_ctx *, u_int);
 
 struct client_ctx *client_find(Window);
 void               client_setup(void);
@@ -397,8 +396,8 @@ int dirent_isdir(char *);
 int dirent_islink(char *);
 int u_spawn(char *);
 
-int   grab_sweep(struct client_ctx *);
-int   grab_drag(struct client_ctx *);
+void  grab_sweep(struct client_ctx *);
+void  grab_drag(struct client_ctx *);
 void  grab_menuinit(struct screen_ctx *);
 void *grab_menu(XButtonEvent *, struct menu_q *);
 void  grab_label(struct client_ctx *);
@@ -472,8 +471,7 @@ void  search_match_exec(struct menu_q *, struct menu_q *, char *);
 void  search_rank_text(struct menu_q *, char *);
 
 void group_init(void);
-int  group_new(void);
-int  group_select(int);
+void group_select(int);
 void group_enter(void);
 void group_exit(int);
 void group_click(struct client_ctx *);
@@ -509,7 +507,6 @@ struct fontdesc *font_getx(struct screen_ctx *sc, const char *name);
 /* Externs */
 
 extern Display				*X_Dpy;
-extern XFontStruct			*X_Font;
 
 extern Cursor				 Cursor_move;
 extern Cursor				 Cursor_resize;
diff --git a/client.c b/client.c
index 3dab02f..c40899a 100644
--- a/client.c
+++ b/client.c
@@ -267,15 +267,6 @@ client_leave(struct client_ctx *cc)
 }
 
 void
-client_nocurrent(void)
-{
-	if (_curcc != NULL)
-		client_setactive(_curcc, 0);
-
-	_curcc = NULL;
-}
-
-void
 client_setactive(struct client_ctx *cc, int fg)
 {
 	struct screen_ctx* sc;
@@ -362,19 +353,6 @@ client_maximize(struct client_ctx *cc)
 }
 
 void
-client_push_geometry(struct client_ctx *cc)
-{
-       cc->savegeom = cc->geom;
-}
-
-void
-client_restore_geometry(struct client_ctx *cc)
-{
-       cc->geom = cc->savegeom;
-       client_resize(cc);
-}
-
-void
 client_resize(struct client_ctx *cc)
 {
 	XMoveResizeWindow(X_Dpy, cc->pwin, cc->geom.x - cc->bwidth,
@@ -408,13 +386,6 @@ client_raise(struct client_ctx *cc)
 }
 
 void
-client_warp(struct client_ctx *cc)
-{
-	client_raise(cc);
-	xu_ptr_setpos(cc->pwin, 0, 0);
-}
-
-void
 client_ptrwarp(struct client_ctx *cc)
 {
 	int x = cc->ptr.x, y = cc->ptr.y;
@@ -880,13 +851,6 @@ client_vertmaximize(struct client_ctx *cc)
 }
 
 void
-client_map(struct client_ctx *cc)
-{
-	/* mtf? */
-	client_ptrwarp(cc);
-}
-
-void
 client_mtf(struct client_ctx *cc)
 {
 	struct screen_ctx *sc;
diff --git a/conf.c b/conf.c
index d2a286c..bc0e0e8 100644
--- a/conf.c
+++ b/conf.c
@@ -327,19 +327,6 @@ conf_get_int(struct client_ctx *cc, enum conftype ctype)
 	return (val);
 }
 
-char *
-conf_get_str(struct client_ctx *cc, enum conftype ctype)
-{
-	switch (ctype) {
-	case CONF_NOTIFIER:
-		return xstrdup("./notifier.py"); /* XXX */
-		break;
-	default:
-		break;
-	}
-    return NULL;
-}
-
 void
 conf_client(struct client_ctx *cc)
 {
@@ -410,23 +397,6 @@ struct {
 };
 
 void
-conf_bindkey(struct conf *c, void (*arg_callback)(struct client_ctx *, void *),
-    int arg_keysym, int arg_modmask, int arg_flags, void * arg_arg)
-{
-	struct keybinding *kb;
-
-	XMALLOC(kb, struct keybinding);
-
-	kb->modmask = arg_modmask;
-	kb->keysym = arg_keysym;
-	kb->keycode = 0;
-	kb->flags = arg_flags;
-	kb->callback = arg_callback;
-	kb->argument = arg_arg;
-	TAILQ_INSERT_TAIL(&c->keybindingq, kb, entry);
-}
-
-void
 conf_parsekeys(struct conf *c, char *filename)
 {
 	DIR *dir;
diff --git a/grab.c b/grab.c
index f55459a..63be295 100644
--- a/grab.c
+++ b/grab.c
@@ -53,7 +53,7 @@ grab_sweep_draw(struct client_ctx *cc, int dx, int dy)
 	    wide/2 - wide_size/2, height + font_ascent(font) + 1);
 }
 
-int
+void
 grab_sweep(struct client_ctx *cc)
 {
 	XEvent ev;
@@ -68,7 +68,7 @@ grab_sweep(struct client_ctx *cc)
 	client_ptrsave(cc);
 
 	if (xu_ptr_grab(sc->rootwin, MouseMask, Cursor_resize) < 0)
-		return (-1);
+		return;
 
 	xu_ptr_setpos(cc->win, cc->geom.width, cc->geom.height);
 	grab_sweep_draw(cc, dx, dy);
@@ -101,13 +101,13 @@ grab_sweep(struct client_ctx *cc)
 			XReparentWindow(X_Dpy, sc->menuwin, sc->rootwin, 0, 0);
 			xu_ptr_ungrab();
 			client_ptrwarp(cc);
-			return (0);
+			return;
 		}
 	}
 	/* NOTREACHED */
 }
 
-int
+void
 grab_drag(struct client_ctx *cc)
 {
 	int x0 = cc->geom.x, y0 = cc->geom.y, xm, ym;
@@ -117,7 +117,7 @@ grab_drag(struct client_ctx *cc)
 	client_raise(cc);
 
 	if (xu_ptr_grab(sc->rootwin, MouseMask, Cursor_move) < 0)
-		return (-1);
+		return;
 
 	xu_ptr_getpos(sc->rootwin, &xm, &ym);
 
@@ -138,7 +138,7 @@ grab_drag(struct client_ctx *cc)
 			break;
 		case ButtonRelease:
 			xu_ptr_ungrab();
-			return (0);
+			return;
 		}
 	}
 	/* NOTREACHED */
@@ -219,9 +219,7 @@ grab_menu(XButtonEvent *e, struct menu_q *menuq)
 				    sc->menuwin, fx, fy);
 				i++;
 			}
-			if (entry != -1)
-				XFillRectangle(X_Dpy, sc->menuwin, sc->hlgc,
-				    0, entry*height, width, height);
+			/* FALLTHROUGH */
 		case MotionNotify:
 			prev = entry;
 			entry = menu_calc_entry(event.xbutton.x,
@@ -320,7 +318,7 @@ grab_label(struct client_ctx *cc)
 					xfree(cc->label);
 
 				cc->label = xstrdup(labelstr);
-
+				/* FALLTHROUGH */
 			case CTL_ABORT:
 				goto out;
 			default:
diff --git a/group.c b/group.c
index c9cccef..77a3bf2 100644
--- a/group.c
+++ b/group.c
@@ -197,36 +197,15 @@ group_init(void)
  * manipulate the 'current group'
  */
 
-#if 0
-/* set current group to the first empty group
- * returns 0 on success, -1 if there are no empty groups
- */
-int
-group_new(void)
-{
-  	int i;
-
-	for (i=0; i < CALMWM_NGROUPS; i++) {
-		if (TAILQ_EMPTY(&Groups[i].clients)) {
-			Group_current = &Groups[i];			
-
-			return (0);
-		}
-	}
-
-	return (-1);
-}
-#endif
-
 /* change the current group */
-int
+void
 group_select(int idx)
 {
 	struct group_ctx *gc = Group_current;
 	struct client_ctx *cc;
 
 	if (idx < 0 || idx >= CALMWM_NGROUPS)
-		return (-1);
+		return;
 
 	TAILQ_FOREACH(cc, &gc->clients, group_entry) {
 		cc->highlight = 0;
@@ -237,7 +216,7 @@ group_select(int idx)
 	Group_current = &Groups[idx];
 
 	group_display_draw(screen_current());
-	return (0);
+	return;
 }
 
 /* enter group mode */
@@ -353,7 +332,7 @@ void
 group_display_draw(struct screen_ctx *sc)
 {
 	struct group_ctx *gc = Group_current;
-	int x, y, dx, dy, fontheight, titlelen;
+	int x, y, dx, dy, fontheight;
 	struct client_ctx *cc;
 	char titlebuf[1024];
 	struct fontdesc *font = DefaultFont;
@@ -363,7 +342,7 @@ group_display_draw(struct screen_ctx *sc)
 	x = y = 0;
 
 	fontheight = font_ascent(font) + font_descent(font) + 1;
-	dx = titlelen = font_width(font, titlebuf, strlen(titlebuf));
+	dx = font_width(font, titlebuf, strlen(titlebuf));
 	dy = fontheight;
 
 	TAILQ_FOREACH(cc, &gc->clients, group_entry) {
diff --git a/kbfunc.c b/kbfunc.c
index 9f59b2b..585107b 100644
--- a/kbfunc.c
+++ b/kbfunc.c
@@ -171,7 +171,6 @@ kbfunc_client_search(struct client_ctx *scratch, void *arg)
 	TAILQ_INIT(&menuq);
 	
 	TAILQ_FOREACH(cc, &Clientq, entry) {
-		struct menu *mi;
 		XCALLOC(mi, struct menu);
 		strlcpy(mi->text, cc->name, sizeof(mi->text));
 		mi->ctx = cc;
diff --git a/search.c b/search.c
index a130743..3645445 100644
--- a/search.c
+++ b/search.c
@@ -457,12 +457,6 @@ search_match_exec(struct menu_q *menuq, struct menu_q *resultq, char *search)
 			TAILQ_INSERT_TAIL(resultq, mi, resultentry);
 }
 
-void
-search_rank_text(struct menu_q *resultq, char *search)
-{
-	return;
-}
-
 static int
 _strsubmatch(char *sub, char *str, int zeroidx)
 {
diff --git a/util.c b/util.c
index 20e4d91..c7f5ea8 100644
--- a/util.c
+++ b/util.c
@@ -65,13 +65,6 @@ exec_wm(char *argstr)
 	err(1, args[0]);
 }
 
-
-int dirent_exists(char *filename) {
-       struct stat buffer;
-
-       return stat(filename, &buffer);
-}
-
 int dirent_isdir(char *filename) {
        struct stat buffer;
        int return_value;
diff --git a/xevents.c b/xevents.c
index ae73090..913db2e 100644
--- a/xevents.c
+++ b/xevents.c
@@ -27,8 +27,6 @@
 #include "headers.h"
 #include "calmwm.h"
 
-void _sendxmsg(Window, Atom, long);
-
 /*
  * NOTE: in reality, many of these should move to client.c now that
  * we've got this nice event layer.
diff --git a/xutil.c b/xutil.c
index b92aaba..040d5b5 100644
--- a/xutil.c
+++ b/xutil.c
@@ -84,16 +84,6 @@ xu_key_grab(Window win, int mask, int keysym)
 
         XGrabKey(X_Dpy, XKeysymToKeycode(X_Dpy, keysym), mask, win, True,
 	    GrabModeAsync, GrabModeAsync);
-#if 0
-        XGrabKey(X_Dpy, XKeysymToKeycode(X_Dpy, keysym), LockMask|mask,
-	    win, True, GrabModeAsync, GrabModeAsync);
-#endif
-}
-
-void
-xu_key_grab_keycode(Window win, int mask, int keycode)
-{
-        XGrabKey(X_Dpy, keycode, mask, win, True, GrabModeAsync, GrabModeAsync);
 }
 
 void
@@ -144,17 +134,6 @@ xu_getstate(struct client_ctx *cc, int *state)
 	return (0);
 }
 
-char *
-xu_getstrprop(struct client_ctx *cc, Atom atm)
-{
-	u_char *cp;
-
-	if (xu_getprop(cc, atm, XA_STRING, 100L, &cp) <= 0)
-		return (NULL);
-
-	return ((char *)cp);
-}
-
 void
 xu_setstate(struct client_ctx *cc, int state)
 {