summary refs log tree commit diff
path: root/kbfunc.c
diff options
context:
space:
mode:
authorokan <okan>2017-05-09 13:40:18 +0000
committerokan <okan>2017-05-09 13:40:18 +0000
commit113ffcf47e3988730f393eb2ce8de734f8f22e89 (patch)
tree9a30bb342aca07c7c8f89d060417e7be5c1d51e0 /kbfunc.c
parent189a735eaa16a01b491518fc5db5183ef0c6d76b (diff)
downloadcwm-113ffcf47e3988730f393eb2ce8de734f8f22e89.tar.gz
cwm-113ffcf47e3988730f393eb2ce8de734f8f22e89.tar.xz
cwm-113ffcf47e3988730f393eb2ce8de734f8f22e89.zip
Alter callbacks to take a struct instead of a growing number of arguments;
greatly simplifies upcoming work.
Diffstat (limited to 'kbfunc.c')
-rw-r--r--kbfunc.c99
1 files changed, 49 insertions, 50 deletions
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;