summary refs log tree commit diff
path: root/conf.c
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2016-12-16 13:42:52 +0100
committerChristian Neukirchen <chneukirchen@gmail.com>2016-12-16 13:48:38 +0100
commit775ba78311768b7a944db95273822c0a567dc171 (patch)
tree13ea9cb9db8e9121cc80e9cce4186a925fb889e2 /conf.c
parentdcb741d2b1378432e226bbeea274c2e5e2508c2d (diff)
parent8b4666cb926121481905b68bf93d6e81c307e9e3 (diff)
downloadcwm-775ba78311768b7a944db95273822c0a567dc171.tar.gz
cwm-775ba78311768b7a944db95273822c0a567dc171.tar.xz
cwm-775ba78311768b7a944db95273822c0a567dc171.zip
cvsimport
* refs/heads/master:
  stray newlines
  Add search_print_text(), a default callback for mi->print in menu_filter(). While here, normalize the remaining search_print_* argument paramters.
  Consistent use of menuq_add for ssh menu.
  Now that dim.{x,y} are available early, use them before requiring a MotionNotify event.
  Set dim.{x,y} during client_init and update on resize, instead of (re)calculating only when applying hints.
  'window-search' is spelled 'menu-window'; the former snuck in during the conversion('menu-window' already existed and was properlly documented); found the hard way by sthen@ while trying to convert.
  Fold unbinding functions into one for each, key and mouse; plugs a leak when unbinding a mouse button bound to a command.
  use the correct type
  Tame the number of 'exec' and 'path' search_match wrappers. No functional change now, though more can likely go later, losing the (paritally complete or incomplete/broken) argument completion bits.
  Switch ssh menu to search_match_text; like group/window/cmd menus, use only a substring match. The previous matching is only intended for the exec menus.
  Change 'menu-window' to display all windows; then add 'menu-window-hidden' for the previous behaviour of 'menu-window'.  'menu-window' becomes the default binding; use 'bind-mouse "1" menu-window-hidden' to restore old behaviour for those who prefer.
  Normalize bind function names, based on a few categories: window, group, menu and pointer.
  Use an additional check with lstat(2) when d_type is unknown.
  revert previous; upcoming changes will hopefully deal with these more naturally.
  Add a wrapper based upon xevent handlers around client move/resize for key and mouse bindings.
  Define callbacks, then default bindings.
  Reorganize for upcoming changes.
  Remove the (8) default bindings for pointer move since they conflict with default bindings for emacs, which wins; the feature remains and can be bound to whatever users wish with cwmrc(5).
Diffstat (limited to 'conf.c')
-rw-r--r--conf.c786
1 files changed, 382 insertions, 404 deletions
diff --git a/conf.c b/conf.c
index cebfc07..15d3217 100644
--- a/conf.c
+++ b/conf.c
@@ -34,27 +34,330 @@
 
 static const char	*conf_bind_getmask(const char *, unsigned int *);
 static void		 conf_cmd_remove(struct conf *, const char *);
-static void		 conf_unbind_kbd(struct conf *, struct bind_ctx *);
+static void		 conf_unbind_key(struct conf *, struct bind_ctx *);
 static void		 conf_unbind_mouse(struct conf *, struct bind_ctx *);
 
