diff options
author | okan <okan> | 2015-11-12 21:28:03 +0000 |
---|---|---|
committer | okan <okan> | 2015-11-12 21:28:03 +0000 |
commit | 4e51ce57a7b773f66304072f7c369f58e0a62159 (patch) | |
tree | 9ad7cbe078aac6879cba972d04d1781025b8b5b3 /conf.c | |
parent | cd21e166754c24e9bbcde1ee3a689079a073cc5b (diff) | |
parent | 323672ace778a61f6f51032453f781d50701e349 (diff) | |
download | cwm-4e51ce57a7b773f66304072f7c369f58e0a62159.tar.gz cwm-4e51ce57a7b773f66304072f7c369f58e0a62159.tar.xz cwm-4e51ce57a7b773f66304072f7c369f58e0a62159.zip |
cvsimport
* refs/heads/master: more client vs screen context differences If a client sets hints, honor them for kb resize requests, just like we do for mouse based resize requests. Move kb pointer movement out of the kbfunc_client_moveresize since it's got nothing to do with clients, thus doing flags work causes lots of waste and almost useless jumpy pointer movements; while here, split out move and resize since they share almost no code, just like mouse client move/resize; factor out amount and factor. Still wonder why this is here, but it works now. pledge "stdio rpath proc exec" cwm before main event loop, after init/setup - mostly for menu building. Partial revert of replacing screen_area() with region_find(); until a fix for a regression is found; this bug has been around for a long time it seems, but this change exposed it. Likely need to track clients in to and out of regions. Use position on root to figure out region. Start cleaning up name vs function differences; replace magic numbers. Clean up unused defines. Extend region to include both view and work areas; switch to region_find() which no longer needs to recalculate gap each time a client (or menu) is created or altered. If no RandR, fall back to display dimensions while building regions instead of during execution.
Diffstat (limited to 'conf.c')
-rw-r--r-- | conf.c | 270 |
1 files changed, 146 insertions, 124 deletions
diff --git a/conf.c b/conf.c index a709d4c..13c08d2 100644 --- a/conf.c +++ b/conf.c @@ -346,126 +346,148 @@ conf_client(struct client_ctx *cc) static const struct { const char *tag; void (*handler)(struct client_ctx *, union arg *); - int flags; + int context; union arg argument; } name_to_func[] = { - { "lower", kbfunc_client_lower, CWM_WIN, {0} }, - { "raise", kbfunc_client_raise, CWM_WIN, {0} }, - { "search", kbfunc_client_search, 0, {0} }, - { "menusearch", kbfunc_menu_cmd, 0, {0} }, - { "groupsearch", kbfunc_menu_group, 0, {0} }, - { "hide", kbfunc_client_hide, CWM_WIN, {0} }, - { "cycle", kbfunc_client_cycle, 0, {.i = CWM_CYCLE} }, - { "rcycle", kbfunc_client_cycle, 0, {.i = CWM_RCYCLE} }, - { "label", kbfunc_client_label, CWM_WIN, {0} }, - { "delete", kbfunc_client_delete, CWM_WIN, {0} }, - { "group1", kbfunc_client_group, 0, {.i = 1} }, - { "group2", kbfunc_client_group, 0, {.i = 2} }, - { "group3", kbfunc_client_group, 0, {.i = 3} }, - { "group4", kbfunc_client_group, 0, {.i = 4} }, - { "group5", kbfunc_client_group, 0, {.i = 5} }, - { "group6", kbfunc_client_group, 0, {.i = 6} }, - { "group7", kbfunc_client_group, 0, {.i = 7} }, - { "group8", kbfunc_client_group, 0, {.i = 8} }, - { "group9", kbfunc_client_group, 0, {.i = 9} }, - { "grouponly1", kbfunc_client_grouponly, 0, {.i = 1} }, - { "grouponly2", kbfunc_client_grouponly, 0, {.i = 2} }, - { "grouponly3", kbfunc_client_grouponly, 0, {.i = 3} }, - { "grouponly4", kbfunc_client_grouponly, 0, {.i = 4} }, - { "grouponly5", kbfunc_client_grouponly, 0, {.i = 5} }, - { "grouponly6", kbfunc_client_grouponly, 0, {.i = 6} }, - { "grouponly7", kbfunc_client_grouponly, 0, {.i = 7} }, - { "grouponly8", kbfunc_client_grouponly, 0, {.i = 8} }, - { "grouponly9", kbfunc_client_grouponly, 0, {.i = 9} }, - { "movetogroup1", kbfunc_client_movetogroup, CWM_WIN, {.i = 1} }, - { "movetogroup2", kbfunc_client_movetogroup, CWM_WIN, {.i = 2} }, - { "movetogroup3", kbfunc_client_movetogroup, CWM_WIN, {.i = 3} }, - { "movetogroup4", kbfunc_client_movetogroup, CWM_WIN, {.i = 4} }, - { "movetogroup5", kbfunc_client_movetogroup, CWM_WIN, {.i = 5} }, - { "movetogroup6", kbfunc_client_movetogroup, CWM_WIN, {.i = 6} }, - { "movetogroup7", kbfunc_client_movetogroup, CWM_WIN, {.i = 7} }, - { "movetogroup8", kbfunc_client_movetogroup, CWM_WIN, {.i = 8} }, - { "movetogroup9", kbfunc_client_movetogroup, CWM_WIN, {.i = 9} }, - { "nogroup", kbfunc_client_nogroup, 0, {0} }, - { "cyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_CYCLE} }, - { "rcyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_RCYCLE} }, - { "cycleingroup", kbfunc_client_cycle, CWM_WIN, - {.i = (CWM_CYCLE | CWM_INGROUP)} }, - { "rcycleingroup", kbfunc_client_cycle, CWM_WIN, - {.i = (CWM_RCYCLE | CWM_INGROUP)} }, - { "grouptoggle", kbfunc_client_grouptoggle, CWM_WIN, {.i = 0}}, - { "sticky", kbfunc_client_toggle_sticky, CWM_WIN, {0} }, - { "fullscreen", kbfunc_client_toggle_fullscreen, CWM_WIN, {0} }, - { "maximize", kbfunc_client_toggle_maximize, CWM_WIN, {0} }, - { "vmaximize", kbfunc_client_toggle_vmaximize, CWM_WIN, {0} }, - { "hmaximize", kbfunc_client_toggle_hmaximize, CWM_WIN, {0} }, - { "freeze", kbfunc_client_toggle_freeze, CWM_WIN, {0} }, - { "restart", kbfunc_cwm_status, 0, {.i = CWM_EXECWM} }, - { "quit", kbfunc_cwm_status, 0, {.i = CWM_QUIT} }, - { "exec", kbfunc_exec, 0, {.i = CWM_EXEC_PROGRAM} }, - { "exec_wm", kbfunc_exec, 0, {.i = CWM_EXEC_WM} }, - { "ssh", kbfunc_ssh, 0, {0} }, - { "terminal", kbfunc_term, 0, {0} }, - { "lock", kbfunc_lock, 0, {0} }, - { "moveup", kbfunc_client_moveresize, CWM_WIN, - {.i = (CWM_UP | CWM_MOVE)} }, - { "movedown", kbfunc_client_moveresize, CWM_WIN, - {.i = (CWM_DOWN | CWM_MOVE)} }, - { "moveright", kbfunc_client_moveresize, CWM_WIN, - {.i = (CWM_RIGHT | CWM_MOVE)} }, - { "moveleft", kbfunc_client_moveresize, CWM_WIN, - {.i = (CWM_LEFT | CWM_MOVE)} }, - { "bigmoveup", kbfunc_client_moveresize, CWM_WIN, - {.i = (CWM_UP | CWM_MOVE | CWM_BIGMOVE)} }, - { "bigmovedown", kbfunc_client_moveresize, CWM_WIN, - {.i = (CWM_DOWN | CWM_MOVE | CWM_BIGMOVE)} }, - { "bigmoveright", kbfunc_client_moveresize, CWM_WIN, - {.i = (CWM_RIGHT | CWM_MOVE | CWM_BIGMOVE)} }, - { "bigmoveleft", kbfunc_client_moveresize, CWM_WIN, - {.i = (CWM_LEFT | CWM_MOVE | CWM_BIGMOVE)} }, - { "resizeup", kbfunc_client_moveresize, CWM_WIN, - {.i = (CWM_UP | CWM_RESIZE)} }, - { "resizedown", kbfunc_client_moveresize, CWM_WIN, - {.i = (CWM_DOWN | CWM_RESIZE)} }, - { "resizeright", kbfunc_client_moveresize, CWM_WIN, - {.i = (CWM_RIGHT | CWM_RESIZE)} }, - { "resizeleft", kbfunc_client_moveresize, CWM_WIN, - {.i = (CWM_LEFT | CWM_RESIZE)} }, - { "bigresizeup", kbfunc_client_moveresize, CWM_WIN, - {.i = (CWM_UP | CWM_RESIZE | CWM_BIGMOVE)} }, - { "bigresizedown", kbfunc_client_moveresize, CWM_WIN, - {.i = (CWM_DOWN | CWM_RESIZE | CWM_BIGMOVE)} }, - { "bigresizeright", kbfunc_client_moveresize, CWM_WIN, - {.i = (CWM_RIGHT | CWM_RESIZE | CWM_BIGMOVE)} }, - { "bigresizeleft", kbfunc_client_moveresize, CWM_WIN, - {.i = (CWM_LEFT | CWM_RESIZE | CWM_BIGMOVE)} }, - { "ptrmoveup", kbfunc_client_moveresize, 0, - {.i = (CWM_UP | CWM_PTRMOVE)} }, - { "ptrmovedown", kbfunc_client_moveresize, 0, - {.i = (CWM_DOWN | CWM_PTRMOVE)} }, - { "ptrmoveleft", kbfunc_client_moveresize, 0, - {.i = (CWM_LEFT | CWM_PTRMOVE)} }, - { "ptrmoveright", kbfunc_client_moveresize, 0, - {.i = (CWM_RIGHT | CWM_PTRMOVE)} }, - { "bigptrmoveup", kbfunc_client_moveresize, 0, - {.i = (CWM_UP | CWM_PTRMOVE | CWM_BIGMOVE)} }, - { "bigptrmovedown", kbfunc_client_moveresize, 0, - {.i = (CWM_DOWN | CWM_PTRMOVE | CWM_BIGMOVE)} }, - { "bigptrmoveleft", kbfunc_client_moveresize, 0, - {.i = (CWM_LEFT | CWM_PTRMOVE | CWM_BIGMOVE)} }, - { "bigptrmoveright", kbfunc_client_moveresize, 0, - {.i = (CWM_RIGHT | CWM_PTRMOVE | CWM_BIGMOVE)} }, - { "htile", kbfunc_tile, CWM_WIN, {.i = CWM_TILE_HORIZ} }, - { "vtile", kbfunc_tile, CWM_WIN, {.i = CWM_TILE_VERT} }, - { "window_lower", kbfunc_client_lower, CWM_WIN, {0} }, - { "window_raise", kbfunc_client_raise, CWM_WIN, {0} }, - { "window_hide", kbfunc_client_hide, CWM_WIN, {0} }, - { "window_move", mousefunc_client_move, CWM_WIN, {0} }, - { "window_resize", mousefunc_client_resize, CWM_WIN, {0} }, - { "window_grouptoggle", kbfunc_client_grouptoggle, CWM_WIN, {.i = 1} }, - { "menu_group", mousefunc_menu_group, 0, {0} }, - { "menu_unhide", mousefunc_menu_unhide, 0, {0} }, - { "menu_cmd", mousefunc_menu_cmd, 0, {0} }, + { "lower", kbfunc_client_lower, CWM_CONTEXT_CLIENT, {0} }, + { "raise", kbfunc_client_raise, CWM_CONTEXT_CLIENT, {0} }, + { "search", kbfunc_menu_client, CWM_CONTEXT_SCREEN, {0} }, + { "menusearch", kbfunc_menu_cmd, CWM_CONTEXT_SCREEN, {0} }, + { "groupsearch", kbfunc_menu_group, CWM_CONTEXT_SCREEN, {0} }, + { "hide", kbfunc_client_hide, CWM_CONTEXT_CLIENT, {0} }, + { "cycle", kbfunc_client_cycle, CWM_CONTEXT_SCREEN, + {.i = CWM_CLIENT_CYCLE} }, + { "rcycle", kbfunc_client_cycle, CWM_CONTEXT_SCREEN, + {.i = CWM_CLIENT_RCYCLE} }, + { "label", kbfunc_client_label, CWM_CONTEXT_CLIENT, {0} }, + { "delete", kbfunc_client_delete, CWM_CONTEXT_CLIENT, {0} }, + { "group1", kbfunc_group_toggle, CWM_CONTEXT_SCREEN, {.i = 1} }, + { "group2", kbfunc_group_toggle, CWM_CONTEXT_SCREEN, {.i = 2} }, + { "group3", kbfunc_group_toggle, CWM_CONTEXT_SCREEN, {.i = 3} }, + { "group4", kbfunc_group_toggle, CWM_CONTEXT_SCREEN, {.i = 4} }, + { "group5", kbfunc_group_toggle, CWM_CONTEXT_SCREEN, {.i = 5} }, + { "group6", kbfunc_group_toggle, CWM_CONTEXT_SCREEN, {.i = 6} }, + { "group7", kbfunc_group_toggle, CWM_CONTEXT_SCREEN, {.i = 7} }, + { "group8", kbfunc_group_toggle, CWM_CONTEXT_SCREEN, {.i = 8} }, + { "group9", kbfunc_group_toggle, CWM_CONTEXT_SCREEN, {.i = 9} }, + { "grouponly1", kbfunc_group_only, CWM_CONTEXT_SCREEN, {.i = 1} }, + { "grouponly2", kbfunc_group_only, CWM_CONTEXT_SCREEN, {.i = 2} }, + { "grouponly3", kbfunc_group_only, CWM_CONTEXT_SCREEN, {.i = 3} }, + { "grouponly4", kbfunc_group_only, CWM_CONTEXT_SCREEN, {.i = 4} }, + { "grouponly5", kbfunc_group_only, CWM_CONTEXT_SCREEN, {.i = 5} }, + { "grouponly6", kbfunc_group_only, CWM_CONTEXT_SCREEN, {.i = 6} }, + { "grouponly7", kbfunc_group_only, CWM_CONTEXT_SCREEN, {.i = 7} }, + { "grouponly8", kbfunc_group_only, CWM_CONTEXT_SCREEN, {.i = 8} }, + { "grouponly9", kbfunc_group_only, CWM_CONTEXT_SCREEN, {.i = 9} }, + { "movetogroup1", kbfunc_client_movetogroup, CWM_CONTEXT_CLIENT, + {.i = 1} }, + { "movetogroup2", kbfunc_client_movetogroup, CWM_CONTEXT_CLIENT, + {.i = 2} }, + { "movetogroup3", kbfunc_client_movetogroup, CWM_CONTEXT_CLIENT, + {.i = 3} }, + { "movetogroup4", kbfunc_client_movetogroup, CWM_CONTEXT_CLIENT, + {.i = 4} }, + { "movetogroup5", kbfunc_client_movetogroup, CWM_CONTEXT_CLIENT, + {.i = 5} }, + { "movetogroup6", kbfunc_client_movetogroup, CWM_CONTEXT_CLIENT, + {.i = 6} }, + { "movetogroup7", kbfunc_client_movetogroup, CWM_CONTEXT_CLIENT, + {.i = 7} }, + { "movetogroup8", kbfunc_client_movetogroup, CWM_CONTEXT_CLIENT, + {.i = 8} }, + { "movetogroup9", kbfunc_client_movetogroup, CWM_CONTEXT_CLIENT, + {.i = 9} }, + { "nogroup", kbfunc_group_alltoggle, CWM_CONTEXT_SCREEN, {0} }, + { "cyclegroup", kbfunc_group_cycle, CWM_CONTEXT_SCREEN, + {.i = CWM_CLIENT_CYCLE} }, + { "rcyclegroup", kbfunc_group_cycle, CWM_CONTEXT_SCREEN, + {.i = CWM_CLIENT_RCYCLE} }, + { "cycleingroup", kbfunc_client_cycle, CWM_CONTEXT_CLIENT, + {.i = (CWM_CLIENT_CYCLE | CWM_CLIENT_CYCLE_INGRP)} }, + { "rcycleingroup", kbfunc_client_cycle, CWM_CONTEXT_CLIENT, + {.i = (CWM_CLIENT_RCYCLE | CWM_CLIENT_CYCLE_INGRP)} }, + { "grouptoggle", kbfunc_client_grouptoggle, CWM_CONTEXT_CLIENT, + {.i = CWM_KBD}}, + { "sticky", kbfunc_client_toggle_sticky, CWM_CONTEXT_CLIENT, {0} }, + { "fullscreen", kbfunc_client_toggle_fullscreen, CWM_CONTEXT_CLIENT, + {0} }, + { "maximize", kbfunc_client_toggle_maximize, CWM_CONTEXT_CLIENT, {0} }, + { "vmaximize", kbfunc_client_toggle_vmaximize, CWM_CONTEXT_CLIENT, + {0} }, + { "hmaximize", kbfunc_client_toggle_hmaximize, CWM_CONTEXT_CLIENT, + {0} }, + { "freeze", kbfunc_client_toggle_freeze, CWM_CONTEXT_CLIENT, {0} }, + { "restart", kbfunc_cwm_status, CWM_CONTEXT_SCREEN, + {.i = CWM_EXEC_WM} }, + { "quit", kbfunc_cwm_status, CWM_CONTEXT_SCREEN, {.i = CWM_QUIT} }, + { "exec", kbfunc_menu_exec, CWM_CONTEXT_SCREEN, {.i = CWM_MENU_EXEC} }, + { "exec_wm", kbfunc_menu_exec, CWM_CONTEXT_SCREEN, + {.i = CWM_MENU_EXEC_WM} }, + { "ssh", kbfunc_menu_ssh, CWM_CONTEXT_SCREEN, {0} }, + { "terminal", kbfunc_exec_term, CWM_CONTEXT_SCREEN, {0} }, + { "lock", kbfunc_exec_lock, CWM_CONTEXT_SCREEN, {0} }, + { "moveup", kbfunc_client_move, CWM_CONTEXT_CLIENT, + {.i = (CWM_UP)} }, + { "movedown", kbfunc_client_move, CWM_CONTEXT_CLIENT, + {.i = (CWM_DOWN)} }, + { "moveright", kbfunc_client_move, CWM_CONTEXT_CLIENT, + {.i = (CWM_RIGHT)} }, + { "moveleft", kbfunc_client_move, CWM_CONTEXT_CLIENT, + {.i = (CWM_LEFT)} }, + { "bigmoveup", kbfunc_client_move, CWM_CONTEXT_CLIENT, + {.i = (CWM_UP | CWM_BIGAMOUNT)} }, + { "bigmovedown", kbfunc_client_move, CWM_CONTEXT_CLIENT, + {.i = (CWM_DOWN | CWM_BIGAMOUNT)} }, + { "bigmoveright", kbfunc_client_move, CWM_CONTEXT_CLIENT, + {.i = (CWM_RIGHT | CWM_BIGAMOUNT)} }, + { "bigmoveleft", kbfunc_client_move, CWM_CONTEXT_CLIENT, + {.i = (CWM_LEFT | CWM_BIGAMOUNT)} }, + { "resizeup", kbfunc_client_resize, CWM_CONTEXT_CLIENT, + {.i = (CWM_UP)} }, + { "resizedown", kbfunc_client_resize, CWM_CONTEXT_CLIENT, + {.i = (CWM_DOWN)} }, + { "resizeright", kbfunc_client_resize, CWM_CONTEXT_CLIENT, + {.i = (CWM_RIGHT)} }, + { "resizeleft", kbfunc_client_resize, CWM_CONTEXT_CLIENT, + {.i = (CWM_LEFT)} }, + { "bigresizeup", kbfunc_client_resize, CWM_CONTEXT_CLIENT, + {.i = (CWM_UP | CWM_BIGAMOUNT)} }, + { "bigresizedown", kbfunc_client_resize, CWM_CONTEXT_CLIENT, + {.i = (CWM_DOWN | CWM_BIGAMOUNT)} }, + { "bigresizeright", kbfunc_client_resize, CWM_CONTEXT_CLIENT, + {.i = (CWM_RIGHT | CWM_BIGAMOUNT)} }, + { "bigresizeleft", kbfunc_client_resize, CWM_CONTEXT_CLIENT, + {.i = (CWM_LEFT | CWM_BIGAMOUNT)} }, + { "ptrmoveup", kbfunc_ptrmove, CWM_CONTEXT_SCREEN, + {.i = (CWM_UP)} }, + { "ptrmovedown", kbfunc_ptrmove, CWM_CONTEXT_SCREEN, + {.i = (CWM_DOWN)} }, + { "ptrmoveleft", kbfunc_ptrmove, CWM_CONTEXT_SCREEN, + {.i = (CWM_LEFT)} }, + { "ptrmoveright", kbfunc_ptrmove, CWM_CONTEXT_SCREEN, + {.i = (CWM_RIGHT)} }, + { "bigptrmoveup", kbfunc_ptrmove, CWM_CONTEXT_SCREEN, + {.i = (CWM_UP | CWM_BIGAMOUNT)} }, + { "bigptrmovedown", kbfunc_ptrmove, CWM_CONTEXT_SCREEN, + {.i = (CWM_DOWN | CWM_BIGAMOUNT)} }, + { "bigptrmoveleft", kbfunc_ptrmove, CWM_CONTEXT_SCREEN, + {.i = (CWM_LEFT | CWM_BIGAMOUNT)} }, + { "bigptrmoveright", kbfunc_ptrmove, CWM_CONTEXT_SCREEN, + {.i = (CWM_RIGHT | CWM_BIGAMOUNT)} }, + { "htile", kbfunc_client_tile, CWM_CONTEXT_CLIENT, + {.i = CWM_CLIENT_TILE_HORIZ} }, + { "vtile", kbfunc_client_tile, CWM_CONTEXT_CLIENT, + {.i = CWM_CLIENT_TILE_VERT} }, + { "window_lower", kbfunc_client_lower, CWM_CONTEXT_CLIENT, {0} }, + { "window_raise", kbfunc_client_raise, CWM_CONTEXT_CLIENT, {0} }, + { "window_hide", kbfunc_client_hide, CWM_CONTEXT_CLIENT, {0} }, + { "window_move", mousefunc_client_move, CWM_CONTEXT_CLIENT, {0} }, + { "window_resize", mousefunc_client_resize, CWM_CONTEXT_CLIENT, {0} }, + { "window_grouptoggle", kbfunc_group_toggle, CWM_CONTEXT_CLIENT, + {.i = CWM_MOUSE} }, + { "menu_group", mousefunc_menu_group, CWM_CONTEXT_SCREEN, {0} }, + { "menu_unhide", mousefunc_menu_client, CWM_CONTEXT_SCREEN, {0} }, + { "menu_cmd", mousefunc_menu_cmd, CWM_CONTEXT_SCREEN, {0} }, }; static const struct { @@ -527,14 +549,14 @@ conf_bind_kbd(struct conf *c, const char *bind, const char *cmd) continue; kb->callback = name_to_func[i].handler; - kb->flags = name_to_func[i].flags; + kb->context = name_to_func[i].context; kb->argument = name_to_func[i].argument; TAILQ_INSERT_TAIL(&c->keybindingq, kb, entry); return(1); } - kb->callback = kbfunc_cmdexec; - kb->flags = CWM_CMD; + kb->callback = kbfunc_exec; + kb->context = CWM_CONTEXT_NONE; kb->argument.c = xstrdup(cmd); TAILQ_INSERT_TAIL(&c->keybindingq, kb, entry); return(1); @@ -551,7 +573,7 @@ conf_unbind_kbd(struct conf *c, struct binding *unbind) if (key->press.keysym == unbind->press.keysym) { TAILQ_REMOVE(&c->keybindingq, key, entry); - if (key->flags & CWM_CMD) + if (key->context == CWM_CONTEXT_NONE) free(key->argument.c); free(key); } @@ -588,7 +610,7 @@ conf_bind_mouse(struct conf *c, const char *bind, const char *cmd) continue; mb->callback = name_to_func[i].handler; - mb->flags = name_to_func[i].flags; + mb->context = name_to_func[i].context; mb->argument = name_to_func[i].argument; TAILQ_INSERT_TAIL(&c->mousebindingq, mb, entry); return(1); @@ -638,7 +660,7 @@ conf_grab_mouse(Window win) xu_btn_ungrab(win); TAILQ_FOREACH(mb, &Conf.mousebindingq, entry) { - if (mb->flags & CWM_WIN) + if (mb->context == CWM_CONTEXT_CLIENT) xu_btn_grab(win, mb->modmask, mb->press.button); } } |