diff options
-rw-r--r-- | calmwm.h | 110 | ||||
-rw-r--r-- | conf.c | 214 | ||||
-rw-r--r-- | kbfunc.c | 99 | ||||
-rw-r--r-- | mousefunc.c | 4 | ||||
-rw-r--r-- | xevents.c | 14 |
5 files changed, 219 insertions, 222 deletions
diff --git a/calmwm.h b/calmwm.h index 4106333..193c0b5 100644 --- a/calmwm.h +++ b/calmwm.h @@ -66,7 +66,6 @@ enum cwm_status { CWM_RUNNING, CWM_EXEC_WM }; - enum cursor_font { CF_NORMAL, CF_MOVE, @@ -156,7 +155,6 @@ struct client_ctx { #define CLIENT_FULLSCREEN 0x0800 #define CLIENT_STICKY 0x1000 #define CLIENT_ACTIVE 0x2000 - #define CLIENT_HIGHLIGHT (CLIENT_GROUP | CLIENT_UNGROUP) #define CLIENT_MAXFLAGS (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED) #define CLIENT_MAXIMIZED (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED) @@ -219,30 +217,29 @@ struct screen_ctx { }; TAILQ_HEAD(screen_q, screen_ctx); -enum xev { - CWM_XEV_KEY, - CWM_XEV_BTN -}; -union arg { - char *c; - int i; -}; -union press { - KeySym keysym; - unsigned int button; +struct cargs { + char *cmd; + int flag; + enum { + CWM_XEV_KEY, + CWM_XEV_BTN + } xev; }; enum context { - CWM_CONTEXT_NONE, + CWM_CONTEXT_NONE = 0, CWM_CONTEXT_CC, CWM_CONTEXT_SC }; struct bind_ctx { TAILQ_ENTRY(bind_ctx) entry; - void (*callback)(void *, union arg *, enum xev); - union arg argument; - unsigned int modmask; - union press press; + void (*callback)(void *, struct cargs *); + struct cargs *cargs; enum context context; + unsigned int modmask; + union { + KeySym keysym; + unsigned int button; + } press; }; TAILQ_HEAD(keybind_q, bind_ctx); TAILQ_HEAD(mousebind_q, bind_ctx); @@ -462,49 +459,42 @@ void screen_update_geometry(struct screen_ctx *); void screen_updatestackingorder(struct screen_ctx *); void screen_assert_clients_within(struct screen_ctx *); -void kbfunc_cwm_status(void *, union arg *, enum xev); -void kbfunc_ptrmove(void *, union arg *, enum xev); -void kbfunc_client_move(void *, union arg *, enum xev); -void kbfunc_client_resize(void *, union arg *, enum xev); -void kbfunc_client_delete(void *, union arg *, enum xev); -void kbfunc_client_lower(void *, union arg *, enum xev); -void kbfunc_client_raise(void *, union arg *, enum xev); -void kbfunc_client_hide(void *, union arg *, enum xev); -void kbfunc_client_toggle_freeze(void *, - union arg *, enum xev); -void kbfunc_client_toggle_sticky(void *, - union arg *, enum xev); +void kbfunc_cwm_status(void *, struct cargs *); +void kbfunc_ptrmove(void *, struct cargs *); +void kbfunc_client_move(void *, struct cargs *); +void kbfunc_client_resize(void *, struct cargs *); +void kbfunc_client_delete(void *, struct cargs *); +void kbfunc_client_lower(void *, struct cargs *); +void kbfunc_client_raise(void *, struct cargs *); +void kbfunc_client_hide(void *, struct cargs *); +void kbfunc_client_toggle_freeze(void *, struct cargs *); +void kbfunc_client_toggle_sticky(void *, struct cargs *); void kbfunc_client_toggle_fullscreen(void *, - union arg *, enum xev); -void kbfunc_client_toggle_maximize(void *, - union arg *, enum xev); -void kbfunc_client_toggle_hmaximize(void *, - union arg *, enum xev); -void kbfunc_client_toggle_vmaximize(void *, - union arg *, enum xev); -void kbfunc_client_htile(void *, union arg *, enum xev); -void kbfunc_client_vtile(void *, union arg *, enum xev); -void kbfunc_client_cycle(void *, union arg *, enum xev); -void kbfunc_client_toggle_group(void *, - union arg *, enum xev); -void kbfunc_client_movetogroup(void *, - union arg *, enum xev); -void kbfunc_group_toggle(void *, union arg *, enum xev); -void kbfunc_group_only(void *, union arg *, enum xev); -void kbfunc_group_cycle(void *, union arg *, enum xev); -void kbfunc_group_alltoggle(void *, union arg *, enum xev); -void kbfunc_menu_client(void *, union arg *, enum xev); -void kbfunc_menu_cmd(void *, union arg *, enum xev); -void kbfunc_menu_group(void *, union arg *, enum xev); -void kbfunc_menu_exec(void *, union arg *, enum xev); -void kbfunc_menu_ssh(void *, union arg *, enum xev); -void kbfunc_menu_client_label(void *, union arg *, enum xev); -void kbfunc_exec_cmd(void *, union arg *, enum xev); -void kbfunc_exec_lock(void *, union arg *, enum xev); -void kbfunc_exec_term(void *, union arg *, enum xev); - -void mousefunc_client_move(void *, union arg *, enum xev); -void mousefunc_client_resize(void *, union arg *, enum xev); + struct cargs *); +void kbfunc_client_toggle_maximize(void *, struct cargs *); +void kbfunc_client_toggle_hmaximize(void *, struct cargs *); +void kbfunc_client_toggle_vmaximize(void *, struct cargs *); +void kbfunc_client_htile(void *, struct cargs *); +void kbfunc_client_vtile(void *, struct cargs *); +void kbfunc_client_cycle(void *, struct cargs *); +void kbfunc_client_toggle_group(void *, struct cargs *); +void kbfunc_client_movetogroup(void *, struct cargs *); +void kbfunc_group_toggle(void *, struct cargs *); +void kbfunc_group_only(void *, struct cargs *); +void kbfunc_group_cycle(void *, struct cargs *); +void kbfunc_group_alltoggle(void *, struct cargs *); +void kbfunc_menu_client(void *, struct cargs *); +void kbfunc_menu_cmd(void *, struct cargs *); +void kbfunc_menu_group(void *, struct cargs *); +void kbfunc_menu_exec(void *, struct cargs *); +void kbfunc_menu_ssh(void *, struct cargs *); +void kbfunc_menu_client_label(void *, struct cargs *); +void kbfunc_exec_cmd(void *, struct cargs *); +void kbfunc_exec_lock(void *, struct cargs *); +void kbfunc_exec_term(void *, struct cargs *); + +void mousefunc_client_move(void *, struct cargs *); +void mousefunc_client_resize(void *, struct cargs *); void menu_windraw(struct screen_ctx *, Window, const char *, ...); diff --git a/conf.c b/conf.c index 16e1a54..ac89516 100644 --- a/conf.c +++ b/conf.c @@ -56,134 +56,134 @@ static const char *color_binds[] = { }; static const struct { const char *tag; - void (*handler)(void *, union arg *, enum xev); + void (*handler)(void *, struct cargs *); enum context context; - union arg argument; + int flag; } 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-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)} }, + (CWM_CYCLE_FORWARD) }, { "window-rcycle", kbfunc_client_cycle, CWM_CONTEXT_SC, - {.i = (CWM_CYCLE_REVERSE)} }, + (CWM_CYCLE_REVERSE) }, { "window-cycle-ingroup", kbfunc_client_cycle, CWM_CONTEXT_SC, - {.i = (CWM_CYCLE_FORWARD | CWM_CYCLE_INGROUP)} }, + (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} }, + (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, 1 }, + { "window-movetogroup-2", kbfunc_client_movetogroup, CWM_CONTEXT_CC, 2 }, + { "window-movetogroup-3", kbfunc_client_movetogroup, CWM_CONTEXT_CC, 3 }, + { "window-movetogroup-4", kbfunc_client_movetogroup, CWM_CONTEXT_CC, 4 }, + { "window-movetogroup-5", kbfunc_client_movetogroup, CWM_CONTEXT_CC, 5 }, + { "window-movetogroup-6", kbfunc_client_movetogroup, CWM_CONTEXT_CC, 6 }, + { "window-movetogroup-7", kbfunc_client_movetogroup, CWM_CONTEXT_CC, 7 }, + { "window-movetogroup-8", kbfunc_client_movetogroup, CWM_CONTEXT_CC, 8 }, + { "window-movetogroup-9", kbfunc_client_movetogroup, CWM_CONTEXT_CC, 9 }, + + { "window-move", mousefunc_client_move, CWM_CONTEXT_CC, 0 }, { "window-move-up", kbfunc_client_move, CWM_CONTEXT_CC, - {.i = (CWM_UP)} }, + (CWM_UP) }, { "window-move-down", kbfunc_client_move, CWM_CONTEXT_CC, - {.i = (CWM_DOWN)} }, + (CWM_DOWN) }, { "window-move-right", kbfunc_client_move, CWM_CONTEXT_CC, - {.i = (CWM_RIGHT)} }, + (CWM_RIGHT) }, { "window-move-left", kbfunc_client_move, CWM_CONTEXT_CC, - {.i = (CWM_LEFT)} }, + (CWM_LEFT) }, { "window-move-up-big", kbfunc_client_move, CWM_CONTEXT_CC, - {.i = (CWM_UP | CWM_BIGAMOUNT)} }, + (CWM_UP | CWM_BIGAMOUNT) }, { "window-move-down-big", kbfunc_client_move, CWM_CONTEXT_CC, - {.i = (CWM_DOWN | CWM_BIGAMOUNT)} }, + (CWM_DOWN | CWM_BIGAMOUNT) }, { "window-move-right-big", kbfunc_client_move, CWM_CONTEXT_CC, - {.i = (CWM_RIGHT | CWM_BIGAMOUNT)} }, + (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} }, + (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)} }, + (CWM_UP) }, { "window-resize-down", kbfunc_client_resize, CWM_CONTEXT_CC, - {.i = (CWM_DOWN)} }, + (CWM_DOWN) }, { "window-resize-right", kbfunc_client_resize, CWM_CONTEXT_CC, - {.i = (CWM_RIGHT)} }, + (CWM_RIGHT) }, { "window-resize-left", kbfunc_client_resize, CWM_CONTEXT_CC, - {.i = (CWM_LEFT)} }, + (CWM_LEFT) }, { "window-resize-up-big", kbfunc_client_resize, CWM_CONTEXT_CC, - {.i = (CWM_UP | CWM_BIGAMOUNT)} }, + (CWM_UP | CWM_BIGAMOUNT) }, { "window-resize-down-big", kbfunc_client_resize, CWM_CONTEXT_CC, - {.i = (CWM_DOWN | CWM_BIGAMOUNT)} }, + (CWM_DOWN | CWM_BIGAMOUNT) }, { "window-resize-right-big", kbfunc_client_resize, CWM_CONTEXT_CC, - {.i = (CWM_RIGHT | CWM_BIGAMOUNT)} }, + (CWM_RIGHT | CWM_BIGAMOUNT) }, { "window-resize-left-big", kbfunc_client_resize, CWM_CONTEXT_CC, - {.i = (CWM_LEFT | CWM_BIGAMOUNT)} }, + (CWM_LEFT | CWM_BIGAMOUNT) }, { "group-cycle", kbfunc_group_cycle, CWM_CONTEXT_SC, - {.i = (CWM_CYCLE_FORWARD)} }, + (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} }, + (CWM_CYCLE_REVERSE) }, + { "group-toggle-all", kbfunc_group_alltoggle, CWM_CONTEXT_SC, 0 }, + { "group-toggle-1", kbfunc_group_toggle, CWM_CONTEXT_SC, 1 }, + { "group-toggle-2", kbfunc_group_toggle, CWM_CONTEXT_SC, 2 }, + { "group-toggle-3", kbfunc_group_toggle, CWM_CONTEXT_SC, 3 }, + { "group-toggle-4", kbfunc_group_toggle, CWM_CONTEXT_SC, 4 }, + { "group-toggle-5", kbfunc_group_toggle, CWM_CONTEXT_SC, 5 }, + { "group-toggle-6", kbfunc_group_toggle, CWM_CONTEXT_SC, 6 }, + { "group-toggle-7", kbfunc_group_toggle, CWM_CONTEXT_SC, 7 }, + { "group-toggle-8", kbfunc_group_toggle, CWM_CONTEXT_SC, 8 }, + { "group-toggle-9", kbfunc_group_toggle, CWM_CONTEXT_SC, 9 }, + { "group-only-1", kbfunc_group_only, CWM_CONTEXT_SC, 1 }, + { "group-only-2", kbfunc_group_only, CWM_CONTEXT_SC, 2 }, + { "group-only-3", kbfunc_group_only, CWM_CONTEXT_SC, 3 }, + { "group-only-4", kbfunc_group_only, CWM_CONTEXT_SC, 4 }, + { "group-only-5", kbfunc_group_only, CWM_CONTEXT_SC, 5 }, + { "group-only-6", kbfunc_group_only, CWM_CONTEXT_SC, 6 }, + { "group-only-7", kbfunc_group_only, CWM_CONTEXT_SC, 7 }, + { "group-only-8", kbfunc_group_only, CWM_CONTEXT_SC, 8 }, + { "group-only-9", kbfunc_group_only, CWM_CONTEXT_SC, 9 }, { "pointer-move-up", kbfunc_ptrmove, CWM_CONTEXT_SC, - {.i = (CWM_UP)} }, + (CWM_UP) }, { "pointer-move-down", kbfunc_ptrmove, CWM_CONTEXT_SC, - {.i = (CWM_DOWN)} }, + (CWM_DOWN) }, { "pointer-move-left", kbfunc_ptrmove, CWM_CONTEXT_SC, - {.i = (CWM_LEFT)} }, + (CWM_LEFT) }, { "pointer-move-right", kbfunc_ptrmove, CWM_CONTEXT_SC, - {.i = (CWM_RIGHT)} }, + (CWM_RIGHT) }, { "pointer-move-up-big", kbfunc_ptrmove, CWM_CONTEXT_SC, - {.i = (CWM_UP | CWM_BIGAMOUNT)} }, + (CWM_UP | CWM_BIGAMOUNT) }, { "pointer-move-down-big", kbfunc_ptrmove, CWM_CONTEXT_SC, - {.i = (CWM_DOWN | CWM_BIGAMOUNT)} }, + (CWM_DOWN | CWM_BIGAMOUNT) }, { "pointer-move-left-big", kbfunc_ptrmove, CWM_CONTEXT_SC, - {.i = (CWM_LEFT | CWM_BIGAMOUNT)} }, + (CWM_LEFT | CWM_BIGAMOUNT) }, { "pointer-move-right-big", kbfunc_ptrmove, CWM_CONTEXT_SC, - {.i = (CWM_RIGHT | CWM_BIGAMOUNT)} }, + (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-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} }, + CWM_MENU_WINDOW_ALL }, { "menu-window-hidden", kbfunc_menu_client, CWM_CONTEXT_SC, - {.i = CWM_MENU_WINDOW_HIDDEN} }, + CWM_MENU_WINDOW_HIDDEN }, { "menu-exec", kbfunc_menu_exec, CWM_CONTEXT_SC, - {.i = CWM_MENU_EXEC_EXEC} }, + CWM_MENU_EXEC_EXEC }, { "menu-exec-wm", kbfunc_menu_exec, CWM_CONTEXT_SC, - {.i = CWM_MENU_EXEC_WM} }, + 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} }, + { "terminal", kbfunc_exec_term, CWM_CONTEXT_SC, 0 }, + { "lock", kbfunc_exec_lock, CWM_CONTEXT_SC, 0 }, + { "restart", kbfunc_cwm_status, CWM_CONTEXT_SC, CWM_EXEC_WM }, + { "quit", kbfunc_cwm_status, CWM_CONTEXT_SC, CWM_QUIT }, }; static unsigned int ignore_mods[] = { @@ -510,12 +510,13 @@ int conf_bind_key(struct conf *c, const char *bind, const char *cmd) { struct bind_ctx *kb; + struct cargs *cargs; const char *key; unsigned int i; if ((strcmp(bind, "all") == 0) && (cmd == NULL)) { conf_unbind_key(c, NULL); - goto out; + return(1); } kb = xmalloc(sizeof(*kb)); key = conf_bind_getmask(bind, &kb->modmask); @@ -528,22 +529,24 @@ conf_bind_key(struct conf *c, const char *bind, const char *cmd) conf_unbind_key(c, kb); if (cmd == NULL) { free(kb); - goto out; + return(1); } + cargs = xcalloc(1, sizeof(*cargs)); 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); + cargs->flag = name_to_func[i].flag; goto out; } kb->callback = kbfunc_exec_cmd; kb->context = CWM_CONTEXT_NONE; - kb->argument.c = xstrdup(cmd); - TAILQ_INSERT_TAIL(&c->keybindq, kb, entry); + cargs->flag = 0; + cargs->cmd = xstrdup(cmd); out: + kb->cargs = cargs; + TAILQ_INSERT_TAIL(&c->keybindq, kb, entry); return(1); } @@ -557,8 +560,8 @@ conf_unbind_key(struct conf *c, struct bind_ctx *unbind) ((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); + free(key->cargs->cmd); + free(key->cargs); free(key); } } @@ -568,12 +571,13 @@ int conf_bind_mouse(struct conf *c, const char *bind, const char *cmd) { struct bind_ctx *mb; + struct cargs *cargs; const char *button, *errstr; unsigned int i; if ((strcmp(bind, "all") == 0) && (cmd == NULL)) { conf_unbind_mouse(c, NULL); - goto out; + return(1); } mb = xmalloc(sizeof(*mb)); button = conf_bind_getmask(bind, &mb->modmask); @@ -586,22 +590,24 @@ conf_bind_mouse(struct conf *c, const char *bind, const char *cmd) conf_unbind_mouse(c, mb); if (cmd == NULL) { free(mb); - goto out; + return(1); } + cargs = xcalloc(1, sizeof(*cargs)); 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); + cargs->flag = name_to_func[i].flag; goto out; } mb->callback = kbfunc_exec_cmd; mb->context = CWM_CONTEXT_NONE; - mb->argument.c = xstrdup(cmd); - TAILQ_INSERT_TAIL(&c->mousebindq, mb, entry); + cargs->flag = 0; + cargs->cmd = xstrdup(cmd); out: + mb->cargs = cargs; + TAILQ_INSERT_TAIL(&c->mousebindq, mb, entry); return(1); } @@ -615,8 +621,8 @@ conf_unbind_mouse(struct conf *c, struct bind_ctx *unbind) ((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->cargs->cmd); + free(mb->cargs); free(mb); } } diff --git a/kbfunc.c b/kbfunc.c index d038e1d..f705b9d 100644 --- a/kbfunc.c +++ b/kbfunc.c @@ -41,9 +41,9 @@ extern sig_atomic_t cwm_status; static void kbfunc_amount(int, int, int *, int *); void -kbfunc_cwm_status(void *ctx, union arg *arg, enum xev xev) +kbfunc_cwm_status(void *ctx, struct cargs *cargs) { - cwm_status = arg->i; + cwm_status = cargs->flag; } static void @@ -71,20 +71,20 @@ kbfunc_amount(int flags, int amt, int *mx, int *my) } void -kbfunc_ptrmove(void *ctx, union arg *arg, enum xev xev) +kbfunc_ptrmove(void *ctx, struct cargs *cargs) { struct screen_ctx *sc = ctx; int x, y; int mx = 0, my = 0; - kbfunc_amount(arg->i, Conf.mamount, &mx, &my); + kbfunc_amount(cargs->flag, Conf.mamount, &mx, &my); xu_ptr_getpos(sc->rootwin, &x, &y); xu_ptr_setpos(sc->rootwin, x + mx, y + my); } void -kbfunc_client_move(void *ctx, union arg *arg, enum xev xev) +kbfunc_client_move(void *ctx, struct cargs *cargs) { struct client_ctx *cc = ctx; struct screen_ctx *sc = cc->sc; @@ -94,7 +94,7 @@ kbfunc_client_move(void *ctx, union arg *arg, enum xev xev) if (cc->flags & CLIENT_FREEZE) return; - kbfunc_amount(arg->i, Conf.mamount, &mx, &my); + kbfunc_amount(cargs->flag, Conf.mamount, &mx, &my); cc->geom.x += mx; if (cc->geom.x < -(cc->geom.w + cc->bwidth - 1)) @@ -122,7 +122,7 @@ kbfunc_client_move(void *ctx, union arg *arg, enum xev xev) } void -kbfunc_client_resize(void *ctx, union arg *arg, enum xev xev) +kbfunc_client_resize(void *ctx, struct cargs *cargs) { struct client_ctx *cc = ctx; int mx = 0, my = 0; @@ -134,7 +134,7 @@ kbfunc_client_resize(void *ctx, union arg *arg, enum xev xev) if (!(cc->hint.flags & PResizeInc)) amt = Conf.mamount; - kbfunc_amount(arg->i, amt, &mx, &my); + kbfunc_amount(cargs->flag, amt, &mx, &my); if ((cc->geom.w += mx * cc->hint.incw) < cc->hint.minw) cc->geom.w = cc->hint.minw; @@ -150,137 +150,136 @@ kbfunc_client_resize(void *ctx, union arg *arg, enum xev xev) } void -kbfunc_client_delete(void *ctx, union arg *arg, enum xev xev) +kbfunc_client_delete(void *ctx, struct cargs *cargs) { client_send_delete(ctx); } void -kbfunc_client_lower(void *ctx, union arg *arg, enum xev xev) +kbfunc_client_lower(void *ctx, struct cargs *cargs) { client_ptrsave(ctx); client_lower(ctx); } void -kbfunc_client_raise(void *ctx, union arg *arg, enum xev xev) +kbfunc_client_raise(void *ctx, struct cargs *cargs) { client_raise(ctx); } void -kbfunc_client_hide(void *ctx, union arg *arg, enum xev xev) +kbfunc_client_hide(void *ctx, struct cargs *cargs) { client_hide(ctx); } void -kbfunc_client_toggle_freeze(void *ctx, union arg *arg, enum xev xev) +kbfunc_client_toggle_freeze(void *ctx, struct cargs *cargs) { client_toggle_freeze(ctx); } void -kbfunc_client_toggle_sticky(void *ctx, union arg *arg, enum xev xev) +kbfunc_client_toggle_sticky(void *ctx, struct cargs *cargs) { client_toggle_sticky(ctx); } void -kbfunc_client_toggle_fullscreen(void *ctx, union arg *arg, enum xev xev) +kbfunc_client_toggle_fullscreen(void *ctx, struct cargs *cargs) { client_toggle_fullscreen(ctx); } void -kbfunc_client_toggle_maximize(void *ctx, union arg *arg, enum xev xev) +kbfunc_client_toggle_maximize(void *ctx, struct cargs *cargs) { client_toggle_maximize(ctx); } void -kbfunc_client_toggle_hmaximize(void *ctx, union arg *arg, enum xev xev) +kbfunc_client_toggle_hmaximize(void *ctx, struct cargs *cargs) { client_toggle_hmaximize(ctx); } void -kbfunc_client_toggle_vmaximize(void *ctx, union arg *arg, enum xev xev) +kbfunc_client_toggle_vmaximize(void *ctx, struct cargs *cargs) { client_toggle_vmaximize(ctx); } void -kbfunc_client_htile(void *ctx, union arg *arg, enum xev xev) +kbfunc_client_htile(void *ctx, struct cargs *cargs) { client_htile(ctx); } void -kbfunc_client_vtile(void *ctx, union arg *arg, enum xev xev) +kbfunc_client_vtile(void *ctx, struct cargs *cargs) { client_vtile(ctx); } void -kbfunc_client_cycle(void *ctx, union arg *arg, enum xev xev) +kbfunc_client_cycle(void *ctx, struct cargs *cargs) { - client_cycle(ctx, arg->i); + client_cycle(ctx, cargs->flag); } void -kbfunc_client_toggle_group(void *ctx, union arg *arg, enum xev xev) +kbfunc_client_toggle_group(void *ctx, struct cargs *cargs) { struct client_ctx *cc = ctx; - if (xev == CWM_XEV_KEY) { - /* For X apps that steal events. */ + /* For X apps that steal events. */ + if (cargs->xev == CWM_XEV_KEY) XGrabKeyboard(X_Dpy, cc->win, True, GrabModeAsync, GrabModeAsync, CurrentTime); - } group_toggle_membership_enter(cc); } void -kbfunc_client_movetogroup(void *ctx, union arg *arg, enum xev xev) +kbfunc_client_movetogroup(void *ctx, struct cargs *cargs) { - group_movetogroup(ctx, arg->i); + group_movetogroup(ctx, cargs->flag); } void -kbfunc_group_toggle(void *ctx, union arg *arg, enum xev xev) +kbfunc_group_toggle(void *ctx, struct cargs *cargs) { - group_hidetoggle(ctx, arg->i); + group_hidetoggle(ctx, cargs->flag); } void -kbfunc_group_only(void *ctx, union arg *arg, enum xev xev) +kbfunc_group_only(void *ctx, struct cargs *cargs) { - group_only(ctx, arg->i); + group_only(ctx, cargs->flag); } void -kbfunc_group_cycle(void *ctx, union arg *arg, enum xev xev) +kbfunc_group_cycle(void *ctx, struct cargs *cargs) { - group_cycle(ctx, arg->i); + group_cycle(ctx, cargs->flag); } void -kbfunc_group_alltoggle(void *ctx, union arg *arg, enum xev xev) +kbfunc_group_alltoggle(void *ctx, struct cargs *cargs) { group_alltoggle(ctx); } void -kbfunc_menu_client(void *ctx, union arg *arg, enum xev xev) +kbfunc_menu_client(void *ctx, struct cargs *cargs) { struct screen_ctx *sc = ctx; struct client_ctx *cc, *old_cc; struct menu *mi; struct menu_q menuq; - int m = (xev == CWM_XEV_BTN); - int all = (arg->i & CWM_MENU_WINDOW_ALL); + int m = (cargs->xev == CWM_XEV_BTN); + int all = (cargs->flag & CWM_MENU_WINDOW_ALL); old_cc = client_current(); @@ -311,13 +310,13 @@ kbfunc_menu_client(void *ctx, union arg *arg, enum xev xev) } void -kbfunc_menu_cmd(void *ctx, union arg *arg, enum xev xev) +kbfunc_menu_cmd(void *ctx, struct cargs *cargs) { struct screen_ctx *sc = ctx; struct cmd_ctx *cmd; struct menu *mi; struct menu_q menuq; - int m = (xev == CWM_XEV_BTN); + int m = (cargs->xev == CWM_XEV_BTN); TAILQ_INIT(&menuq); TAILQ_FOREACH(cmd, &Conf.cmdq, entry) { @@ -340,13 +339,13 @@ kbfunc_menu_cmd(void *ctx, union arg *arg, enum xev xev) } void -kbfunc_menu_group(void *ctx, union arg *arg, enum xev xev) +kbfunc_menu_group(void *ctx, struct cargs *cargs) { struct screen_ctx *sc = ctx; struct group_ctx *gc; struct menu *mi; struct menu_q menuq; - int m = (xev == CWM_XEV_BTN); + int m = (cargs->xev == CWM_XEV_BTN); TAILQ_INIT(&menuq); TAILQ_FOREACH(gc, &sc->groupq, entry) { @@ -367,7 +366,7 @@ kbfunc_menu_group(void *ctx, union arg *arg, enum xev xev) } void -kbfunc_menu_exec(void *ctx, union arg *arg, enum xev xev) +kbfunc_menu_exec(void *ctx, struct cargs *cargs) { #define NPATHS 256 struct screen_ctx *sc = ctx; @@ -379,7 +378,7 @@ kbfunc_menu_exec(void *ctx, union arg *arg, enum xev xev) struct dirent *dp; struct menu *mi; struct menu_q menuq; - int l, i, cmd = arg->i; + int l, i, cmd = cargs->flag; switch (cmd) { case CWM_MENU_EXEC_EXEC: @@ -457,7 +456,7 @@ out: } void -kbfunc_menu_ssh(void *ctx, union arg *arg, enum xev xev) +kbfunc_menu_ssh(void *ctx, struct cargs *cargs) { struct screen_ctx *sc = ctx; struct cmd_ctx *cmd; @@ -524,7 +523,7 @@ out: } void -kbfunc_menu_client_label(void *ctx, union arg *arg, enum xev xev) +kbfunc_menu_client_label(void *ctx, struct cargs *cargs) { struct client_ctx *cc = ctx; struct menu *mi; @@ -544,13 +543,13 @@ kbfunc_menu_client_label(void *ctx, union arg *arg, enum xev xev) } void -kbfunc_exec_cmd(void *ctx, union arg *arg, enum xev xev) +kbfunc_exec_cmd(void *ctx, struct cargs *cargs) { - u_spawn(arg->c); + u_spawn(cargs->cmd); } void -kbfunc_exec_term(void *ctx, union arg *arg, enum xev xev) +kbfunc_exec_term(void *ctx, struct cargs *cargs) { struct cmd_ctx *cmd; @@ -561,7 +560,7 @@ kbfunc_exec_term(void *ctx, union arg *arg, enum xev xev) } void -kbfunc_exec_lock(void *ctx, union arg *arg, enum xev xev) +kbfunc_exec_lock(void *ctx, struct cargs *cargs) { struct cmd_ctx *cmd; diff --git a/mousefunc.c b/mousefunc.c index fa671cc..494f52d 100644 --- a/mousefunc.c +++ b/mousefunc.c @@ -33,7 +33,7 @@ #include "calmwm.h" void -mousefunc_client_resize(void *ctx, union arg *arg, enum xev xev) +mousefunc_client_resize(void *ctx, struct cargs *cargs) { struct client_ctx *cc = ctx; XEvent ev; @@ -87,7 +87,7 @@ mousefunc_client_resize(void *ctx, union arg *arg, enum xev xev) } void -mousefunc_client_move(void *ctx, union arg *arg, enum xev xev) +mousefunc_client_move(void *ctx, struct cargs *cargs) { struct client_ctx *cc = ctx; XEvent ev; diff --git a/xevents.c b/xevents.c index 946ea98..cc3515a 100644 --- a/xevents.c +++ b/xevents.c @@ -233,22 +233,23 @@ xev_handle_buttonpress(XEvent *ee) if (mb == NULL) return; + mb->cargs->xev = CWM_XEV_BTN; switch (mb->context) { case CWM_CONTEXT_CC: if (((cc = client_find(e->window)) == NULL) && (cc = client_current()) == NULL) return; - (*mb->callback)(cc, &mb->argument, CWM_XEV_BTN); + (*mb->callback)(cc, mb->cargs); break; case CWM_CONTEXT_SC: if (e->window != e->root) return; if ((sc = screen_find(e->window)) == NULL) return; - (*mb->callback)(sc, &mb->argument, CWM_XEV_BTN); + (*mb->callback)(sc, mb->cargs); break; case CWM_CONTEXT_NONE: - (*mb->callback)(NULL, &mb->argument, CWM_XEV_BTN); + (*mb->callback)(NULL, mb->cargs); break; } } @@ -295,20 +296,21 @@ xev_handle_keypress(XEvent *ee) if (kb == NULL) return; + kb->cargs->xev = CWM_XEV_KEY; switch (kb->context) { case CWM_CONTEXT_CC: if (((cc = client_find(e->window)) == NULL) && (cc = client_current()) == NULL) return; - (*kb->callback)(cc, &kb->argument, CWM_XEV_KEY); + (*kb->callback)(cc, kb->cargs); break; case CWM_CONTEXT_SC: if ((sc = screen_find(e->window)) == NULL) return; - (*kb->callback)(sc, &kb->argument, CWM_XEV_KEY); + (*kb->callback)(sc, kb->cargs); break; case CWM_CONTEXT_NONE: - (*kb->callback)(NULL, &kb->argument, CWM_XEV_KEY); + (*kb->callback)(NULL, kb->cargs); break; } } |