+static int cursor_binds[] = {
+	XC_left_ptr,		/* CF_NORMAL */
+	XC_fleur,		/* CF_MOVE */
+	XC_bottom_right_corner,	/* CF_RESIZE */
+	XC_question_arrow,	/* CF_QUESTION */
+};
+static const char *color_binds[] = {
+	"#CCCCCC",		/* CWM_COLOR_BORDER_ACTIVE */
+	"#666666",		/* CWM_COLOR_BORDER_INACTIVE */
+	"#FC8814",		/* CWM_COLOR_BORDER_URGENCY */
+	"blue",			/* CWM_COLOR_BORDER_GROUP */
+	"red",			/* CWM_COLOR_BORDER_UNGROUP */
+	"black",		/* CWM_COLOR_MENU_FG */
+	"white",		/* CWM_COLOR_MENU_BG */
+	"black",		/* CWM_COLOR_MENU_FONT */
+	"",			/* CWM_COLOR_MENU_FONT_SEL */
+};
+static const struct {
+	const char	*tag;
+	void		 (*handler)(void *, union arg *, enum xev);
+	enum context	 context;
+	union arg	 argument;
+} name_to_func[] = {
+	{ "window-menu-label", kbfunc_menu_client_label, CWM_CONTEXT_CC, {0} },
+	{ "window-lower", kbfunc_client_lower, CWM_CONTEXT_CC, {0} },
+	{ "window-raise", kbfunc_client_raise, CWM_CONTEXT_CC, {0} },
+	{ "window-hide", kbfunc_client_hide, CWM_CONTEXT_CC, {0} },
+	{ "window-delete", kbfunc_client_delete, CWM_CONTEXT_CC, {0} },
+	{ "window-htile", kbfunc_client_htile, CWM_CONTEXT_CC, {0} },
+	{ "window-vtile", kbfunc_client_vtile, CWM_CONTEXT_CC, {0} },
+	{ "window-stick", kbfunc_client_toggle_sticky, CWM_CONTEXT_CC, {0} },
+	{ "window-fullscreen", kbfunc_client_toggle_fullscreen, CWM_CONTEXT_CC, {0} },
+	{ "window-maximize", kbfunc_client_toggle_maximize, CWM_CONTEXT_CC, {0} },
+	{ "window-vmaximize", kbfunc_client_toggle_vmaximize, CWM_CONTEXT_CC, {0} },
+	{ "window-hmaximize", kbfunc_client_toggle_hmaximize, CWM_CONTEXT_CC, {0} },
+	{ "window-freeze", kbfunc_client_toggle_freeze, CWM_CONTEXT_CC, {0} },
+	{ "window-cycle", kbfunc_client_cycle, CWM_CONTEXT_SC,
+	    {.i = (CWM_CYCLE_FORWARD)} },
+	{ "window-rcycle", kbfunc_client_cycle, CWM_CONTEXT_SC,
+	    {.i = (CWM_CYCLE_REVERSE)} },
+	{ "window-cycle-ingroup", kbfunc_client_cycle, CWM_CONTEXT_SC,
+	    {.i = (CWM_CYCLE_FORWARD | CWM_CYCLE_INGROUP)} },
+	{ "window-rcycle-ingroup", kbfunc_client_cycle, CWM_CONTEXT_SC,
+	    {.i = (CWM_CYCLE_REVERSE | CWM_CYCLE_INGROUP)} },
+	{ "window-group", kbfunc_client_toggle_group, CWM_CONTEXT_CC, {0} },
+	{ "window-movetogroup-1", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 1} },
+	{ "window-movetogroup-2", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 2} },
+	{ "window-movetogroup-3", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 3} },
+	{ "window-movetogroup-4", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 4} },
+	{ "window-movetogroup-5", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 5} },
+	{ "window-movetogroup-6", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 6} },
+	{ "window-movetogroup-7", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 7} },
+	{ "window-movetogroup-8", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 8} },
+	{ "window-movetogroup-9", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 9} },
+
+	{ "window-move", mousefunc_client_move, CWM_CONTEXT_CC, {0} },
+	{ "window-move-up", kbfunc_client_move, CWM_CONTEXT_CC,
+	    {.i = (CWM_UP)} },
+	{ "window-move-down", kbfunc_client_move, CWM_CONTEXT_CC,
+	    {.i = (CWM_DOWN)} },
+	{ "window-move-right", kbfunc_client_move, CWM_CONTEXT_CC,
+	    {.i = (CWM_RIGHT)} },
+	{ "window-move-left", kbfunc_client_move, CWM_CONTEXT_CC,
+	    {.i = (CWM_LEFT)} },
+	{ "window-move-up-big", kbfunc_client_move, CWM_CONTEXT_CC,
+	    {.i = (CWM_UP | CWM_BIGAMOUNT)} },
+	{ "window-move-down-big", kbfunc_client_move, CWM_CONTEXT_CC,
+	    {.i = (CWM_DOWN | CWM_BIGAMOUNT)} },
+	{ "window-move-right-big", kbfunc_client_move, CWM_CONTEXT_CC,
+	    {.i = (CWM_RIGHT | CWM_BIGAMOUNT)} },
+	{ "window-move-left-big", kbfunc_client_move, CWM_CONTEXT_CC,
+	    {.i = (CWM_LEFT | CWM_BIGAMOUNT)} },
+	{ "window-resize", mousefunc_client_resize, CWM_CONTEXT_CC, {0} },
+	{ "window-resize-up", kbfunc_client_resize, CWM_CONTEXT_CC,
+	    {.i = (CWM_UP)} },
+	{ "window-resize-down", kbfunc_client_resize, CWM_CONTEXT_CC,
+	    {.i = (CWM_DOWN)} },
+	{ "window-resize-right", kbfunc_client_resize, CWM_CONTEXT_CC,
+	    {.i = (CWM_RIGHT)} },
+	{ "window-resize-left", kbfunc_client_resize, CWM_CONTEXT_CC,
+	    {.i = (CWM_LEFT)} },
+	{ "window-resize-up-big", kbfunc_client_resize, CWM_CONTEXT_CC,
+	    {.i = (CWM_UP | CWM_BIGAMOUNT)} },
+	{ "window-resize-down-big", kbfunc_client_resize, CWM_CONTEXT_CC,
+	    {.i = (CWM_DOWN | CWM_BIGAMOUNT)} },
+	{ "window-resize-right-big", kbfunc_client_resize, CWM_CONTEXT_CC,
+	    {.i = (CWM_RIGHT | CWM_BIGAMOUNT)} },
+	{ "window-resize-left-big", kbfunc_client_resize, CWM_CONTEXT_CC,
+	    {.i = (CWM_LEFT | CWM_BIGAMOUNT)} },
+
+	{ "group-cycle", kbfunc_group_cycle, CWM_CONTEXT_SC,
+	    {.i = (CWM_CYCLE_FORWARD)} },
+	{ "group-rcycle", kbfunc_group_cycle, CWM_CONTEXT_SC,
+	    {.i = (CWM_CYCLE_REVERSE)} },
+	{ "group-toggle-all", kbfunc_group_alltoggle, CWM_CONTEXT_SC, {0} },
+	{ "group-toggle-1", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 1} },
+	{ "group-toggle-2", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 2} },
+	{ "group-toggle-3", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 3} },
+	{ "group-toggle-4", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 4} },
+	{ "group-toggle-5", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 5} },
+	{ "group-toggle-6", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 6} },
+	{ "group-toggle-7", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 7} },
+	{ "group-toggle-8", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 8} },
+	{ "group-toggle-9", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 9} },
+	{ "group-only-1", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 1} },
+	{ "group-only-2", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 2} },
+	{ "group-only-3", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 3} },
+	{ "group-only-4", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 4} },
+	{ "group-only-5", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 5} },
+	{ "group-only-6", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 6} },
+	{ "group-only-7", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 7} },
+	{ "group-only-8", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 8} },
+	{ "group-only-9", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 9} },
+
+	{ "pointer-move-up", kbfunc_ptrmove, CWM_CONTEXT_SC,
+	    {.i = (CWM_UP)} },
+	{ "pointer-move-down", kbfunc_ptrmove, CWM_CONTEXT_SC,
+	    {.i = (CWM_DOWN)} },
+	{ "pointer-move-left", kbfunc_ptrmove, CWM_CONTEXT_SC,
+	    {.i = (CWM_LEFT)} },
+	{ "pointer-move-right", kbfunc_ptrmove, CWM_CONTEXT_SC,
+	    {.i = (CWM_RIGHT)} },
+	{ "pointer-move-up-big", kbfunc_ptrmove, CWM_CONTEXT_SC,
+	    {.i = (CWM_UP | CWM_BIGAMOUNT)} },
+	{ "pointer-move-down-big", kbfunc_ptrmove, CWM_CONTEXT_SC,
+	    {.i = (CWM_DOWN | CWM_BIGAMOUNT)} },
+	{ "pointer-move-left-big", kbfunc_ptrmove, CWM_CONTEXT_SC,
+	    {.i = (CWM_LEFT | CWM_BIGAMOUNT)} },
+	{ "pointer-move-right-big", kbfunc_ptrmove, CWM_CONTEXT_SC,
+	    {.i = (CWM_RIGHT | CWM_BIGAMOUNT)} },
+
+	{ "menu-cmd", kbfunc_menu_cmd, CWM_CONTEXT_SC, {0} },
+	{ "menu-group", kbfunc_menu_group, CWM_CONTEXT_SC, {0} },
+	{ "menu-ssh", kbfunc_menu_ssh, CWM_CONTEXT_SC, {0} },
+	{ "menu-window", kbfunc_menu_client, CWM_CONTEXT_SC,
+	    {.i = CWM_MENU_WINDOW_ALL} },
+	{ "menu-window-hidden", kbfunc_menu_client, CWM_CONTEXT_SC,
+	    {.i = CWM_MENU_WINDOW_HIDDEN} },
+	{ "menu-exec", kbfunc_menu_exec, CWM_CONTEXT_SC,
+	    {.i = CWM_MENU_EXEC_EXEC} },
+	{ "menu-exec-wm", kbfunc_menu_exec, CWM_CONTEXT_SC,
+	    {.i = CWM_MENU_EXEC_WM} },
+
+	{ "terminal", kbfunc_exec_term, CWM_CONTEXT_SC, {0} },
+	{ "lock", kbfunc_exec_lock, CWM_CONTEXT_SC, {0} },
+	{ "restart", kbfunc_cwm_status, CWM_CONTEXT_SC, {.i = CWM_EXEC_WM} },
+	{ "quit", kbfunc_cwm_status, CWM_CONTEXT_SC, {.i = CWM_QUIT} },
+
+};
+static unsigned int ignore_mods[] = {
+	0, LockMask, Mod2Mask, Mod2Mask | LockMask
+};
+static const struct {
+	const char	ch;
+	int		mask;
+} bind_mods[] = {
+	{ 'C',	ControlMask },
+	{ 'M',	Mod1Mask },
+	{ '4',	Mod4Mask },
+	{ 'S',	ShiftMask },
+};
+static const struct {
+	const char	*key;
+	const char	*func;
+} key_binds[] = {
+	{ "CM-Return",	"terminal" },
+	{ "CM-Delete",	"lock" },
+	{ "M-question",	"menu-exec" },
+	{ "CM-w",	"menu-exec-wm" },
+	{ "M-period",	"menu-ssh" },
+	{ "M-Return",	"window-hide" },
+	{ "M-Down",	"window-lower" },
+	{ "M-Up",	"window-raise" },
+	{ "M-slash",	"menu-window" },
+	{ "C-slash",	"menu-cmd" },
+	{ "M-Tab",	"window-cycle" },
+	{ "MS-Tab",	"window-rcycle" },
+	{ "CM-n",	"window-menu-label" },
+	{ "CM-x",	"window-delete" },
+	{ "CM-a",	"group-toggle-all" },
+	{ "CM-0",	"group-toggle-all" },
+	{ "CM-1",	"group-toggle-1" },
+	{ "CM-2",	"group-toggle-2" },
+	{ "CM-3",	"group-toggle-3" },
+	{ "CM-4",	"group-toggle-4" },
+	{ "CM-5",	"group-toggle-5" },
+	{ "CM-6",	"group-toggle-6" },
+	{ "CM-7",	"group-toggle-7" },
+	{ "CM-8",	"group-toggle-8" },
+	{ "CM-9",	"group-toggle-9" },
+	{ "M-Right",	"group-cycle" },
+	{ "M-Left",	"group-rcycle" },
+	{ "CM-g",	"window-group" },
+	{ "CM-f",	"window-fullscreen" },
+	{ "CM-m",	"window-maximize" },
+	{ "CM-s",	"window-stick" },
+	{ "CM-equal",	"window-vmaximize" },
+	{ "CMS-equal",	"window-hmaximize" },
+	{ "CMS-f",	"window-freeze" },
+	{ "CMS-r",	"restart" },
+	{ "CMS-q",	"quit" },
+	{ "M-h",	"window-move-left" },
+	{ "M-j",	"window-move-down" },
+	{ "M-k",	"window-move-up" },
+	{ "M-l",	"window-move-right" },
+	{ "MS-h",	"window-move-left-big" },
+	{ "MS-j",	"window-move-down-big" },
+	{ "MS-k",	"window-move-up-big" },
+	{ "MS-l",	"window-move-right-big" },
+	{ "CM-h",	"window-resize-left" },
+	{ "CM-j",	"window-resize-down" },
+	{ "CM-k",	"window-resize-up" },
+	{ "CM-l",	"window-resize-right" },
+	{ "CMS-h",	"window-resize-left-big" },
+	{ "CMS-j",	"window-resize-down-big" },
+	{ "CMS-k",	"window-resize-up-big" },
+	{ "CMS-l",	"window-resize-right-big" },
+},
+mouse_binds[] = {
+	{ "1",		"menu-window" },
+	{ "2",		"menu-group" },
+	{ "3",		"menu-cmd" },
+	{ "M-1",	"window-move" },
+	{ "CM-1",	"window-group" },
+	{ "M-2",	"window-resize" },
+	{ "M-3",	"window-lower" },
+	{ "CMS-3",	"window-hide" },
+};
+
+void
+conf_init(struct conf *c)
+{
+	unsigned int	i;
+
+	c->stickygroups = 0;
+	c->bwidth = 1;
+	c->mamount = 1;
+	c->snapdist = 0;
+	c->ngroups = 10;
+	c->nameqlen = 5;
+
+	TAILQ_INIT(&c->ignoreq);
+	TAILQ_INIT(&c->cmdq);
+	TAILQ_INIT(&c->keybindq);
+	TAILQ_INIT(&c->autogroupq);
+	TAILQ_INIT(&c->mousebindq);
+
+	for (i = 0; i < nitems(key_binds); i++)
+		conf_bind_key(c, key_binds[i].key, key_binds[i].func);
+
+	for (i = 0; i < nitems(mouse_binds); i++)
+		conf_bind_mouse(c, mouse_binds[i].key, mouse_binds[i].func);
+
+	for (i = 0; i < nitems(color_binds); i++)
+		c->color[i] = xstrdup(color_binds[i]);
+
+	conf_cmd_add(c, "lock", "xlock");
+	conf_cmd_add(c, "term", "xterm");
+
+	(void)snprintf(c->known_hosts, sizeof(c->known_hosts), "%s/%s",
+	    homedir, ".ssh/known_hosts");
+
+	c->font = xstrdup("sans-serif:pixelsize=14:bold");
+	c->wmname = xstrdup("CWM");
+}
+
+void
+conf_clear(struct conf *c)
+{
+	struct autogroup	*ag;
+	struct bind_ctx		*kb, *mb;
+	struct winname		*wn;
+	struct cmd_ctx		*cmd;
+	int			 i;
+
+	while ((cmd = TAILQ_FIRST(&c->cmdq)) != NULL) {
+		TAILQ_REMOVE(&c->cmdq, cmd, entry);
+		free(cmd->name);
+		free(cmd);
+	}
+	while ((kb = TAILQ_FIRST(&c->keybindq)) != NULL) {
+		TAILQ_REMOVE(&c->keybindq, kb, entry);
+		free(kb);
+	}
+	while ((ag = TAILQ_FIRST(&c->autogroupq)) != NULL) {
+		TAILQ_REMOVE(&c->autogroupq, ag, entry);
+		free(ag->class);
+		free(ag->name);
+		free(ag);
+	}
+	while ((wn = TAILQ_FIRST(&c->ignoreq)) != NULL) {
+		TAILQ_REMOVE(&c->ignoreq, wn, entry);
+		free(wn->name);
+		free(wn);
+	}
+	while ((mb = TAILQ_FIRST(&c->mousebindq)) != NULL) {
+		TAILQ_REMOVE(&c->mousebindq, mb, entry);
+		free(mb);
+	}
+	for (i = 0; i < CWM_COLOR_NITEMS; i++)
+		free(c->color[i]);
+
+	free(c->font);
+	free(c->wmname);
+}
+
 int
 conf_cmd_add(struct conf *c, const char *name, const char *path)
 {
 	struct cmd_ctx	*cmd;
 
 	cmd = xmalloc(sizeof(*cmd));
-
 	cmd->name = xstrdup(name);
 	if (strlcpy(cmd->path, path, sizeof(cmd->path)) >= sizeof(cmd->path)) {
 		free(cmd->name);
 		free(cmd);
 		return(0);
 	}
-
 	conf_cmd_remove(c, name);
 
 	TAILQ_INSERT_TAIL(&c->cmdq, cmd, entry);
-
 	return(1);
 }
 
