Alter callbacks to take a struct instead of a growing number of arguments;

greatly simplifies upcoming work.
This commit is contained in:
okan 2017-05-09 13:40:18 +00:00
parent 189a735eaa
commit 113ffcf47e
5 changed files with 217 additions and 220 deletions

108
calmwm.h
View File

@ -66,7 +66,6 @@ enum cwm_status {
CWM_RUNNING, CWM_RUNNING,
CWM_EXEC_WM CWM_EXEC_WM
}; };
enum cursor_font { enum cursor_font {
CF_NORMAL, CF_NORMAL,
CF_MOVE, CF_MOVE,
@ -156,7 +155,6 @@ struct client_ctx {
#define CLIENT_FULLSCREEN 0x0800 #define CLIENT_FULLSCREEN 0x0800
#define CLIENT_STICKY 0x1000 #define CLIENT_STICKY 0x1000
#define CLIENT_ACTIVE 0x2000 #define CLIENT_ACTIVE 0x2000
#define CLIENT_HIGHLIGHT (CLIENT_GROUP | CLIENT_UNGROUP) #define CLIENT_HIGHLIGHT (CLIENT_GROUP | CLIENT_UNGROUP)
#define CLIENT_MAXFLAGS (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED) #define CLIENT_MAXFLAGS (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED)
#define CLIENT_MAXIMIZED (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED) #define CLIENT_MAXIMIZED (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED)
@ -219,30 +217,29 @@ struct screen_ctx {
}; };
TAILQ_HEAD(screen_q, screen_ctx); TAILQ_HEAD(screen_q, screen_ctx);
enum xev { struct cargs {
CWM_XEV_KEY, char *cmd;
CWM_XEV_BTN int flag;
}; enum {
union arg { CWM_XEV_KEY,
char *c; CWM_XEV_BTN
int i; } xev;
};
union press {
KeySym keysym;
unsigned int button;
}; };
enum context { enum context {
CWM_CONTEXT_NONE, CWM_CONTEXT_NONE = 0,
CWM_CONTEXT_CC, CWM_CONTEXT_CC,
CWM_CONTEXT_SC CWM_CONTEXT_SC
}; };
struct bind_ctx { struct bind_ctx {
TAILQ_ENTRY(bind_ctx) entry; TAILQ_ENTRY(bind_ctx) entry;
void (*callback)(void *, union arg *, enum xev); void (*callback)(void *, struct cargs *);
union arg argument; struct cargs *cargs;
unsigned int modmask;
union press press;
enum context context; enum context context;
unsigned int modmask;
union {
KeySym keysym;
unsigned int button;
} press;
}; };
TAILQ_HEAD(keybind_q, bind_ctx); TAILQ_HEAD(keybind_q, bind_ctx);
TAILQ_HEAD(mousebind_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_updatestackingorder(struct screen_ctx *);
void screen_assert_clients_within(struct screen_ctx *); void screen_assert_clients_within(struct screen_ctx *);
void kbfunc_cwm_status(void *, union arg *, enum xev); void kbfunc_cwm_status(void *, struct cargs *);
void kbfunc_ptrmove(void *, union arg *, enum xev); void kbfunc_ptrmove(void *, struct cargs *);
void kbfunc_client_move(void *, union arg *, enum xev); void kbfunc_client_move(void *, struct cargs *);
void kbfunc_client_resize(void *, union arg *, enum xev); void kbfunc_client_resize(void *, struct cargs *);
void kbfunc_client_delete(void *, union arg *, enum xev); void kbfunc_client_delete(void *, struct cargs *);
void kbfunc_client_lower(void *, union arg *, enum xev); void kbfunc_client_lower(void *, struct cargs *);
void kbfunc_client_raise(void *, union arg *, enum xev); void kbfunc_client_raise(void *, struct cargs *);
void kbfunc_client_hide(void *, union arg *, enum xev); void kbfunc_client_hide(void *, struct cargs *);
void kbfunc_client_toggle_freeze(void *, void kbfunc_client_toggle_freeze(void *, struct cargs *);
union arg *, enum xev); void kbfunc_client_toggle_sticky(void *, struct cargs *);
void kbfunc_client_toggle_sticky(void *,
union arg *, enum xev);
void kbfunc_client_toggle_fullscreen(void *, void kbfunc_client_toggle_fullscreen(void *,
union arg *, enum xev); struct cargs *);
void kbfunc_client_toggle_maximize(void *, void kbfunc_client_toggle_maximize(void *, struct cargs *);
union arg *, enum xev); void kbfunc_client_toggle_hmaximize(void *, struct cargs *);
void kbfunc_client_toggle_hmaximize(void *, void kbfunc_client_toggle_vmaximize(void *, struct cargs *);
union arg *, enum xev); void kbfunc_client_htile(void *, struct cargs *);
void kbfunc_client_toggle_vmaximize(void *, void kbfunc_client_vtile(void *, struct cargs *);
union arg *, enum xev); void kbfunc_client_cycle(void *, struct cargs *);
void kbfunc_client_htile(void *, union arg *, enum xev); void kbfunc_client_toggle_group(void *, struct cargs *);
void kbfunc_client_vtile(void *, union arg *, enum xev); void kbfunc_client_movetogroup(void *, struct cargs *);
void kbfunc_client_cycle(void *, union arg *, enum xev); void kbfunc_group_toggle(void *, struct cargs *);
void kbfunc_client_toggle_group(void *, void kbfunc_group_only(void *, struct cargs *);
union arg *, enum xev); void kbfunc_group_cycle(void *, struct cargs *);
void kbfunc_client_movetogroup(void *, void kbfunc_group_alltoggle(void *, struct cargs *);
union arg *, enum xev); void kbfunc_menu_client(void *, struct cargs *);
void kbfunc_group_toggle(void *, union arg *, enum xev); void kbfunc_menu_cmd(void *, struct cargs *);
void kbfunc_group_only(void *, union arg *, enum xev); void kbfunc_menu_group(void *, struct cargs *);
void kbfunc_group_cycle(void *, union arg *, enum xev); void kbfunc_menu_exec(void *, struct cargs *);
void kbfunc_group_alltoggle(void *, union arg *, enum xev); void kbfunc_menu_ssh(void *, struct cargs *);
void kbfunc_menu_client(void *, union arg *, enum xev); void kbfunc_menu_client_label(void *, struct cargs *);
void kbfunc_menu_cmd(void *, union arg *, enum xev); void kbfunc_exec_cmd(void *, struct cargs *);
void kbfunc_menu_group(void *, union arg *, enum xev); void kbfunc_exec_lock(void *, struct cargs *);
void kbfunc_menu_exec(void *, union arg *, enum xev); void kbfunc_exec_term(void *, struct cargs *);
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_move(void *, struct cargs *);
void mousefunc_client_resize(void *, union arg *, enum xev); void mousefunc_client_resize(void *, struct cargs *);
void menu_windraw(struct screen_ctx *, Window, void menu_windraw(struct screen_ctx *, Window,
const char *, ...); const char *, ...);

212
conf.c
View File

@ -56,134 +56,134 @@ static const char *color_binds[] = {
}; };
static const struct { static const struct {
const char *tag; const char *tag;
void (*handler)(void *, union arg *, enum xev); void (*handler)(void *, struct cargs *);
enum context context; enum context context;
union arg argument; int flag;
} name_to_func[] = { } name_to_func[] = {
{ "window-menu-label", kbfunc_menu_client_label, 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-lower", kbfunc_client_lower, CWM_CONTEXT_CC, 0 },
{ "window-raise", kbfunc_client_raise, CWM_CONTEXT_CC, {0} }, { "window-raise", kbfunc_client_raise, CWM_CONTEXT_CC, 0 },
{ "window-hide", kbfunc_client_hide, CWM_CONTEXT_CC, {0} }, { "window-hide", kbfunc_client_hide, CWM_CONTEXT_CC, 0 },
{ "window-delete", kbfunc_client_delete, CWM_CONTEXT_CC, {0} }, { "window-delete", kbfunc_client_delete, CWM_CONTEXT_CC, 0 },
{ "window-htile", kbfunc_client_htile, CWM_CONTEXT_CC, {0} }, { "window-htile", kbfunc_client_htile, CWM_CONTEXT_CC, 0 },
{ "window-vtile", kbfunc_client_vtile, CWM_CONTEXT_CC, {0} }, { "window-vtile", kbfunc_client_vtile, CWM_CONTEXT_CC, 0 },
{ "window-stick", kbfunc_client_toggle_sticky, 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-fullscreen", kbfunc_client_toggle_fullscreen, CWM_CONTEXT_CC, 0 },
{ "window-maximize", kbfunc_client_toggle_maximize, 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-vmaximize", kbfunc_client_toggle_vmaximize, CWM_CONTEXT_CC, 0 },
{ "window-hmaximize", kbfunc_client_toggle_hmaximize, 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-freeze", kbfunc_client_toggle_freeze, CWM_CONTEXT_CC, 0 },
{ "window-cycle", kbfunc_client_cycle, CWM_CONTEXT_SC, { "window-cycle", kbfunc_client_cycle, CWM_CONTEXT_SC,
{.i = (CWM_CYCLE_FORWARD)} }, (CWM_CYCLE_FORWARD) },
{ "window-rcycle", kbfunc_client_cycle, CWM_CONTEXT_SC, { "window-rcycle", kbfunc_client_cycle, CWM_CONTEXT_SC,
{.i = (CWM_CYCLE_REVERSE)} }, (CWM_CYCLE_REVERSE) },
{ "window-cycle-ingroup", kbfunc_client_cycle, CWM_CONTEXT_SC, { "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, { "window-rcycle-ingroup", kbfunc_client_cycle, CWM_CONTEXT_SC,
{.i = (CWM_CYCLE_REVERSE | CWM_CYCLE_INGROUP)} }, (CWM_CYCLE_REVERSE | CWM_CYCLE_INGROUP) },
{ "window-group", kbfunc_client_toggle_group, CWM_CONTEXT_CC, {0} }, { "window-group", kbfunc_client_toggle_group, CWM_CONTEXT_CC, 0 },
{ "window-movetogroup-1", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 1} }, { "window-movetogroup-1", kbfunc_client_movetogroup, CWM_CONTEXT_CC, 1 },
{ "window-movetogroup-2", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 2} }, { "window-movetogroup-2", kbfunc_client_movetogroup, CWM_CONTEXT_CC, 2 },
{ "window-movetogroup-3", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 3} }, { "window-movetogroup-3", kbfunc_client_movetogroup, CWM_CONTEXT_CC, 3 },
{ "window-movetogroup-4", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 4} }, { "window-movetogroup-4", kbfunc_client_movetogroup, CWM_CONTEXT_CC, 4 },
{ "window-movetogroup-5", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 5} }, { "window-movetogroup-5", kbfunc_client_movetogroup, CWM_CONTEXT_CC, 5 },
{ "window-movetogroup-6", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 6} }, { "window-movetogroup-6", kbfunc_client_movetogroup, CWM_CONTEXT_CC, 6 },
{ "window-movetogroup-7", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 7} }, { "window-movetogroup-7", kbfunc_client_movetogroup, CWM_CONTEXT_CC, 7 },
{ "window-movetogroup-8", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 8} }, { "window-movetogroup-8", kbfunc_client_movetogroup, CWM_CONTEXT_CC, 8 },
{ "window-movetogroup-9", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 9} }, { "window-movetogroup-9", kbfunc_client_movetogroup, CWM_CONTEXT_CC, 9 },
{ "window-move", mousefunc_client_move, CWM_CONTEXT_CC, {0} }, { "window-move", mousefunc_client_move, CWM_CONTEXT_CC, 0 },
{ "window-move-up", kbfunc_client_move, CWM_CONTEXT_CC, { "window-move-up", kbfunc_client_move, CWM_CONTEXT_CC,
{.i = (CWM_UP)} }, (CWM_UP) },
{ "window-move-down", kbfunc_client_move, CWM_CONTEXT_CC, { "window-move-down", kbfunc_client_move, CWM_CONTEXT_CC,
{.i = (CWM_DOWN)} }, (CWM_DOWN) },
{ "window-move-right", kbfunc_client_move, CWM_CONTEXT_CC, { "window-move-right", kbfunc_client_move, CWM_CONTEXT_CC,
{.i = (CWM_RIGHT)} }, (CWM_RIGHT) },
{ "window-move-left", kbfunc_client_move, CWM_CONTEXT_CC, { "window-move-left", kbfunc_client_move, CWM_CONTEXT_CC,
{.i = (CWM_LEFT)} }, (CWM_LEFT) },
{ "window-move-up-big", kbfunc_client_move, CWM_CONTEXT_CC, { "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, { "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, { "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, { "window-move-left-big", kbfunc_client_move, CWM_CONTEXT_CC,
{.i = (CWM_LEFT | CWM_BIGAMOUNT)} }, (CWM_LEFT | CWM_BIGAMOUNT) },
{ "window-resize", mousefunc_client_resize, CWM_CONTEXT_CC, {0} }, { "window-resize", mousefunc_client_resize, CWM_CONTEXT_CC, 0 },
{ "window-resize-up", kbfunc_client_resize, CWM_CONTEXT_CC, { "window-resize-up", kbfunc_client_resize, CWM_CONTEXT_CC,
{.i = (CWM_UP)} }, (CWM_UP) },
{ "window-resize-down", kbfunc_client_resize, CWM_CONTEXT_CC, { "window-resize-down", kbfunc_client_resize, CWM_CONTEXT_CC,
{.i = (CWM_DOWN)} }, (CWM_DOWN) },
{ "window-resize-right", kbfunc_client_resize, CWM_CONTEXT_CC, { "window-resize-right", kbfunc_client_resize, CWM_CONTEXT_CC,
{.i = (CWM_RIGHT)} }, (CWM_RIGHT) },
{ "window-resize-left", kbfunc_client_resize, CWM_CONTEXT_CC, { "window-resize-left", kbfunc_client_resize, CWM_CONTEXT_CC,
{.i = (CWM_LEFT)} }, (CWM_LEFT) },
{ "window-resize-up-big", kbfunc_client_resize, CWM_CONTEXT_CC, { "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, { "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, { "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, { "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, { "group-cycle", kbfunc_group_cycle, CWM_CONTEXT_SC,
{.i = (CWM_CYCLE_FORWARD)} }, (CWM_CYCLE_FORWARD) },
{ "group-rcycle", kbfunc_group_cycle, CWM_CONTEXT_SC, { "group-rcycle", kbfunc_group_cycle, CWM_CONTEXT_SC,
{.i = (CWM_CYCLE_REVERSE)} }, (CWM_CYCLE_REVERSE) },
{ "group-toggle-all", kbfunc_group_alltoggle, CWM_CONTEXT_SC, {0} }, { "group-toggle-all", kbfunc_group_alltoggle, CWM_CONTEXT_SC, 0 },
{ "group-toggle-1", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 1} }, { "group-toggle-1", kbfunc_group_toggle, CWM_CONTEXT_SC, 1 },
{ "group-toggle-2", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 2} }, { "group-toggle-2", kbfunc_group_toggle, CWM_CONTEXT_SC, 2 },
{ "group-toggle-3", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 3} }, { "group-toggle-3", kbfunc_group_toggle, CWM_CONTEXT_SC, 3 },
{ "group-toggle-4", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 4} }, { "group-toggle-4", kbfunc_group_toggle, CWM_CONTEXT_SC, 4 },
{ "group-toggle-5", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 5} }, { "group-toggle-5", kbfunc_group_toggle, CWM_CONTEXT_SC, 5 },
{ "group-toggle-6", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 6} }, { "group-toggle-6", kbfunc_group_toggle, CWM_CONTEXT_SC, 6 },
{ "group-toggle-7", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 7} }, { "group-toggle-7", kbfunc_group_toggle, CWM_CONTEXT_SC, 7 },
{ "group-toggle-8", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 8} }, { "group-toggle-8", kbfunc_group_toggle, CWM_CONTEXT_SC, 8 },
{ "group-toggle-9", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 9} }, { "group-toggle-9", kbfunc_group_toggle, CWM_CONTEXT_SC, 9 },
{ "group-only-1", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 1} }, { "group-only-1", kbfunc_group_only, CWM_CONTEXT_SC, 1 },
{ "group-only-2", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 2} }, { "group-only-2", kbfunc_group_only, CWM_CONTEXT_SC, 2 },
{ "group-only-3", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 3} }, { "group-only-3", kbfunc_group_only, CWM_CONTEXT_SC, 3 },
{ "group-only-4", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 4} }, { "group-only-4", kbfunc_group_only, CWM_CONTEXT_SC, 4 },
{ "group-only-5", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 5} }, { "group-only-5", kbfunc_group_only, CWM_CONTEXT_SC, 5 },
{ "group-only-6", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 6} }, { "group-only-6", kbfunc_group_only, CWM_CONTEXT_SC, 6 },
{ "group-only-7", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 7} }, { "group-only-7", kbfunc_group_only, CWM_CONTEXT_SC, 7 },
{ "group-only-8", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 8} }, { "group-only-8", kbfunc_group_only, CWM_CONTEXT_SC, 8 },
{ "group-only-9", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 9} }, { "group-only-9", kbfunc_group_only, CWM_CONTEXT_SC, 9 },
{ "pointer-move-up", kbfunc_ptrmove, CWM_CONTEXT_SC, { "pointer-move-up", kbfunc_ptrmove, CWM_CONTEXT_SC,
{.i = (CWM_UP)} }, (CWM_UP) },
{ "pointer-move-down", kbfunc_ptrmove, CWM_CONTEXT_SC, { "pointer-move-down", kbfunc_ptrmove, CWM_CONTEXT_SC,
{.i = (CWM_DOWN)} }, (CWM_DOWN) },
{ "pointer-move-left", kbfunc_ptrmove, CWM_CONTEXT_SC, { "pointer-move-left", kbfunc_ptrmove, CWM_CONTEXT_SC,
{.i = (CWM_LEFT)} }, (CWM_LEFT) },
{ "pointer-move-right", kbfunc_ptrmove, CWM_CONTEXT_SC, { "pointer-move-right", kbfunc_ptrmove, CWM_CONTEXT_SC,
{.i = (CWM_RIGHT)} }, (CWM_RIGHT) },
{ "pointer-move-up-big", kbfunc_ptrmove, CWM_CONTEXT_SC, { "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, { "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, { "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, { "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-cmd", kbfunc_menu_cmd, CWM_CONTEXT_SC, 0 },
{ "menu-group", kbfunc_menu_group, CWM_CONTEXT_SC, {0} }, { "menu-group", kbfunc_menu_group, CWM_CONTEXT_SC, 0 },
{ "menu-ssh", kbfunc_menu_ssh, CWM_CONTEXT_SC, {0} }, { "menu-ssh", kbfunc_menu_ssh, CWM_CONTEXT_SC, 0 },
{ "menu-window", kbfunc_menu_client, CWM_CONTEXT_SC, { "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, { "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, { "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, { "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} }, { "terminal", kbfunc_exec_term, CWM_CONTEXT_SC, 0 },
{ "lock", kbfunc_exec_lock, CWM_CONTEXT_SC, {0} }, { "lock", kbfunc_exec_lock, CWM_CONTEXT_SC, 0 },
{ "restart", kbfunc_cwm_status, CWM_CONTEXT_SC, {.i = CWM_EXEC_WM} }, { "restart", kbfunc_cwm_status, CWM_CONTEXT_SC, CWM_EXEC_WM },
{ "quit", kbfunc_cwm_status, CWM_CONTEXT_SC, {.i = CWM_QUIT} }, { "quit", kbfunc_cwm_status, CWM_CONTEXT_SC, CWM_QUIT },
}; };
static unsigned int ignore_mods[] = { static unsigned int ignore_mods[] = {
@ -510,12 +510,13 @@ int
conf_bind_key(struct conf *c, const char *bind, const char *cmd) conf_bind_key(struct conf *c, const char *bind, const char *cmd)
{ {
struct bind_ctx *kb; struct bind_ctx *kb;
struct cargs *cargs;
const char *key; const char *key;
unsigned int i; unsigned int i;
if ((strcmp(bind, "all") == 0) && (cmd == NULL)) { if ((strcmp(bind, "all") == 0) && (cmd == NULL)) {
conf_unbind_key(c, NULL); conf_unbind_key(c, NULL);
goto out; return(1);
} }
kb = xmalloc(sizeof(*kb)); kb = xmalloc(sizeof(*kb));
key = conf_bind_getmask(bind, &kb->modmask); 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); conf_unbind_key(c, kb);
if (cmd == NULL) { if (cmd == NULL) {
free(kb); free(kb);
goto out; return(1);
} }
cargs = xcalloc(1, sizeof(*cargs));
for (i = 0; i < nitems(name_to_func); i++) { for (i = 0; i < nitems(name_to_func); i++) {
if (strcmp(name_to_func[i].tag, cmd) != 0) if (strcmp(name_to_func[i].tag, cmd) != 0)
continue; continue;
kb->callback = name_to_func[i].handler; kb->callback = name_to_func[i].handler;
kb->context = name_to_func[i].context; kb->context = name_to_func[i].context;
kb->argument = name_to_func[i].argument; cargs->flag = name_to_func[i].flag;
TAILQ_INSERT_TAIL(&c->keybindq, kb, entry);
goto out; goto out;
} }
kb->callback = kbfunc_exec_cmd; kb->callback = kbfunc_exec_cmd;
kb->context = CWM_CONTEXT_NONE; kb->context = CWM_CONTEXT_NONE;
kb->argument.c = xstrdup(cmd); cargs->flag = 0;
TAILQ_INSERT_TAIL(&c->keybindq, kb, entry); cargs->cmd = xstrdup(cmd);
out: out:
kb->cargs = cargs;
TAILQ_INSERT_TAIL(&c->keybindq, kb, entry);
return(1); return(1);
} }
@ -557,8 +560,8 @@ conf_unbind_key(struct conf *c, struct bind_ctx *unbind)
((key->modmask == unbind->modmask) && ((key->modmask == unbind->modmask) &&
(key->press.keysym == unbind->press.keysym))) { (key->press.keysym == unbind->press.keysym))) {
TAILQ_REMOVE(&c->keybindq, key, entry); TAILQ_REMOVE(&c->keybindq, key, entry);
if (key->context == CWM_CONTEXT_NONE) free(key->cargs->cmd);
free(key->argument.c); free(key->cargs);
free(key); free(key);
} }
} }
@ -568,12 +571,13 @@ int
conf_bind_mouse(struct conf *c, const char *bind, const char *cmd) conf_bind_mouse(struct conf *c, const char *bind, const char *cmd)
{ {
struct bind_ctx *mb; struct bind_ctx *mb;
struct cargs *cargs;
const char *button, *errstr; const char *button, *errstr;
unsigned int i; unsigned int i;
if ((strcmp(bind, "all") == 0) && (cmd == NULL)) { if ((strcmp(bind, "all") == 0) && (cmd == NULL)) {
conf_unbind_mouse(c, NULL); conf_unbind_mouse(c, NULL);
goto out; return(1);
} }
mb = xmalloc(sizeof(*mb)); mb = xmalloc(sizeof(*mb));
button = conf_bind_getmask(bind, &mb->modmask); 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); conf_unbind_mouse(c, mb);
if (cmd == NULL) { if (cmd == NULL) {
free(mb); free(mb);
goto out; return(1);
} }
cargs = xcalloc(1, sizeof(*cargs));
for (i = 0; i < nitems(name_to_func); i++) { for (i = 0; i < nitems(name_to_func); i++) {
if (strcmp(name_to_func[i].tag, cmd) != 0) if (strcmp(name_to_func[i].tag, cmd) != 0)
continue; continue;
mb->callback = name_to_func[i].handler; mb->callback = name_to_func[i].handler;
mb->context = name_to_func[i].context; mb->context = name_to_func[i].context;
mb->argument = name_to_func[i].argument; cargs->flag = name_to_func[i].flag;
TAILQ_INSERT_TAIL(&c->mousebindq, mb, entry);
goto out; goto out;
} }
mb->callback = kbfunc_exec_cmd; mb->callback = kbfunc_exec_cmd;
mb->context = CWM_CONTEXT_NONE; mb->context = CWM_CONTEXT_NONE;
mb->argument.c = xstrdup(cmd); cargs->flag = 0;
TAILQ_INSERT_TAIL(&c->mousebindq, mb, entry); cargs->cmd = xstrdup(cmd);
out: out:
mb->cargs = cargs;
TAILQ_INSERT_TAIL(&c->mousebindq, mb, entry);
return(1); return(1);
} }
@ -615,8 +621,8 @@ conf_unbind_mouse(struct conf *c, struct bind_ctx *unbind)
((mb->modmask == unbind->modmask) && ((mb->modmask == unbind->modmask) &&
(mb->press.button == unbind->press.button))) { (mb->press.button == unbind->press.button))) {
TAILQ_REMOVE(&c->mousebindq, mb, entry); TAILQ_REMOVE(&c->mousebindq, mb, entry);
if (mb->context == CWM_CONTEXT_NONE) free(mb->cargs->cmd);
free(mb->argument.c); free(mb->cargs);
free(mb); free(mb);
} }
} }

