diff options
author | oga | 2009-01-23 18:58:40 +0000 |
---|---|---|
committer | oga | 2009-01-23 18:58:40 +0000 |
commit | f766a2baaec283eabcfa26f0c60e9a596b43459d (patch) | |
tree | af0bf5a5d5b494570033e062255fb8d34be055dc | |
parent | 4b2cd3a9e6fb79dc8497bc499aea252775e9029c (diff) | |
download | cwm-f766a2baaec283eabcfa26f0c60e9a596b43459d.tar.gz |
Move the keybinding argument to a union to prevent warnings where
sizeof(int) != sizeof(void *). This has been annoying me for ages.
ok okan@, todd@
Diffstat (limited to '')
-rw-r--r-- | calmwm.h | 64 | ||||
-rw-r--r-- | conf.c | 124 | ||||
-rw-r--r-- | kbfunc.c | 58 | ||||
-rw-r--r-- | xevents.c | 4 |
4 files changed, 130 insertions, 120 deletions
@@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: calmwm.h,v 1.78 2009/01/22 15:26:33 oga Exp $ + * $Id: calmwm.h,v 1.79 2009/01/23 18:58:40 oga Exp $ */ #ifndef _CALMWM_H_ @@ -205,14 +205,19 @@ TAILQ_HEAD(winmatch_q, winmatch); #define KBTOGROUP(X) ((X) - 1) +union arg { + char *c; + int i; +}; + struct keybinding { + TAILQ_ENTRY(keybinding) entry; + void (*callback)(struct client_ctx *, union arg *); + union arg argument; int modmask; int keysym; int keycode; int flags; - void (*callback)(struct client_ctx *, void *); - void *argument; - TAILQ_ENTRY(keybinding) entry; }; struct cmd { @@ -423,29 +428,34 @@ void conf_cmd_add(struct conf *, char *, char *, int); int parse_config(const char *, struct conf *); -void kbfunc_client_lower(struct client_ctx *, void *); -void kbfunc_client_raise(struct client_ctx *, void *); -void kbfunc_client_search(struct client_ctx *, void *); -void kbfunc_client_hide(struct client_ctx *, void *); -void kbfunc_client_cycle(struct client_ctx *, void *); -void kbfunc_client_rcycle(struct client_ctx *, void *); -void kbfunc_cmdexec(struct client_ctx *, void *); -void kbfunc_client_label(struct client_ctx *, void *); -void kbfunc_client_delete(struct client_ctx *, void *); -void kbfunc_client_group(struct client_ctx *, void *); -void kbfunc_client_cyclegroup(struct client_ctx *, void *); -void kbfunc_client_nogroup(struct client_ctx *, void *); -void kbfunc_client_grouptoggle(struct client_ctx *, void *); -void kbfunc_client_maximize(struct client_ctx *, void *); -void kbfunc_client_vmaximize(struct client_ctx *, void *); -void kbfunc_reload(struct client_ctx *, void *); -void kbfunc_quit_wm(struct client_ctx *, void *); -void kbfunc_moveresize(struct client_ctx *, void *); -void kbfunc_menu_search(struct client_ctx *, void *); -void kbfunc_exec(struct client_ctx *, void *); -void kbfunc_ssh(struct client_ctx *, void *); -void kbfunc_term(struct client_ctx *, void *); -void kbfunc_lock(struct client_ctx *, void *); +void kbfunc_client_lower(struct client_ctx *, union arg *); +void kbfunc_client_raise(struct client_ctx *, union arg *); +void kbfunc_client_search(struct client_ctx *, union arg *); +void kbfunc_client_hide(struct client_ctx *, union arg *); +void kbfunc_client_cycle(struct client_ctx *, union arg *); +void kbfunc_client_rcycle(struct client_ctx *, union arg *); +void kbfunc_cmdexec(struct client_ctx *, union arg *); +void kbfunc_client_label(struct client_ctx *, union arg *); +void kbfunc_client_delete(struct client_ctx *, union arg *); +void kbfunc_client_group(struct client_ctx *, union arg *); +void kbfunc_client_cyclegroup(struct client_ctx *, + union arg *); +void kbfunc_client_nogroup(struct client_ctx *, + union arg *); +void kbfunc_client_grouptoggle(struct client_ctx *, + union arg *); +void kbfunc_client_maximize(struct client_ctx *, + union arg *); +void kbfunc_client_vmaximize(struct client_ctx *, + union arg *); +void kbfunc_reload(struct client_ctx *, union arg *); +void kbfunc_quit_wm(struct client_ctx *, union arg *); +void kbfunc_moveresize(struct client_ctx *, union arg *); +void kbfunc_menu_search(struct client_ctx *, union arg *); +void kbfunc_exec(struct client_ctx *, union arg *); +void kbfunc_ssh(struct client_ctx *, union arg *); +void kbfunc_term(struct client_ctx *, union arg *); +void kbfunc_lock(struct client_ctx *, union arg *); void mousefunc_window_resize(struct client_ctx *, void *); void mousefunc_window_move(struct client_ctx *, void *); @@ -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. * - * $Id: conf.c,v 1.53 2009/01/21 15:04:38 todd Exp $ + * $Id: conf.c,v 1.54 2009/01/23 18:58:40 oga Exp $ */ #include "headers.h" @@ -207,88 +207,88 @@ conf_client(struct client_ctx *cc) } struct { - char *tag; - void (*handler)(struct client_ctx *, void *); - int flags; - void *argument; + char *tag; + void (*handler)(struct client_ctx *, union arg *); + int flags; + union arg argument; } name_to_kbfunc[] = { - { "lower", kbfunc_client_lower, KBFLAG_NEEDCLIENT, 0 }, - { "raise", kbfunc_client_raise, KBFLAG_NEEDCLIENT, 0 }, - { "search", kbfunc_client_search, 0, 0 }, - { "menusearch", kbfunc_menu_search, 0, 0 }, - { "hide", kbfunc_client_hide, KBFLAG_NEEDCLIENT, 0 }, - { "cycle", kbfunc_client_cycle, 0, (void *)CWM_CYCLE }, - { "rcycle", kbfunc_client_cycle, 0, (void *)CWM_RCYCLE }, - { "label", kbfunc_client_label, KBFLAG_NEEDCLIENT, 0 }, - { "delete", kbfunc_client_delete, KBFLAG_NEEDCLIENT, 0 }, - { "group1", kbfunc_client_group, 0, (void *)1 }, - { "group2", kbfunc_client_group, 0, (void *)2 }, - { "group3", kbfunc_client_group, 0, (void *)3 }, - { "group4", kbfunc_client_group, 0, (void *)4 }, - { "group5", kbfunc_client_group, 0, (void *)5 }, - { "group6", kbfunc_client_group, 0, (void *)6 }, - { "group7", kbfunc_client_group, 0, (void *)7 }, - { "group8", kbfunc_client_group, 0, (void *)8 }, - { "group9", kbfunc_client_group, 0, (void *)9 }, - { "nogroup", kbfunc_client_nogroup, 0, 0 }, - { "cyclegroup", kbfunc_client_cyclegroup, 0, (void *)CWM_CYCLEGROUP }, - { "rcyclegroup", kbfunc_client_cyclegroup, 0, (void *)CWM_RCYCLEGROUP }, - { "grouptoggle", kbfunc_client_grouptoggle, KBFLAG_NEEDCLIENT, 0}, - { "maximize", kbfunc_client_maximize, KBFLAG_NEEDCLIENT, 0 }, - { "vmaximize", kbfunc_client_vmaximize, KBFLAG_NEEDCLIENT, 0 }, - { "reload", kbfunc_reload, 0, 0 }, - { "quit", kbfunc_quit_wm, 0, 0 }, - { "exec", kbfunc_exec, 0, (void *)CWM_EXEC_PROGRAM }, - { "exec_wm", kbfunc_exec, 0, (void *)CWM_EXEC_WM }, - { "ssh", kbfunc_ssh, 0, 0 }, - { "terminal", kbfunc_term, 0, 0 }, - { "lock", kbfunc_lock, 0, 0 }, + { "lower", kbfunc_client_lower, KBFLAG_NEEDCLIENT, {0} }, + { "raise", kbfunc_client_raise, KBFLAG_NEEDCLIENT, {0} }, + { "search", kbfunc_client_search, 0, {0} }, + { "menusearch", kbfunc_menu_search, 0, {0} }, + { "hide", kbfunc_client_hide, KBFLAG_NEEDCLIENT, {0} }, + { "cycle", kbfunc_client_cycle, 0, {.i = CWM_CYCLE} }, + { "rcycle", kbfunc_client_cycle, 0, {.i = CWM_RCYCLE} }, + { "label", kbfunc_client_label, KBFLAG_NEEDCLIENT, {0} }, + { "delete", kbfunc_client_delete, KBFLAG_NEEDCLIENT, {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} }, + { "nogroup", kbfunc_client_nogroup, 0, {0} }, + { "cyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_CYCLEGROUP} }, + { "rcyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_RCYCLEGROUP} }, + { "grouptoggle", kbfunc_client_grouptoggle, KBFLAG_NEEDCLIENT, {0}}, + { "maximize", kbfunc_client_maximize, KBFLAG_NEEDCLIENT, {0} }, + { "vmaximize", kbfunc_client_vmaximize, KBFLAG_NEEDCLIENT, {0} }, + { "reload", kbfunc_reload, 0, {0} }, + { "quit", kbfunc_quit_wm, 0, {0} }, + { "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_moveresize, KBFLAG_NEEDCLIENT, - (void *)(CWM_UP|CWM_MOVE) }, + {.i = (CWM_UP|CWM_MOVE)} }, { "movedown", kbfunc_moveresize, KBFLAG_NEEDCLIENT, - (void *)(CWM_DOWN|CWM_MOVE) }, + {.i = (CWM_DOWN|CWM_MOVE)} }, { "moveright", kbfunc_moveresize, KBFLAG_NEEDCLIENT, - (void *)(CWM_RIGHT|CWM_MOVE) }, + {.i = (CWM_RIGHT|CWM_MOVE)} }, { "moveleft", kbfunc_moveresize, KBFLAG_NEEDCLIENT, - (void *)(CWM_LEFT|CWM_MOVE) }, + {.i = (CWM_LEFT|CWM_MOVE)} }, { "bigmoveup", kbfunc_moveresize, KBFLAG_NEEDCLIENT, - (void *)(CWM_UP|CWM_MOVE|CWM_BIGMOVE) }, + {.i = (CWM_UP|CWM_MOVE|CWM_BIGMOVE)} }, { "bigmovedown", kbfunc_moveresize, KBFLAG_NEEDCLIENT, - (void *)(CWM_DOWN|CWM_MOVE|CWM_BIGMOVE) }, + {.i = (CWM_DOWN|CWM_MOVE|CWM_BIGMOVE)} }, { "bigmoveright", kbfunc_moveresize, KBFLAG_NEEDCLIENT, - (void *)(CWM_RIGHT|CWM_MOVE|CWM_BIGMOVE) }, + {.i = (CWM_RIGHT|CWM_MOVE|CWM_BIGMOVE)} }, { "bigmoveleft", kbfunc_moveresize, KBFLAG_NEEDCLIENT, - (void *)(CWM_LEFT|CWM_MOVE|CWM_BIGMOVE) }, + {.i = (CWM_LEFT|CWM_MOVE|CWM_BIGMOVE)} }, { "resizeup", kbfunc_moveresize, KBFLAG_NEEDCLIENT, - (void *)(CWM_UP|CWM_RESIZE) }, + {.i = (CWM_UP|CWM_RESIZE)} }, { "resizedown", kbfunc_moveresize, KBFLAG_NEEDCLIENT, - (void *)(CWM_DOWN|CWM_RESIZE) }, + {.i = (CWM_DOWN|CWM_RESIZE)} }, { "resizeright", kbfunc_moveresize, KBFLAG_NEEDCLIENT, - (void *)(CWM_RIGHT|CWM_RESIZE) }, + {.i = (CWM_RIGHT|CWM_RESIZE)} }, { "resizeleft", kbfunc_moveresize, KBFLAG_NEEDCLIENT, - (void *)(CWM_LEFT|CWM_RESIZE) }, + {.i = (CWM_LEFT|CWM_RESIZE)} }, { "bigresizeup", kbfunc_moveresize, KBFLAG_NEEDCLIENT, - (void *)(CWM_UP|CWM_RESIZE|CWM_BIGMOVE) }, + {.i = (CWM_UP|CWM_RESIZE|CWM_BIGMOVE)} }, { "bigresizedown", kbfunc_moveresize, KBFLAG_NEEDCLIENT, - (void *)(CWM_DOWN|CWM_RESIZE|CWM_BIGMOVE) }, + {.i = (CWM_DOWN|CWM_RESIZE|CWM_BIGMOVE)} }, { "bigresizeright", kbfunc_moveresize, KBFLAG_NEEDCLIENT, - (void *)(CWM_RIGHT|CWM_RESIZE|CWM_BIGMOVE) }, + {.i = (CWM_RIGHT|CWM_RESIZE|CWM_BIGMOVE)} }, { "bigresizeleft", kbfunc_moveresize, KBFLAG_NEEDCLIENT, - (void *)(CWM_LEFT|CWM_RESIZE|CWM_BIGMOVE) }, - { "ptrmoveup", kbfunc_moveresize, 0, (void *)(CWM_UP|CWM_PTRMOVE) }, - { "ptrmovedown", kbfunc_moveresize, 0, (void *)(CWM_DOWN|CWM_PTRMOVE) }, - { "ptrmoveleft", kbfunc_moveresize, 0, (void *)(CWM_LEFT|CWM_PTRMOVE) }, + {.i = (CWM_LEFT|CWM_RESIZE|CWM_BIGMOVE)} }, + { "ptrmoveup", kbfunc_moveresize, 0, {.i = (CWM_UP|CWM_PTRMOVE)} }, + { "ptrmovedown", kbfunc_moveresize, 0, {.i = (CWM_DOWN|CWM_PTRMOVE)} }, + { "ptrmoveleft", kbfunc_moveresize, 0, {.i = (CWM_LEFT|CWM_PTRMOVE)} }, { "ptrmoveright", kbfunc_moveresize, 0, - (void *)(CWM_RIGHT|CWM_PTRMOVE) }, + {.i = (CWM_RIGHT|CWM_PTRMOVE)} }, { "bigptrmoveup", kbfunc_moveresize, 0, - (void *)(CWM_UP|CWM_PTRMOVE|CWM_BIGMOVE) }, + {.i = (CWM_UP|CWM_PTRMOVE|CWM_BIGMOVE)} }, { "bigptrmovedown", kbfunc_moveresize, 0, - (void *)(CWM_DOWN|CWM_PTRMOVE|CWM_BIGMOVE) }, + {.i = (CWM_DOWN|CWM_PTRMOVE|CWM_BIGMOVE)} }, { "bigptrmoveleft", kbfunc_moveresize, 0, - (void *)(CWM_LEFT|CWM_PTRMOVE|CWM_BIGMOVE) }, + {.i = (CWM_LEFT|CWM_PTRMOVE|CWM_BIGMOVE)} }, { "bigptrmoveright", kbfunc_moveresize, 0, - (void *)(CWM_RIGHT|CWM_PTRMOVE|CWM_BIGMOVE) }, - { NULL, NULL, 0, 0}, + {.i = (CWM_RIGHT|CWM_PTRMOVE|CWM_BIGMOVE)} }, + { NULL, NULL, 0, {0}}, }; /* @@ -388,7 +388,7 @@ conf_bindname(struct conf *c, char *name, char *binding) } current_binding->callback = kbfunc_cmdexec; - current_binding->argument = xstrdup(binding); + current_binding->argument.c = xstrdup(binding); current_binding->flags = 0; conf_grab(c, current_binding); TAILQ_INSERT_TAIL(&c->keybindingq, current_binding, entry); @@ -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. * - * $Id: kbfunc.c,v 1.33 2009/01/16 15:24:14 okan Exp $ + * $Id: kbfunc.c,v 1.34 2009/01/23 18:58:40 oga Exp $ */ #include <paths.h> @@ -30,13 +30,13 @@ extern int _xev_quit; void -kbfunc_client_lower(struct client_ctx *cc, void *arg) +kbfunc_client_lower(struct client_ctx *cc, union arg *arg) { client_lower(cc); } void -kbfunc_client_raise(struct client_ctx *cc, void *arg) +kbfunc_client_raise(struct client_ctx *cc, union arg *arg) { client_raise(cc); } @@ -44,7 +44,7 @@ kbfunc_client_raise(struct client_ctx *cc, void *arg) #define typemask (CWM_MOVE | CWM_RESIZE | CWM_PTRMOVE) #define movemask (CWM_UP | CWM_DOWN | CWM_LEFT | CWM_RIGHT) void -kbfunc_moveresize(struct client_ctx *cc, void *arg) +kbfunc_moveresize(struct client_ctx *cc, union arg *arg) { struct screen_ctx *sc; int x, y, flags, amt; @@ -53,7 +53,7 @@ kbfunc_moveresize(struct client_ctx *cc, void *arg) sc = screen_current(); mx = my = 0; - flags = (int)arg; + flags = arg->i; amt = MOVE_AMOUNT; if (flags & CWM_BIGMOVE) { @@ -125,7 +125,7 @@ kbfunc_moveresize(struct client_ctx *cc, void *arg) } void -kbfunc_client_search(struct client_ctx *scratch, void *arg) +kbfunc_client_search(struct client_ctx *scratch, union arg *arg) { struct client_ctx *cc, *old_cc; struct menu *mi; @@ -160,7 +160,7 @@ kbfunc_client_search(struct client_ctx *scratch, void *arg) } void -kbfunc_menu_search(struct client_ctx *scratch, void *arg) +kbfunc_menu_search(struct client_ctx *scratch, union arg *arg) { struct cmd *cmd; struct menu *mi; @@ -186,7 +186,7 @@ kbfunc_menu_search(struct client_ctx *scratch, void *arg) } void -kbfunc_client_cycle(struct client_ctx *scratch, void *arg) +kbfunc_client_cycle(struct client_ctx *scratch, union arg *arg) { struct screen_ctx *sc; @@ -196,35 +196,35 @@ kbfunc_client_cycle(struct client_ctx *scratch, void *arg) XGrabKeyboard(X_Dpy, sc->rootwin, True, GrabModeAsync, GrabModeAsync, CurrentTime); - client_cycle((int)arg); + client_cycle(arg->i); } void -kbfunc_client_hide(struct client_ctx *cc, void *arg) +kbfunc_client_hide(struct client_ctx *cc, union arg *arg) { client_hide(cc); } void -kbfunc_cmdexec(struct client_ctx *cc, void *arg) +kbfunc_cmdexec(struct client_ctx *cc, union arg *arg) { - u_spawn((char *)arg); + u_spawn(arg->c); } void -kbfunc_term(struct client_ctx *cc, void *arg) +kbfunc_term(struct client_ctx *cc, union arg *arg) { u_spawn(Conf.termpath); } void -kbfunc_lock(struct client_ctx *cc, void *arg) +kbfunc_lock(struct client_ctx *cc, union arg *arg) { u_spawn(Conf.lockpath); } void -kbfunc_exec(struct client_ctx *scratch, void *arg) +kbfunc_exec(struct client_ctx *scratch, union arg *arg) { #define NPATHS 256 char **ap, *paths[NPATHS], *path, *pathcpy, *label; @@ -238,7 +238,7 @@ kbfunc_exec(struct client_ctx *scratch, void *arg) struct menu_q menuq; struct stat sb; - int cmd = (int)arg; + int cmd = arg->i; switch (cmd) { case CWM_EXEC_PROGRAM: label = "exec"; @@ -338,7 +338,7 @@ kbfunc_exec(struct client_ctx *scratch, void *arg) } void -kbfunc_ssh(struct client_ctx *scratch, void *arg) +kbfunc_ssh(struct client_ctx *scratch, union arg *arg) { struct menu *mi; struct menu_q menuq; @@ -405,7 +405,7 @@ kbfunc_ssh(struct client_ctx *scratch, void *arg) } void -kbfunc_client_label(struct client_ctx *cc, void *arg) +kbfunc_client_label(struct client_ctx *cc, union arg *arg) { struct menu *mi; struct menu_q menuq; @@ -428,31 +428,31 @@ kbfunc_client_label(struct client_ctx *cc, void *arg) } void -kbfunc_client_delete(struct client_ctx *cc, void *arg) +kbfunc_client_delete(struct client_ctx *cc, union arg *arg) { client_send_delete(cc); } void -kbfunc_client_group(struct client_ctx *cc, void *arg) +kbfunc_client_group(struct client_ctx *cc, union arg *arg) { - group_hidetoggle(KBTOGROUP((int)arg)); + group_hidetoggle(KBTOGROUP(arg->i)); } void -kbfunc_client_cyclegroup(struct client_ctx *cc, void *arg) +kbfunc_client_cyclegroup(struct client_ctx *cc, union arg *arg) { - group_cycle((int)arg); + group_cycle(arg->i); } void -kbfunc_client_nogroup(struct client_ctx *cc, void *arg) +kbfunc_client_nogroup(struct client_ctx *cc, union arg *arg) { group_alltoggle(); } void -kbfunc_client_grouptoggle(struct client_ctx *cc, void *arg) +kbfunc_client_grouptoggle(struct client_ctx *cc, union arg *arg) { /* XXX for stupid X apps like xpdf and gvim */ XGrabKeyboard(X_Dpy, cc->win, True, @@ -462,25 +462,25 @@ kbfunc_client_grouptoggle(struct client_ctx *cc, void *arg) } void -kbfunc_client_maximize(struct client_ctx *cc, void *arg) +kbfunc_client_maximize(struct client_ctx *cc, union arg *arg) { client_maximize(cc); } void -kbfunc_client_vmaximize(struct client_ctx *cc, void *arg) +kbfunc_client_vmaximize(struct client_ctx *cc, union arg *arg) { client_vertmaximize(cc); } void -kbfunc_quit_wm(struct client_ctx *cc, void *arg) +kbfunc_quit_wm(struct client_ctx *cc, union arg *arg) { _xev_quit = 1; } void -kbfunc_reload(struct client_ctx *cc, void *arg) +kbfunc_reload(struct client_ctx *cc, union arg *arg) { conf_reload(&Conf); } @@ -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. * - * $Id: xevents.c,v 1.37 2009/01/22 19:01:56 okan Exp $ + * $Id: xevents.c,v 1.38 2009/01/23 18:58:40 oga Exp $ */ /* @@ -294,7 +294,7 @@ xev_handle_keypress(struct xevent *xev, XEvent *ee) if (kb->flags & KBFLAG_NEEDCLIENT) goto out; - (*kb->callback)(cc, kb->argument); + (*kb->callback)(cc, &kb->argument); out: xev_register(xev); |