@@ -71,6 +374,7 @@ conf_cmd_remove(struct conf *c, const char *name)
 		}
 	}
 }
+
 void
 conf_autogroup(struct conf *c, int num, const char *name, const char *class)
 {
@@ -78,7 +382,6 @@ conf_autogroup(struct conf *c, int num, const char *name, const char *class)
 	char			*p;
 
 	ag = xmalloc(sizeof(*ag));
-
 	if ((p = strchr(class, ',')) == NULL) {
 		if (name == NULL)
 			ag->name = NULL;
@@ -88,7 +391,6 @@ conf_autogroup(struct conf *c, int num, const char *name, const char *class)
 		ag->class = xstrdup(class);
 	} else {
 		*(p++) = '\0';
-
 		if (name == NULL)
 			ag->name = xstrdup(class);
 		else
@@ -97,7 +399,6 @@ conf_autogroup(struct conf *c, int num, const char *name, const char *class)
 		ag->class = xstrdup(p);
 	}
 	ag->num = num;
-
 	TAILQ_INSERT_TAIL(&c->autogroupq, ag, entry);
 }
 
@@ -111,17 +412,30 @@ conf_ignore(struct conf *c, const char *name)
 	TAILQ_INSERT_TAIL(&c->ignoreq, wn, entry);
 }
 