View File

@ -41,9 +41,9 @@ extern sig_atomic_t cwm_status;
static void kbfunc_amount(int, int, int *, int *); static void kbfunc_amount(int, int, int *, int *);
void 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 static void
@ -71,20 +71,20 @@ kbfunc_amount(int flags, int amt, int *mx, int *my)
} }
void void
kbfunc_ptrmove(void *ctx, union arg *arg, enum xev xev) kbfunc_ptrmove(void *ctx, struct cargs *cargs)
{ {
struct screen_ctx *sc = ctx; struct screen_ctx *sc = ctx;
int x, y; int x, y;
int mx = 0, my = 0; 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_getpos(sc->rootwin, &x, &y);
xu_ptr_setpos(sc->rootwin, x + mx, y + my); xu_ptr_setpos(sc->rootwin, x + mx, y + my);
} }
void 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 client_ctx *cc = ctx;
struct screen_ctx *sc = cc->sc; 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) if (cc->flags & CLIENT_FREEZE)
return; return;
kbfunc_amount(arg->i, Conf.mamount, &mx, &my); kbfunc_amount(cargs->flag, Conf.mamount, &mx, &my);
cc->geom.x += mx; cc->geom.x += mx;
if (cc->geom.x < -(cc->geom.w + cc->bwidth - 1)) 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 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; struct client_ctx *cc = ctx;
int mx = 0, my = 0; 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)) if (!(cc->hint.flags & PResizeInc))
amt = Conf.mamount; 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) if ((cc->geom.w += mx * cc->hint.incw) < cc->hint.minw)
cc->geom.w = 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 void
kbfunc_client_delete(void *ctx, union arg *arg, enum xev xev) kbfunc_client_delete(void *ctx, struct cargs *cargs)
{ {
client_send_delete(ctx); client_send_delete(ctx);
} }
void void
kbfunc_client_lower(void *ctx, union arg *arg, enum xev xev) kbfunc_client_lower(void *ctx, struct cargs *cargs)
{ {
client_ptrsave(ctx); client_ptrsave(ctx);
client_lower(ctx); client_lower(ctx);
} }
void void
kbfunc_client_raise(void *ctx, union arg *arg, enum xev xev) kbfunc_client_raise(void *ctx, struct cargs *cargs)
{ {
client_raise(ctx); client_raise(ctx);
} }
void void
kbfunc_client_hide(void *ctx, union arg *arg, enum xev xev) kbfunc_client_hide(void *ctx, struct cargs *cargs)
{ {
client_hide(ctx); client_hide(ctx);
} }
void 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); client_toggle_freeze(ctx);
} }
void 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); client_toggle_sticky(ctx);
} }
void 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); client_toggle_fullscreen(ctx);
} }
void 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); client_toggle_maximize(ctx);
} }
void 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); client_toggle_hmaximize(ctx);
} }
void 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); client_toggle_vmaximize(ctx);
} }
void void
kbfunc_client_htile(void *ctx, union arg *arg, enum xev xev) kbfunc_client_htile(void *ctx, struct cargs *cargs)
{ {
client_htile(ctx); client_htile(ctx);
} }
void void
kbfunc_client_vtile(void *ctx, union arg *arg, enum xev xev) kbfunc_client_vtile(void *ctx, struct cargs *cargs)
{ {
client_vtile(ctx); client_vtile(ctx);
} }
void 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 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; 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, XGrabKeyboard(X_Dpy, cc->win, True,
GrabModeAsync, GrabModeAsync, CurrentTime); GrabModeAsync, GrabModeAsync, CurrentTime);
}
group_toggle_membership_enter(cc); group_toggle_membership_enter(cc);
} }
void 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 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 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 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 void
kbfunc_group_alltoggle(void *ctx, union arg *arg, enum xev xev) kbfunc_group_alltoggle(void *ctx, struct cargs *cargs)
{ {
group_alltoggle(ctx); group_alltoggle(ctx);
} }
void 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 screen_ctx *sc = ctx;
struct client_ctx *cc, *old_cc; struct client_ctx *cc, *old_cc;
struct menu *mi; struct menu *mi;
struct menu_q menuq; struct menu_q menuq;
int m = (xev == CWM_XEV_BTN); int m = (cargs->xev == CWM_XEV_BTN);
int all = (arg->i & CWM_MENU_WINDOW_ALL); int all = (cargs->flag & CWM_MENU_WINDOW_ALL);
old_cc = client_current(); old_cc = client_current();
@ -311,13 +310,13 @@ kbfunc_menu_client(void *ctx, union arg *arg, enum xev xev)
} }
void 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 screen_ctx *sc = ctx;
struct cmd_ctx *cmd; struct cmd_ctx *cmd;
struct menu *mi; struct menu *mi;
struct menu_q menuq; struct menu_q menuq;
int m = (xev == CWM_XEV_BTN); int m = (cargs->xev == CWM_XEV_BTN);
TAILQ_INIT(&menuq); TAILQ_INIT(&menuq);
TAILQ_FOREACH(cmd, &Conf.cmdq, entry) { TAILQ_FOREACH(cmd, &Conf.cmdq, entry) {
@ -340,13 +339,13 @@ kbfunc_menu_cmd(void *ctx, union arg *arg, enum xev xev)
} }
void 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 screen_ctx *sc = ctx;
struct group_ctx *gc; struct group_ctx *gc;
struct menu *mi; struct menu *mi;
struct menu_q menuq; struct menu_q menuq;
int m = (xev == CWM_XEV_BTN); int m = (cargs->xev == CWM_XEV_BTN);
TAILQ_INIT(&menuq); TAILQ_INIT(&menuq);
TAILQ_FOREACH(gc, &sc->groupq, entry) { TAILQ_FOREACH(gc, &sc->groupq, entry) {
@ -367,7 +366,7 @@ kbfunc_menu_group(void *ctx, union arg *arg, enum xev xev)
} }
void void
kbfunc_menu_exec(void *ctx, union arg *arg, enum xev xev) kbfunc_menu_exec(void *ctx, struct cargs *cargs)
{ {
#define NPATHS 256 #define NPATHS 256
struct screen_ctx *sc = ctx; struct screen_ctx *sc = ctx;
@ -379,7 +378,7 @@ kbfunc_menu_exec(void *ctx, union arg *arg, enum xev xev)
struct dirent *dp; struct dirent *dp;
struct menu *mi; struct menu *mi;
struct menu_q menuq; struct menu_q menuq;
int l, i, cmd = arg->i; int l, i, cmd = cargs->flag;
switch (cmd) { switch (cmd) {
case CWM_MENU_EXEC_EXEC: case CWM_MENU_EXEC_EXEC:
@ -457,7 +456,7 @@ out:
} }
void 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 screen_ctx *sc = ctx;
struct cmd_ctx *cmd; struct cmd_ctx *cmd;
@ -524,7 +523,7 @@ out:
} }
void 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 client_ctx *cc = ctx;
struct menu *mi; struct menu *mi;
@ -544,13 +543,13 @@ kbfunc_menu_client_label(void *ctx, union arg *arg, enum xev xev)
} }
void 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 void
kbfunc_exec_term(void *ctx, union arg *arg, enum xev xev) kbfunc_exec_term(void *ctx, struct cargs *cargs)
{ {
struct cmd_ctx *cmd; struct cmd_ctx *cmd;
@ -561,7 +560,7 @@ kbfunc_exec_term(void *ctx, union arg *arg, enum xev xev)
} }
void void
kbfunc_exec_lock(void *ctx, union arg *arg, enum xev xev) kbfunc_exec_lock(void *ctx, struct cargs *cargs)
{ {
struct cmd_ctx *cmd; struct cmd_ctx *cmd;

View File

@ -33,7 +33,7 @@
#include "calmwm.h" #include "calmwm.h"
void 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; struct client_ctx *cc = ctx;
XEvent ev; XEvent ev;
@ -87,7 +87,7 @@ mousefunc_client_resize(void *ctx, union arg *arg, enum xev xev)
} }
void 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; struct client_ctx *cc = ctx;
XEvent ev; XEvent ev;

