From ceb545c78714e7691b5bad3df39f8ce682bf30d0 Mon Sep 17 00:00:00 2001 From: okan Date: Thu, 1 Dec 2016 17:17:27 +0000 Subject: Normalize bind function names, based on a few categories: window, group, menu and pointer. Replace 'bind' and 'mousebind' options with 'bind-key' and 'bind-mouse', respectively, replace special 'unmap' keyword with 'unbind-key' and 'unbind-mouse', and additionally allow unbinding all with 'all' keyword. --- conf.c | 364 +++++++++++++++++++++++++++++++++++----------------------------- cwmrc.5 | 317 +++++++++++++++++++++++++++---------------------------- parse.y | 53 +++++++--- 3 files changed, 390 insertions(+), 344 deletions(-) diff --git a/conf.c b/conf.c index 50cf846..a8473a7 100644 --- a/conf.c +++ b/conf.c @@ -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 @@ -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) { diff --git a/cwmrc.5 b/cwmrc.5 index cdf42c4..df0c08e 100644 --- a/cwmrc.5 +++ b/cwmrc.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: cwmrc.5,v 1.63 2016/10/05 14:01:23 okan Exp $ +.\" $OpenBSD: cwmrc.5,v 1.64 2016/12/01 17:17:27 okan Exp $ .\" .\" Copyright (c) 2004,2005 Marius Aamodt Eriksen .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: October 5 2016 $ +.Dd $Mdocdate: December 1 2016 $ .Dt CWMRC 5 .Os .Sh NAME @@ -63,11 +63,15 @@ The name and class values, respectively, for existing windows are both set in the WM_CLASS property and may be obtained using .Xr xprop 1 . .Pp -.It Ic bind Ar keys command -Cause the creation of a key binding, or replacement of a default -key binding. +.It Ic bind-key Ar key function +Bind or rebind key +.Ar key +to +.Ar function . The modifier keys come first, followed by a -.Sq - . +.Sq - , +then a keysym name, taken from +.Pa /usr/X11R6/include/X11/keysymdef.h . .Pp The following modifiers are recognised: .Pp @@ -83,22 +87,53 @@ Mod4 (windows) key. .El .Pp The -.Sq - -should be followed by a keysym name, taken from -.Pa /usr/X11R6/include/X11/keysymdef.h . -The -.Ar command +.Ar function may either be one from the -.Sx BIND COMMAND LIST +.Sx BIND FUNCTION LIST (see below) or the command line that is to be executed. .Pp -A special -.Ar command -keyword -.Dq unmap -can be used to remove the named key binding. -This can be used to remove a binding which conflicts with an -application. +.It Ic bind-mouse Ar button function +Bind or rebind button +.Ar button +to +.Ar function . +The modifier keys come first, followed by a +.Sq - , +then the button number. +.Pp +The following modifiers are recognised: +.Pp +.Bl -tag -width Ds -offset indent -compact +.It Ic C +Control key. +.It Ic M +Meta key. +.It Ic S +Shift key. +.It Ic 4 +Mod4 (windows) key. +.El +.Pp +The following buttons are recognised: +.Pp +.Bl -tag -width Ds -offset indent -compact +.It Ic 1 +Left mouse button. +.It Ic 2 +Middle mouse button. +.It Ic 3 +Right mouse button. +.It Ic 4 +Scroll up mouse button. +.It Ic 5 +Scroll down mouse button. +.El +.Pp +The +.Ar function +may be taken from the +.Sx BIND FUNCTION LIST +(see below) or the command line that is to be executed. .Pp .It Ic borderwidth Ar pixels Set the window border width to @@ -177,48 +212,6 @@ Ignore, and do not warp to, windows with the name .Ar windowname when drawing borders and cycling through windows. .Pp -.It Ic mousebind Ar buttons command -Cause the creation of a mouse binding, or replacement of a default -mouse binding. -The modifier keys come first, followed by a -.Sq - . -.Pp -The following modifiers are recognised: -.Pp -.Bl -tag -width Ds -offset indent -compact -.It Ic C -Control key. -.It Ic M -Meta key. -.It Ic S -Shift key. -.It Ic 4 -Mod4 (windows) key. -.El -.Pp -The -.Sq - -should be followed by number: -.Pp -.Bl -tag -width Ds -offset indent -compact -.It Ic 1 -Left mouse button. -.It Ic 2 -Middle mouse button. -.It Ic 3 -Right mouse button. -.It Ic 4 -Scroll up mouse button. -.It Ic 5 -Scroll down mouse button. -.El -.Pp -The -.Ar command -may be taken from the -.Sx MOUSEBIND COMMAND LIST -(see below). -.Pp .It Ic moveamount Ar pixels Set a default size for the keyboard movement bindings, in pixels. @@ -234,9 +227,28 @@ The default behavior for new windows is to not assign any group. By enabling sticky group mode, .Xr cwm 1 will assign new windows to the currently selected group. +.Pp +.It Ic unbind-key Ar key +Unbind function bound to +.Ar key . +A special +.Ar key +keyword +.Dq all +can be used to unbind all keys. +.Pp +.It Ic unbind-mouse Ar button +Unbind function bound to +.Ar button . +A special +.Ar button +keyword +.Dq all +can be used to unbind all buttons. +.Pp .El -.Sh BIND COMMAND LIST -.Bl -tag -width 18n -compact +.Sh BIND FUNCTION LIST +.Bl -tag -width 23n -compact .It restart Restart the running .Xr cwm 1 . @@ -247,197 +259,174 @@ Quit Spawn a new terminal. .It lock Lock the screen. -.It search +.It menu-window Launch window search menu. -.It menusearch +.It menu-cmd Launch application search menu. -.It groupsearch +.It menu-group Launch group search menu. -.It exec +.It menu-exec Launch .Dq exec program menu. -.It exec_wm +.It menu-exec-wm Launch .Dq exec WindowManager menu. -.It ssh +.It menu-ssh Launch .Dq ssh menu. -.It group[n] +.It group-toggle-[n] Toggle visibility of group n, where n is 1-9. -.It grouponly[n] -Like -.Ar group[n] -but also hides the other groups. -.It nogroup +.It group-only-[n] +Show only group n, where n is 1-9, hiding other groups. +.It window-toggle-all Toggle visibility of all groups. -.It grouptoggle +.It window-group Toggle group membership of current window. -.It movetogroup[n] +.It window-movetogroup-[n] Hide current window from display and move to group n, where n is 1-9. -.It cyclegroup +.It group-cycle Forward cycle through groups. -.It rcyclegroup +.It group-rcycle Reverse cycle through groups. -.It cycle +.It window-cycle Forward cycle through windows. -.It rcycle +.It window-rcycle Reverse cycle through windows. -.It cycleingroup +.It window-cycle-ingroup Forward cycle through windows in current group. -.It rcycleingroup +.It window-rcycle-ingroup Reverse cycle through windows in current group. -.It delete +.It window-delete Delete current window. -.It hide +.It window-hide Hide current window. -.It lower +.It window-lower Lower current window. -.It raise +.It window-raise Raise current window. -.It label +.It window-menu-label Label current window. -.It freeze +.It window-freeze Freeze current window geometry. -.It stick +.It window-stick Stick current window to all groups (same as assigning to nogroup). -.It fullscreen +.It window-fullscreen Full-screen current window (gap + border removed). -.It maximize +.It window-maximize Maximize current window (gap + border honored). -.It vmaximize +.It window-vmaximize Vertically maximize current window (gap + border honored). -.It hmaximize +.It window-hmaximize Horizontally maximize current window (gap + border honored). -.It moveup +.It window-htile +Current window is placed at the top of the screen and maximized +horizontally, other windows in its group share remaining screen space. +.It window-vtile +Current window is placed on the left of the screen and maximized +vertically, other windows in its group share remaining screen space. +.It window-move +Move current window. +.It window-resize +Resize current window. +.It window-move-up Move window .Ar moveamount pixels up. -.It movedown +.It window-move-down Move window .Ar moveamount pixels down. -.It moveright +.It window-move-right Move window .Ar moveamount pixels right. -.It moveleft +.It window-move-left Move window .Ar moveamount pixels left. -.It bigmoveup +.It window-move-up-big Move window 10 times .Ar moveamount pixels up. -.It bigmovedown +.It window-move-down-big Move window 10 times .Ar moveamount pixels down. -.It bigmoveright +.It window-move-right-big Move window 10 times .Ar moveamount pixels right. -.It bigmoveleft +.It window-move-left-big Move window 10 times .Ar moveamount pixels left. -.It resizeup +.It window-resize-up Resize window .Ar moveamount pixels up. -.It resizedown +.It window-resize-down Resize window .Ar moveamount pixels down. -.It resizeright +.It window-resize-right Resize window .Ar moveamount pixels right. -.It resizeleft +.It window-resize-left Resize window .Ar moveamount pixels left. -.It bigresizeup +.It window-resize-up-big Resize window 10 times .Ar moveamount pixels up. -.It bigresizedown +.It window-resize-down-big Resize window 10 times .Ar moveamount pixels down. -.It bigresizeright +.It window-resize-right-big Resize window 10 times .Ar moveamount pixels right. -.It bigresizeleft +.It window-resize-left-big Resize window 10 times .Ar moveamount pixels left. -.It ptrmoveup +.It pointer-move-up Move pointer .Ar moveamount pixels up. -.It ptrmovedown +.It pointer-move-down Move pointer .Ar moveamount pixels down. -.It ptrmoveright +.It pointer-move-right Move pointer .Ar moveamount pixels right. -.It ptrmoveleft +.It pointer-move-left Move pointer .Ar moveamount pixels left. -.It bigptrmoveup +.It pointer-move-up-big Move pointer 10 times .Ar moveamount pixels up. -.It bigptrmovedown +.It pointer-move-down-big Move pointer 10 times .Ar moveamount pixels down. -.It bigptrmoveright +.It pointer-move-right-big Move pointer 10 times .Ar moveamount pixels right. -.It bigptrmoveleft +.It pointer-move-left-big Move pointer 10 times .Ar moveamount pixels left. -.It htile -Current window is placed at the top of the screen and maximized -horizontally, other windows in its group share remaining screen space. -.It vtile -Current window is placed on the left of the screen and maximized -vertically, other windows in its group share remaining screen space. -.El -.Sh MOUSEBIND COMMAND LIST -.Bl -tag -width 18n -compact -.It window_move -Move current window. -.It window_resize -Resize current window. -.It window_lower -Lower current window. -.It window_raise -Raise current window. -.It window_hide -Hide current window. -.It window_grouptoggle -Toggle group membership of current window. -.It cyclegroup -Forward cycle through groups. -.It rcyclegroup -Reverse cycle through groups. -.It menu_group -Launch group list. -.It menu_unhide -Launch hidden window list. -.It menu_cmd -Launch command list. .El .Sh FILES .Bl -tag -width "~/.cwmrcXXX" -compact @@ -470,23 +459,23 @@ ignore xapm ignore xclock # Key bindings -bind CM-r label -bind CS-Return "xterm -e top" -bind 4-o unmap -bind CM-equal unmap -bind CMS-equal unmap -bind C4-equal vmaximize -bind C4S-equal hmaximize -bind M-1 grouponly1 -bind M-2 grouponly2 -bind M-3 grouponly3 -bind MS-1 movetogroup1 -bind MS-2 movetogroup2 -bind MS-3 movetogroup3 +bind-key CM-r window-menu-label +bind-key CS-Return "xterm -e top" +bind-key C4-equal window-vmaximize +bind-key C4S-equal window-hmaximize +bind-key M-1 group-only-1 +bind-key M-2 group-only-2 +bind-key M-3 group-only-3 +bind-key MS-1 window-movetogroup-1 +bind-key MS-2 window-movetogroup-2 +bind-key MS-3 window-movetogroup-3 +unbind-key 4-o +unbind-key CM-equal +unbind-key CMS-equal # Mouse bindings -mousebind M-2 window_lower -mousebind M-3 window_resize +bind-mouse M-2 window-lower +bind-mouse M-3 window-resize .Ed .Sh SEE ALSO .Xr cwm 1 diff --git a/parse.y b/parse.y index 7ed8f93..65db97b 100644 --- a/parse.y +++ b/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.66 2016/11/14 21:25:59 okan Exp $ */ +/* $OpenBSD: parse.y,v 1.67 2016/12/01 17:17:27 okan Exp $ */ /* * Copyright (c) 2002, 2003, 2004 Henning Brauer @@ -68,8 +68,9 @@ typedef struct { %} -%token FONTNAME STICKY GAP MOUSEBIND -%token AUTOGROUP BIND COMMAND IGNORE +%token BINDKEY UNBINDKEY BINDMOUSE UNBINDMOUSE +%token FONTNAME STICKY GAP +%token AUTOGROUP COMMAND IGNORE %token YES NO BORDERWIDTH MOVEAMOUNT %token COLOR SNAPDIST %token ACTIVEBORDER INACTIVEBORDER URGENCYBORDER @@ -169,16 +170,6 @@ main : FONTNAME STRING { conf_ignore(conf, $2); free($2); } - | BIND STRING string { - if (!conf_bind_key(conf, $2, $3)) { - yyerror("invalid bind: %s %s", $2, $3); - free($2); - free($3); - YYERROR; - } - free($2); - free($3); - } | GAP NUMBER NUMBER NUMBER NUMBER { if ($2 < 0 || $2 > INT_MAX || $3 < 0 || $3 > INT_MAX || @@ -192,9 +183,27 @@ main : FONTNAME STRING { conf->gap.left = $4; conf->gap.right = $5; } - | MOUSEBIND STRING string { + | BINDKEY STRING string { + if (!conf_bind_key(conf, $2, $3)) { + yyerror("invalid bind-key: %s %s", $2, $3); + free($2); + free($3); + YYERROR; + } + free($2); + free($3); + } + | UNBINDKEY STRING { + if (!conf_bind_key(conf, $2, NULL)) { + yyerror("invalid unbind-key: %s", $2); + free($2); + YYERROR; + } + free($2); + } + | BINDMOUSE STRING string { if (!conf_bind_mouse(conf, $2, $3)) { - yyerror("invalid mousebind: %s %s", $2, $3); + yyerror("invalid bind-mouse: %s %s", $2, $3); free($2); free($3); YYERROR; @@ -202,6 +211,14 @@ main : FONTNAME STRING { free($2); free($3); } + | UNBINDMOUSE STRING { + if (!conf_bind_mouse(conf, $2, NULL)) { + yyerror("invalid unbind-mouse: %s", $2); + free($2); + YYERROR; + } + free($2); + } ; color : COLOR colors @@ -278,7 +295,8 @@ lookup(char *s) static const struct keywords keywords[] = { { "activeborder", ACTIVEBORDER}, { "autogroup", AUTOGROUP}, - { "bind", BIND}, + { "bind-key", BINDKEY}, + { "bind-mouse", BINDMOUSE}, { "borderwidth", BORDERWIDTH}, { "color", COLOR}, { "command", COMMAND}, @@ -290,12 +308,13 @@ lookup(char *s) { "inactiveborder", INACTIVEBORDER}, { "menubg", MENUBG}, { "menufg", MENUFG}, - { "mousebind", MOUSEBIND}, { "moveamount", MOVEAMOUNT}, { "no", NO}, { "selfont", FONTSELCOLOR}, { "snapdist", SNAPDIST}, { "sticky", STICKY}, + { "unbind-key", UNBINDKEY}, + { "unbind-mouse", UNBINDMOUSE}, { "ungroupborder", UNGROUPBORDER}, { "urgencyborder", URGENCYBORDER}, { "yes", YES} -- cgit v1.2.3-2-gb3c3