-static const char *color_binds[] = {
-	"#CCCCCC",	/* CWM_COLOR_BORDER_ACTIVE */
-	"#666666",	/* CWM_COLOR_BORDER_INACTIVE */
-	"#FC8814",	/* CWM_COLOR_BORDER_URGENCY */
-	"blue",		/* CWM_COLOR_BORDER_GROUP */
-	"red",		/* CWM_COLOR_BORDER_UNGROUP */
-	"black",	/* CWM_COLOR_MENU_FG */
-	"white",	/* CWM_COLOR_MENU_BG */
-	"black",	/* CWM_COLOR_MENU_FONT */
-	"",		/* CWM_COLOR_MENU_FONT_SEL */
-};
+void
+conf_cursor(struct conf *c)
+{
+	unsigned int	 i;
+
+	for (i = 0; i < nitems(cursor_binds); i++)
+		c->cursor[i] = XCreateFontCursor(X_Dpy, cursor_binds[i]);
+}
+
+void
+conf_client(struct client_ctx *cc)
+{
+	struct winname	*wn;
+	int		 ignore = 0;
+
+	TAILQ_FOREACH(wn, &Conf.ignoreq, entry) {
+		if (strncasecmp(wn->name, cc->name, strlen(wn->name)) == 0) {
+			ignore = 1;
+			break;
+		}
+	}
+	cc->bwidth = (ignore) ? 0 : Conf.bwidth;
+	cc->flags |= (ignore) ? CLIENT_IGNORE : 0;
+}
 
 void
 conf_screen(struct screen_ctx *sc)
@@ -174,322 +488,6 @@ conf_screen(struct screen_ctx *sc)
 	conf_grab_kbd(sc->rootwin);
 }
 