View File

@ -233,22 +233,23 @@ xev_handle_buttonpress(XEvent *ee)
if (mb == NULL) if (mb == NULL)
return; return;
mb->cargs->xev = CWM_XEV_BTN;
switch (mb->context) { switch (mb->context) {
case CWM_CONTEXT_CC: case CWM_CONTEXT_CC:
if (((cc = client_find(e->window)) == NULL) && if (((cc = client_find(e->window)) == NULL) &&
(cc = client_current()) == NULL) (cc = client_current()) == NULL)
return; return;
(*mb->callback)(cc, &mb->argument, CWM_XEV_BTN); (*mb->callback)(cc, mb->cargs);
break; break;
case CWM_CONTEXT_SC: case CWM_CONTEXT_SC:
if (e->window != e->root) if (e->window != e->root)
return; return;
if ((sc = screen_find(e->window)) == NULL) if ((sc = screen_find(e->window)) == NULL)
return; return;
(*mb->callback)(sc, &mb->argument, CWM_XEV_BTN); (*mb->callback)(sc, mb->cargs);
break; break;
case CWM_CONTEXT_NONE: case CWM_CONTEXT_NONE:
(*mb->callback)(NULL, &mb->argument, CWM_XEV_BTN); (*mb->callback)(NULL, mb->cargs);
break; break;
} }
} }
@ -295,20 +296,21 @@ xev_handle_keypress(XEvent *ee)
if (kb == NULL) if (kb == NULL)
return; return;
kb->cargs->xev = CWM_XEV_KEY;
switch (kb->context) { switch (kb->context) {
case CWM_CONTEXT_CC: case CWM_CONTEXT_CC:
if (((cc = client_find(e->window)) == NULL) && if (((cc = client_find(e->window)) == NULL) &&
(cc = client_current()) == NULL) (cc = client_current()) == NULL)
return; return;
(*kb->callback)(cc, &kb->argument, CWM_XEV_KEY); (*kb->callback)(cc, kb->cargs);
break; break;
case CWM_CONTEXT_SC: case CWM_CONTEXT_SC:
if ((sc = screen_find(e->window)) == NULL) if ((sc = screen_find(e->window)) == NULL)
return; return;
(*kb->callback)(sc, &kb->argument, CWM_XEV_KEY); (*kb->callback)(sc, kb->cargs);
break; break;
case CWM_CONTEXT_NONE: case CWM_CONTEXT_NONE:
(*kb->callback)(NULL, &kb->argument, CWM_XEV_KEY); (*kb->callback)(NULL, kb->cargs);
break; break;
} }
} }