summaryrefslogtreecommitdiff
path: root/app/cwm/conf.c
diff options
context:
space:
mode:
authorOkan Demirmen <okan@cvs.openbsd.org>2015-11-10 20:05:34 +0000
committerOkan Demirmen <okan@cvs.openbsd.org>2015-11-10 20:05:34 +0000
commit02add558861e61335f362c7d8c94913584335225 (patch)
tree18a5c6508655b92feeba5fcc0967fdc89310101f /app/cwm/conf.c
parente17e0a72afcfeee5c188c25d1ab1c8f7770cdb49 (diff)
Start cleaning up name vs function differences; replace magic numbers.
Diffstat (limited to 'app/cwm/conf.c')
-rw-r--r--app/cwm/conf.c224
1 files changed, 123 insertions, 101 deletions
diff --git a/app/cwm/conf.c b/app/cwm/conf.c
index 7d5bfab79..92f775bac 100644
--- a/app/cwm/conf.c
+++ b/app/cwm/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.198 2015/09/16 17:58:25 okan Exp $
+ * $OpenBSD: conf.c,v 1.199 2015/11/10 20:05:33 okan Exp $
*/
#include <sys/types.h>
@@ -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,
+ { "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_client_group, CWM_CONTEXT_SCREEN, {.i = 1} },
+ { "group2", kbfunc_client_group, CWM_CONTEXT_SCREEN, {.i = 2} },
+ { "group3", kbfunc_client_group, CWM_CONTEXT_SCREEN, {.i = 3} },
+ { "group4", kbfunc_client_group, CWM_CONTEXT_SCREEN, {.i = 4} },
+ { "group5", kbfunc_client_group, CWM_CONTEXT_SCREEN, {.i = 5} },
+ { "group6", kbfunc_client_group, CWM_CONTEXT_SCREEN, {.i = 6} },
+ { "group7", kbfunc_client_group, CWM_CONTEXT_SCREEN, {.i = 7} },
+ { "group8", kbfunc_client_group, CWM_CONTEXT_SCREEN, {.i = 8} },
+ { "group9", kbfunc_client_group, CWM_CONTEXT_SCREEN, {.i = 9} },
+ { "grouponly1", kbfunc_client_grouponly, CWM_CONTEXT_SCREEN, {.i = 1} },
+ { "grouponly2", kbfunc_client_grouponly, CWM_CONTEXT_SCREEN, {.i = 2} },
+ { "grouponly3", kbfunc_client_grouponly, CWM_CONTEXT_SCREEN, {.i = 3} },
+ { "grouponly4", kbfunc_client_grouponly, CWM_CONTEXT_SCREEN, {.i = 4} },
+ { "grouponly5", kbfunc_client_grouponly, CWM_CONTEXT_SCREEN, {.i = 5} },
+ { "grouponly6", kbfunc_client_grouponly, CWM_CONTEXT_SCREEN, {.i = 6} },
+ { "grouponly7", kbfunc_client_grouponly, CWM_CONTEXT_SCREEN, {.i = 7} },
+ { "grouponly8", kbfunc_client_grouponly, CWM_CONTEXT_SCREEN, {.i = 8} },
+ { "grouponly9", kbfunc_client_grouponly, 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_client_nogroup, CWM_CONTEXT_SCREEN, {0} },
+ { "cyclegroup", kbfunc_client_cyclegroup, CWM_CONTEXT_SCREEN,
+ {.i = CWM_CLIENT_CYCLE} },
+ { "rcyclegroup", kbfunc_client_cyclegroup, 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_moveresize, CWM_CONTEXT_CLIENT,
{.i = (CWM_UP | CWM_MOVE)} },
- { "movedown", kbfunc_client_moveresize, CWM_WIN,
+ { "movedown", kbfunc_client_moveresize, CWM_CONTEXT_CLIENT,
{.i = (CWM_DOWN | CWM_MOVE)} },
- { "moveright", kbfunc_client_moveresize, CWM_WIN,
+ { "moveright", kbfunc_client_moveresize, CWM_CONTEXT_CLIENT,
{.i = (CWM_RIGHT | CWM_MOVE)} },
- { "moveleft", kbfunc_client_moveresize, CWM_WIN,
+ { "moveleft", kbfunc_client_moveresize, CWM_CONTEXT_CLIENT,
{.i = (CWM_LEFT | CWM_MOVE)} },
- { "bigmoveup", kbfunc_client_moveresize, CWM_WIN,
+ { "bigmoveup", kbfunc_client_moveresize, CWM_CONTEXT_CLIENT,
{.i = (CWM_UP | CWM_MOVE | CWM_BIGMOVE)} },
- { "bigmovedown", kbfunc_client_moveresize, CWM_WIN,
+ { "bigmovedown", kbfunc_client_moveresize, CWM_CONTEXT_CLIENT,
{.i = (CWM_DOWN | CWM_MOVE | CWM_BIGMOVE)} },
- { "bigmoveright", kbfunc_client_moveresize, CWM_WIN,
+ { "bigmoveright", kbfunc_client_moveresize, CWM_CONTEXT_CLIENT,
{.i = (CWM_RIGHT | CWM_MOVE | CWM_BIGMOVE)} },
- { "bigmoveleft", kbfunc_client_moveresize, CWM_WIN,
+ { "bigmoveleft", kbfunc_client_moveresize, CWM_CONTEXT_CLIENT,
{.i = (CWM_LEFT | CWM_MOVE | CWM_BIGMOVE)} },
- { "resizeup", kbfunc_client_moveresize, CWM_WIN,
+ { "resizeup", kbfunc_client_moveresize, CWM_CONTEXT_CLIENT,
{.i = (CWM_UP | CWM_RESIZE)} },
- { "resizedown", kbfunc_client_moveresize, CWM_WIN,
+ { "resizedown", kbfunc_client_moveresize, CWM_CONTEXT_CLIENT,
{.i = (CWM_DOWN | CWM_RESIZE)} },
- { "resizeright", kbfunc_client_moveresize, CWM_WIN,
+ { "resizeright", kbfunc_client_moveresize, CWM_CONTEXT_CLIENT,
{.i = (CWM_RIGHT | CWM_RESIZE)} },
- { "resizeleft", kbfunc_client_moveresize, CWM_WIN,
+ { "resizeleft", kbfunc_client_moveresize, CWM_CONTEXT_CLIENT,
{.i = (CWM_LEFT | CWM_RESIZE)} },
- { "bigresizeup", kbfunc_client_moveresize, CWM_WIN,
+ { "bigresizeup", kbfunc_client_moveresize, CWM_CONTEXT_CLIENT,
{.i = (CWM_UP | CWM_RESIZE | CWM_BIGMOVE)} },
- { "bigresizedown", kbfunc_client_moveresize, CWM_WIN,
+ { "bigresizedown", kbfunc_client_moveresize, CWM_CONTEXT_CLIENT,
{.i = (CWM_DOWN | CWM_RESIZE | CWM_BIGMOVE)} },
- { "bigresizeright", kbfunc_client_moveresize, CWM_WIN,
+ { "bigresizeright", kbfunc_client_moveresize, CWM_CONTEXT_CLIENT,
{.i = (CWM_RIGHT | CWM_RESIZE | CWM_BIGMOVE)} },
- { "bigresizeleft", kbfunc_client_moveresize, CWM_WIN,
+ { "bigresizeleft", kbfunc_client_moveresize, CWM_CONTEXT_CLIENT,
{.i = (CWM_LEFT | CWM_RESIZE | CWM_BIGMOVE)} },
- { "ptrmoveup", kbfunc_client_moveresize, 0,
+ { "ptrmoveup", kbfunc_client_moveresize, CWM_CONTEXT_SCREEN,
{.i = (CWM_UP | CWM_PTRMOVE)} },
- { "ptrmovedown", kbfunc_client_moveresize, 0,
+ { "ptrmovedown", kbfunc_client_moveresize, CWM_CONTEXT_SCREEN,
{.i = (CWM_DOWN | CWM_PTRMOVE)} },
- { "ptrmoveleft", kbfunc_client_moveresize, 0,
+ { "ptrmoveleft", kbfunc_client_moveresize, CWM_CONTEXT_SCREEN,
{.i = (CWM_LEFT | CWM_PTRMOVE)} },
- { "ptrmoveright", kbfunc_client_moveresize, 0,
+ { "ptrmoveright", kbfunc_client_moveresize, CWM_CONTEXT_SCREEN,
{.i = (CWM_RIGHT | CWM_PTRMOVE)} },
- { "bigptrmoveup", kbfunc_client_moveresize, 0,
+ { "bigptrmoveup", kbfunc_client_moveresize, CWM_CONTEXT_SCREEN,
{.i = (CWM_UP | CWM_PTRMOVE | CWM_BIGMOVE)} },
- { "bigptrmovedown", kbfunc_client_moveresize, 0,
+ { "bigptrmovedown", kbfunc_client_moveresize, CWM_CONTEXT_SCREEN,
{.i = (CWM_DOWN | CWM_PTRMOVE | CWM_BIGMOVE)} },
- { "bigptrmoveleft", kbfunc_client_moveresize, 0,
+ { "bigptrmoveleft", kbfunc_client_moveresize, CWM_CONTEXT_SCREEN,
{.i = (CWM_LEFT | CWM_PTRMOVE | CWM_BIGMOVE)} },
- { "bigptrmoveright", kbfunc_client_moveresize, 0,
+ { "bigptrmoveright", kbfunc_client_moveresize, CWM_CONTEXT_SCREEN,
{.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} },
+ { "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_client_grouptoggle, 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);
}
}