-static const struct {
-	const char	*key;
-	const char	*func;
-} kbd_binds[] = {
-	{ "CM-Return",	"terminal" },
-	{ "CM-Delete",	"lock" },
-	{ "M-question",	"exec" },
-	{ "CM-w",	"exec_wm" },
-	{ "M-period",	"ssh" },
-	{ "M-Return",	"hide" },
-	{ "M-Down",	"lower" },
-	{ "M-Up",	"raise" },
-	{ "M-slash",	"search" },
-	{ "C-slash",	"menusearch" },
-	{ "M-Tab",	"cycle" },
-	{ "MS-Tab",	"rcycle" },
-	{ "CM-n",	"label" },
-	{ "CM-x",	"delete" },
-	{ "CM-a",	"nogroup" },
-	{ "CM-0",	"nogroup" },
-	{ "CM-1",	"group1" },
-	{ "CM-2",	"group2" },
-	{ "CM-3",	"group3" },
-	{ "CM-4",	"group4" },
-	{ "CM-5",	"group5" },
-	{ "CM-6",	"group6" },
-	{ "CM-7",	"group7" },
-	{ "CM-8",	"group8" },
-	{ "CM-9",	"group9" },
-	{ "M-Right",	"cyclegroup" },
-	{ "M-Left",	"rcyclegroup" },
-	{ "CM-g",	"grouptoggle" },
-	{ "CM-f",	"fullscreen" },
-	{ "CM-m",	"maximize" },
-	{ "CM-s",	"stick" },
-	{ "CM-equal",	"vmaximize" },
-	{ "CMS-equal",	"hmaximize" },
-	{ "CMS-f",	"freeze" },
-	{ "CMS-r",	"restart" },
-	{ "CMS-q",	"quit" },
-	{ "M-h",	"moveleft" },
-	{ "M-j",	"movedown" },
-	{ "M-k",	"moveup" },
-	{ "M-l",	"moveright" },
-	{ "MS-h",	"bigmoveleft" },
-	{ "MS-j",	"bigmovedown" },
-	{ "MS-k",	"bigmoveup" },
-	{ "MS-l",	"bigmoveright" },
-	{ "CM-h",	"resizeleft" },
-	{ "CM-j",	"resizedown" },
-	{ "CM-k",	"resizeup" },
-	{ "CM-l",	"resizeright" },
-	{ "CMS-h",	"bigresizeleft" },
-	{ "CMS-j",	"bigresizedown" },
-	{ "CMS-k",	"bigresizeup" },
-	{ "CMS-l",	"bigresizeright" },
-	{ "C-Left",	"ptrmoveleft" },
-	{ "C-Down",	"ptrmovedown" },
-	{ "C-Up",	"ptrmoveup" },
-	{ "C-Right",	"ptrmoveright" },
-	{ "CS-Left",	"bigptrmoveleft" },
-	{ "CS-Down",	"bigptrmovedown" },
-	{ "CS-Up",	"bigptrmoveup" },
-	{ "CS-Right",	"bigptrmoveright" },
-},
-mouse_binds[] = {
-	{ "1",		"menu_unhide" },
-	{ "2",		"menu_group" },
-	{ "3",		"menu_cmd" },
-	{ "M-1",	"window_move" },
-	{ "CM-1",	"window_grouptoggle" },
-	{ "M-2",	"window_resize" },
-	{ "M-3",	"window_lower" },
-	{ "CMS-3",	"window_hide" },
-};
-
-void
-conf_init(struct conf *c)
-{
-	unsigned int	i;
-
-	c->stickygroups = 0;
-	c->bwidth = 1;
-	c->mamount = 1;
-	c->snapdist = 0;
-	c->ngroups = 10;
-	c->nameqlen = 5;
-
-	TAILQ_INIT(&c->ignoreq);
-	TAILQ_INIT(&c->cmdq);
-	TAILQ_INIT(&c->keybindq);
-	TAILQ_INIT(&c->autogroupq);
-	TAILQ_INIT(&c->mousebindq);
-
-	for (i = 0; i < nitems(kbd_binds); i++)
-		conf_bind_kbd(c, kbd_binds[i].key, kbd_binds[i].func);
-
-	for (i = 0; i < nitems(mouse_binds); i++)
-		conf_bind_mouse(c, mouse_binds[i].key, mouse_binds[i].func);
-
-	for (i = 0; i < nitems(color_binds); i++)
-		c->color[i] = xstrdup(color_binds[i]);
-
-	conf_cmd_add(c, "lock", "xlock");
-	conf_cmd_add(c, "term", "xterm");
-
-	(void)snprintf(c->known_hosts, sizeof(c->known_hosts), "%s/%s",
-	    homedir, ".ssh/known_hosts");
-
-	c->font = xstrdup("sans-serif:pixelsize=14:bold");
-	c->wmname = xstrdup("CWM");
-}
-
-void
-conf_clear(struct conf *c)
-{
-	struct autogroup	*ag;
-	struct bind_ctx		*kb, *mb;
-	struct winname		*wn;
-	struct cmd_ctx		*cmd;
-	int			 i;
-
-	while ((cmd = TAILQ_FIRST(&c->cmdq)) != NULL) {
-		TAILQ_REMOVE(&c->cmdq, cmd, entry);
-		free(cmd->name);
-		free(cmd);
-	}
-
-	while ((kb = TAILQ_FIRST(&c->keybindq)) != NULL) {
-		TAILQ_REMOVE(&c->keybindq, kb, entry);
-		free(kb);
-	}
-
-	while ((ag = TAILQ_FIRST(&c->autogroupq)) != NULL) {
-		TAILQ_REMOVE(&c->autogroupq, ag, entry);
-		free(ag->class);
-		free(ag->name);
-		free(ag);
-	}
-
-	while ((wn = TAILQ_FIRST(&c->ignoreq)) != NULL) {
-		TAILQ_REMOVE(&c->ignoreq, wn, entry);
-		free(wn->name);
-		free(wn);
-	}
-
-	while ((mb = TAILQ_FIRST(&c->mousebindq)) != NULL) {
-		TAILQ_REMOVE(&c->mousebindq, mb, entry);
-		free(mb);
-	}
-
-	for (i = 0; i < CWM_COLOR_NITEMS; i++)
-		free(c->color[i]);
-
-	free(c->font);
-	free(c->wmname);
-}
-
-void
-conf_client(struct client_ctx *cc)
-{
-	struct winname	*wn;
-	int		 ignore = 0;
-
-	TAILQ_FOREACH(wn, &Conf.ignoreq, entry) {
-		if (strncasecmp(wn->name, cc->name, strlen(wn->name)) == 0) {
-			ignore = 1;
-			break;
-		}
-	}
-
-	cc->bwidth = (ignore) ? 0 : Conf.bwidth;
-	cc->flags |= (ignore) ? CLIENT_IGNORE : 0;
-}
-
-static const struct {
-	const char	*tag;
-	void		 (*handler)(void *, union arg *, enum xev);
-	int		 context;
-	union arg	 argument;
-} name_to_func[] = {
-	{ "lower", kbfunc_client_lower, CWM_CONTEXT_CC, {0} },
-	{ "raise", kbfunc_client_raise, CWM_CONTEXT_CC, {0} },
-	{ "search", kbfunc_menu_client, CWM_CONTEXT_SC, {0} },
-	{ "menusearch", kbfunc_menu_cmd, CWM_CONTEXT_SC, {0} },
-	{ "groupsearch", kbfunc_menu_group, CWM_CONTEXT_SC, {0} },
-	{ "hide", kbfunc_client_hide, CWM_CONTEXT_CC, {0} },
-	{ "cycle", kbfunc_client_cycle, CWM_CONTEXT_SC,
-	    {.i = (CWM_CYCLE_FORWARD)} },
-	{ "rcycle", kbfunc_client_cycle, CWM_CONTEXT_SC,
-	    {.i = (CWM_CYCLE_REVERSE)} },
-	{ "label", kbfunc_menu_client_label, CWM_CONTEXT_CC, {0} },
-	{ "delete", kbfunc_client_delete, CWM_CONTEXT_CC, {0} },
-	{ "group1", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 1} },
-	{ "group2", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 2} },
-	{ "group3", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 3} },
-	{ "group4", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 4} },
-	{ "group5", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 5} },
-	{ "group6", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 6} },
-	{ "group7", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 7} },
-	{ "group8", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 8} },
-	{ "group9", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 9} },
-	{ "grouponly1", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 1} },
-	{ "grouponly2", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 2} },
-	{ "grouponly3", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 3} },
-	{ "grouponly4", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 4} },
-	{ "grouponly5", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 5} },
-	{ "grouponly6", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 6} },
-	{ "grouponly7", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 7} },
-	{ "grouponly8", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 8} },
-	{ "grouponly9", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 9} },
-	{ "movetogroup1", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 1} },
-	{ "movetogroup2", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 2} },
-	{ "movetogroup3", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 3} },
-	{ "movetogroup4", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 4} },
-	{ "movetogroup5", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 5} },
-	{ "movetogroup6", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 6} },
-	{ "movetogroup7", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 7} },
-	{ "movetogroup8", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 8} },
-	{ "movetogroup9", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 9} },
-	{ "nogroup", kbfunc_group_alltoggle, CWM_CONTEXT_SC, {0} },
-	{ "cyclegroup", kbfunc_group_cycle, CWM_CONTEXT_SC,
-	    {.i = (CWM_CYCLE_FORWARD)} },
-	{ "rcyclegroup", kbfunc_group_cycle, CWM_CONTEXT_SC,
-	    {.i = (CWM_CYCLE_REVERSE)} },
-	{ "cycleingroup", kbfunc_client_cycle, CWM_CONTEXT_SC,
-	    {.i = (CWM_CYCLE_FORWARD | CWM_CYCLE_INGROUP)} },
-	{ "rcycleingroup", kbfunc_client_cycle, CWM_CONTEXT_SC,
-	    {.i = (CWM_CYCLE_REVERSE | CWM_CYCLE_INGROUP)} },
-	{ "grouptoggle", kbfunc_client_toggle_group, CWM_CONTEXT_CC, {0} },
-	{ "stick", kbfunc_client_toggle_sticky, CWM_CONTEXT_CC, {0} },
-	{ "fullscreen", kbfunc_client_toggle_fullscreen, CWM_CONTEXT_CC, {0} },
-	{ "maximize", kbfunc_client_toggle_maximize, CWM_CONTEXT_CC, {0} },
-	{ "vmaximize", kbfunc_client_toggle_vmaximize, CWM_CONTEXT_CC, {0} },
-	{ "hmaximize", kbfunc_client_toggle_hmaximize, CWM_CONTEXT_CC, {0} },
-	{ "freeze", kbfunc_client_toggle_freeze, CWM_CONTEXT_CC, {0} },
-	{ "restart", kbfunc_cwm_status, CWM_CONTEXT_SC, {.i = CWM_EXEC_WM} },
-	{ "quit", kbfunc_cwm_status, CWM_CONTEXT_SC, {.i = CWM_QUIT} },
-	{ "exec", kbfunc_menu_exec, CWM_CONTEXT_SC,
-	    {.i = CWM_MENU_EXEC_EXEC} },
-	{ "exec_wm", kbfunc_menu_exec, CWM_CONTEXT_SC,
-	    {.i = CWM_MENU_EXEC_WM} },
-	{ "ssh", kbfunc_menu_ssh, CWM_CONTEXT_SC, {0} },
-	{ "terminal", kbfunc_exec_term, CWM_CONTEXT_SC, {0} },
-	{ "lock", kbfunc_exec_lock, CWM_CONTEXT_SC, {0} },
-	{ "moveup", kbfunc_client_move, CWM_CONTEXT_CC,
-	    {.i = (CWM_UP)} },
-	{ "movedown", kbfunc_client_move, CWM_CONTEXT_CC,
-	    {.i = (CWM_DOWN)} },
-	{ "moveright", kbfunc_client_move, CWM_CONTEXT_CC,
-	    {.i = (CWM_RIGHT)} },
-	{ "moveleft", kbfunc_client_move, CWM_CONTEXT_CC,
-	    {.i = (CWM_LEFT)} },
-	{ "bigmoveup", kbfunc_client_move, CWM_CONTEXT_CC,
-	    {.i = (CWM_UP | CWM_BIGAMOUNT)} },
-	{ "bigmovedown", kbfunc_client_move, CWM_CONTEXT_CC,
-	    {.i = (CWM_DOWN | CWM_BIGAMOUNT)} },
-	{ "bigmoveright", kbfunc_client_move, CWM_CONTEXT_CC,
-	    {.i = (CWM_RIGHT | CWM_BIGAMOUNT)} },
-	{ "bigmoveleft", kbfunc_client_move, CWM_CONTEXT_CC,
-	    {.i = (CWM_LEFT | CWM_BIGAMOUNT)} },
-	{ "resizeup", kbfunc_client_resize, CWM_CONTEXT_CC,
-	    {.i = (CWM_UP)} },
-	{ "resizedown", kbfunc_client_resize, CWM_CONTEXT_CC,
-	    {.i = (CWM_DOWN)} },
-	{ "resizeright", kbfunc_client_resize, CWM_CONTEXT_CC,
-	    {.i = (CWM_RIGHT)} },
-	{ "resizeleft", kbfunc_client_resize, CWM_CONTEXT_CC,
-	    {.i = (CWM_LEFT)} },
-	{ "bigresizeup", kbfunc_client_resize, CWM_CONTEXT_CC,
-	    {.i = (CWM_UP | CWM_BIGAMOUNT)} },
-	{ "bigresizedown", kbfunc_client_resize, CWM_CONTEXT_CC,
-	    {.i = (CWM_DOWN | CWM_BIGAMOUNT)} },
-	{ "bigresizeright", kbfunc_client_resize, CWM_CONTEXT_CC,
-	    {.i = (CWM_RIGHT | CWM_BIGAMOUNT)} },
-	{ "bigresizeleft", kbfunc_client_resize, CWM_CONTEXT_CC,
-	    {.i = (CWM_LEFT | CWM_BIGAMOUNT)} },
-	{ "ptrmoveup", kbfunc_ptrmove, CWM_CONTEXT_SC,
-	    {.i = (CWM_UP)} },
-	{ "ptrmovedown", kbfunc_ptrmove, CWM_CONTEXT_SC,
-	    {.i = (CWM_DOWN)} },
-	{ "ptrmoveleft", kbfunc_ptrmove, CWM_CONTEXT_SC,
-	    {.i = (CWM_LEFT)} },
-	{ "ptrmoveright", kbfunc_ptrmove, CWM_CONTEXT_SC,
-	    {.i = (CWM_RIGHT)} },
-	{ "bigptrmoveup", kbfunc_ptrmove, CWM_CONTEXT_SC,
-	    {.i = (CWM_UP | CWM_BIGAMOUNT)} },
-	{ "bigptrmovedown", kbfunc_ptrmove, CWM_CONTEXT_SC,
-	    {.i = (CWM_DOWN | CWM_BIGAMOUNT)} },
-	{ "bigptrmoveleft", kbfunc_ptrmove, CWM_CONTEXT_SC,
-	    {.i = (CWM_LEFT | CWM_BIGAMOUNT)} },
-	{ "bigptrmoveright", kbfunc_ptrmove, CWM_CONTEXT_SC,
-	    {.i = (CWM_RIGHT | CWM_BIGAMOUNT)} },
-	{ "htile", kbfunc_client_htile, CWM_CONTEXT_CC, {0} },
-	{ "vtile", kbfunc_client_vtile, CWM_CONTEXT_CC, {0} },
-	{ "window_lower", kbfunc_client_lower, CWM_CONTEXT_CC, {0} },
-	{ "window_raise", kbfunc_client_raise, CWM_CONTEXT_CC, {0} },
-	{ "window_hide", kbfunc_client_hide, CWM_CONTEXT_CC, {0} },
-	{ "window_move", mousefunc_client_move, CWM_CONTEXT_CC, {0} },
-	{ "window_resize", mousefunc_client_resize, CWM_CONTEXT_CC, {0} },
-	{ "window_grouptoggle", kbfunc_client_toggle_group, CWM_CONTEXT_CC, {0} },
-	{ "menu_group", kbfunc_menu_group, CWM_CONTEXT_SC, {0} },
-	{ "menu_unhide", kbfunc_menu_client, CWM_CONTEXT_SC, {0} },
-	{ "menu_cmd", kbfunc_menu_cmd, CWM_CONTEXT_SC, {0} },
-};
-
-static const struct {
-	const char	ch;
-	int		mask;
-} bind_mods[] = {
-	{ 'C',	ControlMask },
-	{ 'M',	Mod1Mask },
-	{ '4',	Mod4Mask },
-	{ 'S',	ShiftMask },
-};
-
 static const char *
 conf_bind_getmask(const char *name, unsigned int *mask)
 {
@@ -504,64 +502,60 @@ conf_bind_getmask(const char *name, unsigned int *mask)
 		if ((ch = strchr(name, bind_mods[i].ch)) != NULL && ch < dash)
 			*mask |= bind_mods[i].mask;
 	}
