diff options
Diffstat (limited to 'conf.c')
-rw-r--r-- | conf.c | 364 |
1 files changed, 201 insertions, 163 deletions
@@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: conf.c,v 1.224 2016/11/15 00:22:02 okan Exp $ + * $OpenBSD: conf.c,v 1.225 2016/12/01 17:17:27 okan Exp $ */ #include <sys/types.h> @@ -35,7 +35,9 @@ static const char *conf_bind_getmask(const char *, unsigned int *); static void conf_cmd_remove(struct conf *, const char *); static void conf_unbind_key(struct conf *, struct bind_ctx *); +static void conf_unbind_key_all(struct conf *); static void conf_unbind_mouse(struct conf *, struct bind_ctx *); +static void conf_unbind_mouse_all(struct conf *); static int cursor_binds[] = { XC_left_ptr, /* CF_NORMAL */ @@ -60,129 +62,129 @@ static const struct { 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, + { "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-search", kbfunc_menu_client, CWM_CONTEXT_SC, {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)} }, - { "rcycle", kbfunc_client_cycle, CWM_CONTEXT_SC, + { "window-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, + { "window-cycle-ingroup", kbfunc_client_cycle, CWM_CONTEXT_SC, {.i = (CWM_CYCLE_FORWARD | CWM_CYCLE_INGROUP)} }, - { "rcycleingroup", kbfunc_client_cycle, CWM_CONTEXT_SC, + { "window-rcycle-ingroup", 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, + { "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)} }, - { "movedown", kbfunc_client_move, CWM_CONTEXT_CC, + { "window-move-down", kbfunc_client_move, CWM_CONTEXT_CC, {.i = (CWM_DOWN)} }, - { "moveright", kbfunc_client_move, CWM_CONTEXT_CC, + { "window-move-right", kbfunc_client_move, CWM_CONTEXT_CC, {.i = (CWM_RIGHT)} }, - { "moveleft", kbfunc_client_move, CWM_CONTEXT_CC, + { "window-move-left", kbfunc_client_move, CWM_CONTEXT_CC, {.i = (CWM_LEFT)} }, - { "bigmoveup", kbfunc_client_move, CWM_CONTEXT_CC, + { "window-move-up-big", kbfunc_client_move, CWM_CONTEXT_CC, {.i = (CWM_UP | CWM_BIGAMOUNT)} }, - { "bigmovedown", kbfunc_client_move, CWM_CONTEXT_CC, + { "window-move-down-big", kbfunc_client_move, CWM_CONTEXT_CC, {.i = (CWM_DOWN | CWM_BIGAMOUNT)} }, - { "bigmoveright", kbfunc_client_move, CWM_CONTEXT_CC, + { "window-move-right-big", kbfunc_client_move, CWM_CONTEXT_CC, {.i = (CWM_RIGHT | CWM_BIGAMOUNT)} }, - { "bigmoveleft", kbfunc_client_move, CWM_CONTEXT_CC, + { "window-move-left-big", kbfunc_client_move, CWM_CONTEXT_CC, {.i = (CWM_LEFT | CWM_BIGAMOUNT)} }, - { "resizeup", kbfunc_client_resize, CWM_CONTEXT_CC, + { "window-resize", mousefunc_client_resize, CWM_CONTEXT_CC, {0} }, + { "window-resize-up", kbfunc_client_resize, CWM_CONTEXT_CC, {.i = (CWM_UP)} }, - { "resizedown", kbfunc_client_resize, CWM_CONTEXT_CC, + { "window-resize-down", kbfunc_client_resize, CWM_CONTEXT_CC, {.i = (CWM_DOWN)} }, - { "resizeright", kbfunc_client_resize, CWM_CONTEXT_CC, + { "window-resize-right", kbfunc_client_resize, CWM_CONTEXT_CC, {.i = (CWM_RIGHT)} }, - { "resizeleft", kbfunc_client_resize, CWM_CONTEXT_CC, + { "window-resize-left", kbfunc_client_resize, CWM_CONTEXT_CC, {.i = (CWM_LEFT)} }, - { "bigresizeup", kbfunc_client_resize, CWM_CONTEXT_CC, + { "window-resize-up-big", kbfunc_client_resize, CWM_CONTEXT_CC, {.i = (CWM_UP | CWM_BIGAMOUNT)} }, - { "bigresizedown", kbfunc_client_resize, CWM_CONTEXT_CC, + { "window-resize-down-big", kbfunc_client_resize, CWM_CONTEXT_CC, {.i = (CWM_DOWN | CWM_BIGAMOUNT)} }, - { "bigresizeright", kbfunc_client_resize, CWM_CONTEXT_CC, + { "window-resize-right-big", kbfunc_client_resize, CWM_CONTEXT_CC, {.i = (CWM_RIGHT | CWM_BIGAMOUNT)} }, - { "bigresizeleft", kbfunc_client_resize, CWM_CONTEXT_CC, + { "window-resize-left-big", kbfunc_client_resize, CWM_CONTEXT_CC, {.i = (CWM_LEFT | CWM_BIGAMOUNT)} }, - { "ptrmoveup", kbfunc_ptrmove, CWM_CONTEXT_SC, + + { "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)} }, - { "ptrmovedown", kbfunc_ptrmove, CWM_CONTEXT_SC, + { "pointer-move-down", kbfunc_ptrmove, CWM_CONTEXT_SC, {.i = (CWM_DOWN)} }, - { "ptrmoveleft", kbfunc_ptrmove, CWM_CONTEXT_SC, + { "pointer-move-left", kbfunc_ptrmove, CWM_CONTEXT_SC, {.i = (CWM_LEFT)} }, - { "ptrmoveright", kbfunc_ptrmove, CWM_CONTEXT_SC, + { "pointer-move-right", kbfunc_ptrmove, CWM_CONTEXT_SC, {.i = (CWM_RIGHT)} }, - { "bigptrmoveup", kbfunc_ptrmove, CWM_CONTEXT_SC, + { "pointer-move-up-big", kbfunc_ptrmove, CWM_CONTEXT_SC, {.i = (CWM_UP | CWM_BIGAMOUNT)} }, - { "bigptrmovedown", kbfunc_ptrmove, CWM_CONTEXT_SC, + { "pointer-move-down-big", kbfunc_ptrmove, CWM_CONTEXT_SC, {.i = (CWM_DOWN | CWM_BIGAMOUNT)} }, - { "bigptrmoveleft", kbfunc_ptrmove, CWM_CONTEXT_SC, + { "pointer-move-left-big", kbfunc_ptrmove, CWM_CONTEXT_SC, {.i = (CWM_LEFT | CWM_BIGAMOUNT)} }, - { "bigptrmoveright", kbfunc_ptrmove, CWM_CONTEXT_SC, + { "pointer-move-right-big", 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} }, + + { "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, {0} }, + { "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 @@ -202,66 +204,66 @@ static const struct { } key_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" }, + { "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", "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" }, + { "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_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" }, + { "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 @@ -510,6 +512,10 @@ conf_bind_key(struct conf *c, const char *bind, const char *cmd) const char *key; unsigned int i; + if ((strcmp(bind, "all") == 0) && (cmd == NULL)) { + conf_unbind_key_all(c); + goto out; + } kb = xmalloc(sizeof(*kb)); key = conf_bind_getmask(bind, &kb->modmask); kb->press.keysym = XStringToKeysym(key); @@ -518,12 +524,10 @@ conf_bind_key(struct conf *c, const char *bind, const char *cmd) free(kb); return(0); } - /* Remove duplicates. */ conf_unbind_key(c, kb); - - if (strcmp("unmap", cmd) == 0) { + 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) @@ -532,12 +536,13 @@ conf_bind_key(struct conf *c, const char *bind, const char *cmd) 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); } @@ -558,6 +563,19 @@ conf_unbind_key(struct conf *c, struct bind_ctx *unbind) } } +static void +conf_unbind_key_all(struct conf *c) +{ + struct bind_ctx *key = NULL, *keynxt; + + TAILQ_FOREACH_SAFE(key, &c->keybindq, entry, keynxt) { + TAILQ_REMOVE(&c->keybindq, key, entry); + if (key->context == CWM_CONTEXT_NONE) + free(key->argument.c); + free(key); + } +} + int conf_bind_mouse(struct conf *c, const char *bind, const char *cmd) { @@ -565,6 +583,10 @@ 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_all(c); + goto out; + } mb = xmalloc(sizeof(*mb)); button = conf_bind_getmask(bind, &mb->modmask); mb->press.button = strtonum(button, Button1, Button5, &errstr); @@ -573,12 +595,10 @@ conf_bind_mouse(struct conf *c, const char *bind, const char *cmd) free(mb); return(0); } - /* 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) @@ -587,9 +607,14 @@ conf_bind_mouse(struct conf *c, const char *bind, const char *cmd) 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 @@ -607,6 +632,19 @@ conf_unbind_mouse(struct conf *c, struct bind_ctx *unbind) } } +static void +conf_unbind_mouse_all(struct conf *c) +{ + struct bind_ctx *mb = NULL, *mbnxt; + + TAILQ_FOREACH_SAFE(mb, &c->mousebindq, entry, mbnxt) { + TAILQ_REMOVE(&c->mousebindq, mb, entry); + if (mb->context == CWM_CONTEXT_NONE) + free(mb->argument.c); + free(mb); + } +} + void conf_grab_kbd(Window win) { |