-
 	/* Skip past modifiers. */
 	return(dash + 1);
 }
 
 int
-conf_bind_kbd(struct conf *c, const char *bind, const char *cmd)
+conf_bind_key(struct conf *c, const char *bind, const char *cmd)
 {
 	struct bind_ctx	*kb;
 	const char	*key;
 	unsigned int	 i;
 
+	if ((strcmp(bind, "all") == 0) && (cmd == NULL)) {
+		conf_unbind_key(c, NULL);
+		goto out;
+	}
 	kb = xmalloc(sizeof(*kb));
 	key = conf_bind_getmask(bind, &kb->modmask);
-
 	kb->press.keysym = XStringToKeysym(key);
 	if (kb->press.keysym == NoSymbol) {
 		warnx("unknown symbol: %s", key);
 		free(kb);
 		return(0);
 	}
-
-	/* We now have the correct binding, remove duplicates. */
-	conf_unbind_kbd(c, kb);
-
-	if (strcmp("unmap", cmd) == 0) {
+	conf_unbind_key(c, kb);
+	if (cmd == NULL) {
 		free(kb);
-		return(1);
+		goto out;
 	}
-
 	for (i = 0; i < nitems(name_to_func); i++) {
 		if (strcmp(name_to_func[i].tag, cmd) != 0)
 			continue;
-
 		kb->callback = name_to_func[i].handler;
 		kb->context = name_to_func[i].context;
 		kb->argument = name_to_func[i].argument;
 		TAILQ_INSERT_TAIL(&c->keybindq, kb, entry);
-		return(1);
+		goto out;
 	}
-
 	kb->callback = kbfunc_exec_cmd;
 	kb->context = CWM_CONTEXT_NONE;
 	kb->argument.c = xstrdup(cmd);
 	TAILQ_INSERT_TAIL(&c->keybindq, kb, entry);
+out:
 	return(1);
 }
 
 static void
-conf_unbind_kbd(struct conf *c, struct bind_ctx *unbind)
+conf_unbind_key(struct conf *c, struct bind_ctx *unbind)
 {
 	struct bind_ctx	*key = NULL, *keynxt;
 
 	TAILQ_FOREACH_SAFE(key, &c->keybindq, entry, keynxt) {
-		if (key->modmask != unbind->modmask)
-			continue;
-
-		if (key->press.keysym == unbind->press.keysym) {
+		if ((unbind == NULL) ||
+		    ((key->modmask == unbind->modmask) &&
+		     (key->press.keysym == unbind->press.keysym))) {
 			TAILQ_REMOVE(&c->keybindq, key, entry);
 			if (key->context == CWM_CONTEXT_NONE)
 				free(key->argument.c);
@@ -577,36 +571,38 @@ conf_bind_mouse(struct conf *c, const char *bind, const char *cmd)
 	const char	*button, *errstr;
 	unsigned int	 i;
 
+	if ((strcmp(bind, "all") == 0) && (cmd == NULL)) {
+		conf_unbind_mouse(c, NULL);
+		goto out;
+	}
 	mb = xmalloc(sizeof(*mb));
 	button = conf_bind_getmask(bind, &mb->modmask);
-
 	mb->press.button = strtonum(button, Button1, Button5, &errstr);
 	if (errstr) {
 		warnx("button number is %s: %s", errstr, button);
 		free(mb);
 		return(0);
 	}
-
-	/* We now have the correct binding, remove duplicates. */
 	conf_unbind_mouse(c, mb);
-
-	if (strcmp("unmap", cmd) == 0) {
+	if (cmd == NULL) {
 		free(mb);
-		return(1);
+		goto out;
 	}
-
 	for (i = 0; i < nitems(name_to_func); i++) {
 		if (strcmp(name_to_func[i].tag, cmd) != 0)
 			continue;
-
 		mb->callback = name_to_func[i].handler;
 		mb->context = name_to_func[i].context;
 		mb->argument = name_to_func[i].argument;
 		TAILQ_INSERT_TAIL(&c->mousebindq, mb, entry);
-		return(1);
+		goto out;
 	}
-
-	return(0);
+	mb->callback = kbfunc_exec_cmd;
+	mb->context = CWM_CONTEXT_NONE;
+	mb->argument.c = xstrdup(cmd);
+	TAILQ_INSERT_TAIL(&c->mousebindq, mb, entry);
+out:
+	return(1);
 }
 
 static void
@@ -615,74 +611,56 @@ conf_unbind_mouse(struct conf *c, struct bind_ctx *unbind)
 	struct bind_ctx		*mb = NULL, *mbnxt;
 
 	TAILQ_FOREACH_SAFE(mb, &c->mousebindq, entry, mbnxt) {
-		if (mb->modmask != unbind->modmask)
-			continue;
-
-		if (mb->press.button == unbind->press.button) {
+		if ((unbind == NULL) || 
+		    ((mb->modmask == unbind->modmask) &&
+		     (mb->press.button == unbind->press.button))) {
 			TAILQ_REMOVE(&c->mousebindq, mb, entry);
+			if (mb->context == CWM_CONTEXT_NONE)
+				free(mb->argument.c);
 			free(mb);
 		}
 	}
 }
 
-static int cursor_binds[] = {
-	XC_left_ptr,		/* CF_NORMAL */
-	XC_fleur,		/* CF_MOVE */
-	XC_bottom_right_corner,	/* CF_RESIZE */
-	XC_question_arrow,	/* CF_QUESTION */
-};
-
 void
-conf_cursor(struct conf *c)
+conf_grab_kbd(Window win)
 {
+	struct bind_ctx	*kb;
+	KeyCode		 kc;
 	unsigned int	 i;
 
-	for (i = 0; i < nitems(cursor_binds); i++)
-		c->cursor[i] = XCreateFontCursor(X_Dpy, cursor_binds[i]);
-}
+	XUngrabKey(X_Dpy, AnyKey, AnyModifier, win);
 
-static unsigned int ign_mods[] = { 0, LockMask, Mod2Mask, Mod2Mask | LockMask };
+	TAILQ_FOREACH(kb, &Conf.keybindq, entry) {
+		kc = XKeysymToKeycode(X_Dpy, kb->press.keysym);
+		if ((XkbKeycodeToKeysym(X_Dpy, kc, 0, 0) != kb->press.keysym) &&
+		    (XkbKeycodeToKeysym(X_Dpy, kc, 0, 1) == kb->press.keysym))
+			kb->modmask |= ShiftMask;
+
+		for (i = 0; i < nitems(ignore_mods); i++)
+			XGrabKey(X_Dpy, kc, (kb->modmask | ignore_mods[i]), win,
+			    True, GrabModeAsync, GrabModeAsync);
+	}
+}
 
 void
 conf_grab_mouse(Window win)
 {
 	struct bind_ctx	*mb;
-	unsigned int	i;
+	unsigned int	 i;
 
 	XUngrabButton(X_Dpy, AnyButton, AnyModifier, win);
 
 	TAILQ_FOREACH(mb, &Conf.mousebindq, entry) {
 		if (mb->context != CWM_CONTEXT_CC)
 			continue;
-		for (i = 0; i < nitems(ign_mods); i++) {
+		for (i = 0; i < nitems(ignore_mods); i++) {
 			XGrabButton(X_Dpy, mb->press.button,
-			    (mb->modmask | ign_mods[i]), win, False,
+			    (mb->modmask | ignore_mods[i]), win, False,
 			    BUTTONMASK, GrabModeAsync, GrabModeSync,
 			    None, None);
 		}
 	}
-
-}
-
-void
-conf_grab_kbd(Window win)
-{
-	struct bind_ctx	*kb;
-	KeyCode		 kc;
-	unsigned int	 i;
-
-	XUngrabKey(X_Dpy, AnyKey, AnyModifier, win);
-
-	TAILQ_FOREACH(kb, &Conf.keybindq, entry) {
-		kc = XKeysymToKeycode(X_Dpy, kb->press.keysym);
-		if ((XkbKeycodeToKeysym(X_Dpy, kc, 0, 0) != kb->press.keysym) &&
-		    (XkbKeycodeToKeysym(X_Dpy, kc, 0, 1) == kb->press.keysym))
-			kb->modmask |= ShiftMask;
-
-		for (i = 0; i < nitems(ign_mods); i++)
-			XGrabKey(X_Dpy, kc, (kb->modmask | ign_mods[i]), win,
-			    True, GrabModeAsync, GrabModeAsync);
-	}
 }
 
 static char *cwmhints[] = {