about summary refs log tree commit diff
diff options
context:
space:
mode:
authorokan <okan>2013-07-08 18:19:22 +0000
committerokan <okan>2013-07-08 18:19:22 +0000
commit1f244fe29c7234b05614f4040208f60052a8d377 (patch)
tree440e0907873489cb4f96ad4f81b65cc7261cc6dd
parenta49373406607e71601ac062c0a75ad36219065e2 (diff)
downloadcwm-1f244fe29c7234b05614f4040208f60052a8d377.tar.gz
cwm-1f244fe29c7234b05614f4040208f60052a8d377.tar.xz
cwm-1f244fe29c7234b05614f4040208f60052a8d377.zip
move kbfunc and mousefunc closer together
-rw-r--r--calmwm.h19
-rw-r--r--conf.c71
-rw-r--r--kbfunc.c2
-rw-r--r--mousefunc.c12
-rw-r--r--xevents.c4
5 files changed, 56 insertions, 52 deletions
diff --git a/calmwm.h b/calmwm.h
index 0f74a87..aa21c35 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -258,7 +258,7 @@ struct mousebinding {
 	u_int			 	button;
 #define MOUSEBIND_CTX_ROOT		0x0001
 #define MOUSEBIND_CTX_WIN		0x0002
-	int				context;
+	int				flags;
 };
 TAILQ_HEAD(mousebinding_q, mousebinding);
 
@@ -403,6 +403,8 @@ void			 kbfunc_client_label(struct client_ctx *, union arg *);
 void			 kbfunc_client_lower(struct client_ctx *, union arg *);
 void			 kbfunc_client_maximize(struct client_ctx *,
 			     union arg *);
+void			 kbfunc_client_moveresize(struct client_ctx *,
+			     union arg *);
 void			 kbfunc_client_movetogroup(struct client_ctx *,
 			     union arg *);
 void			 kbfunc_client_nogroup(struct client_ctx *,
@@ -416,23 +418,22 @@ void			 kbfunc_cmdexec(struct client_ctx *, union arg *);
 void			 kbfunc_exec(struct client_ctx *, union arg *);
 void			 kbfunc_lock(struct client_ctx *, union arg *);
 void			 kbfunc_menu_search(struct client_ctx *, union arg *);
-void			 kbfunc_moveresize(struct client_ctx *, union arg *);
 void			 kbfunc_quit_wm(struct client_ctx *, union arg *);
 void			 kbfunc_restart(struct client_ctx *, union arg *);
 void			 kbfunc_ssh(struct client_ctx *, union arg *);
 void			 kbfunc_term(struct client_ctx *, union arg *);
 void 			 kbfunc_tile(struct client_ctx *, union arg *);
 
+void			 mousefunc_client_grouptoggle(struct client_ctx *,
+			    void *);
+void			 mousefunc_client_hide(struct client_ctx *, void *);
+void			 mousefunc_client_lower(struct client_ctx *, void *);
+void			 mousefunc_client_move(struct client_ctx *, void *);
+void			 mousefunc_client_raise(struct client_ctx *, void *);
+void			 mousefunc_client_resize(struct client_ctx *, void *);
 void			 mousefunc_menu_cmd(struct client_ctx *, void *);
 void			 mousefunc_menu_group(struct client_ctx *, void *);
 void			 mousefunc_menu_unhide(struct client_ctx *, void *);
-void			 mousefunc_window_grouptoggle(struct client_ctx *,
-			    void *);
-void			 mousefunc_window_hide(struct client_ctx *, void *);
-void			 mousefunc_window_lower(struct client_ctx *, void *);
-void			 mousefunc_window_move(struct client_ctx *, void *);
-void			 mousefunc_window_raise(struct client_ctx *, void *);
-void			 mousefunc_window_resize(struct client_ctx *, void *);
 
 struct menu  		*menu_filter(struct screen_ctx *, struct menu_q *,
 			     char *, char *, int,
diff --git a/conf.c b/conf.c
index 82e6fa8..5f3d1cb 100644
--- a/conf.c
+++ b/conf.c
@@ -32,8 +32,8 @@
 #include "calmwm.h"
 
 static const char	*conf_bind_getmask(const char *, u_int *);
-static void	 	 conf_unbind_mouse(struct conf *, struct mousebinding *);
 static void	 	 conf_unbind_kbd(struct conf *, struct keybinding *);
+static void	 	 conf_unbind_mouse(struct conf *, struct mousebinding *);
 
 /* Add an command menu entry to the end of the menu */
 void
@@ -382,50 +382,53 @@ static struct {
 	{ "ssh", kbfunc_ssh, 0, {0} },
 	{ "terminal", kbfunc_term, 0, {0} },
 	{ "lock", kbfunc_lock, 0, {0} },
-	{ "moveup", kbfunc_moveresize, KBFLAG_NEEDCLIENT,
+	{ "moveup", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT,
 	    {.i = (CWM_UP|CWM_MOVE)} },
-	{ "movedown", kbfunc_moveresize, KBFLAG_NEEDCLIENT,
+	{ "movedown", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT,
 	    {.i = (CWM_DOWN|CWM_MOVE)} },
-	{ "moveright", kbfunc_moveresize, KBFLAG_NEEDCLIENT,
+	{ "moveright", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT,
 	    {.i = (CWM_RIGHT|CWM_MOVE)} },
-	{ "moveleft", kbfunc_moveresize, KBFLAG_NEEDCLIENT,
+	{ "moveleft", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT,
 	    {.i = (CWM_LEFT|CWM_MOVE)} },
-	{ "bigmoveup", kbfunc_moveresize, KBFLAG_NEEDCLIENT,
+	{ "bigmoveup", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT,
 	    {.i = (CWM_UP|CWM_MOVE|CWM_BIGMOVE)} },
-	{ "bigmovedown", kbfunc_moveresize, KBFLAG_NEEDCLIENT,
+	{ "bigmovedown", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT,
 	    {.i = (CWM_DOWN|CWM_MOVE|CWM_BIGMOVE)} },
-	{ "bigmoveright", kbfunc_moveresize, KBFLAG_NEEDCLIENT,
+	{ "bigmoveright", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT,
 	    {.i = (CWM_RIGHT|CWM_MOVE|CWM_BIGMOVE)} },
-	{ "bigmoveleft", kbfunc_moveresize, KBFLAG_NEEDCLIENT,
+	{ "bigmoveleft", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT,
 	    {.i = (CWM_LEFT|CWM_MOVE|CWM_BIGMOVE)} },
-	{ "resizeup", kbfunc_moveresize, KBFLAG_NEEDCLIENT,
+	{ "resizeup", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT,
 	    {.i = (CWM_UP|CWM_RESIZE)} },
-	{ "resizedown", kbfunc_moveresize, KBFLAG_NEEDCLIENT,
+	{ "resizedown", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT,
 	    {.i = (CWM_DOWN|CWM_RESIZE)} },
-	{ "resizeright", kbfunc_moveresize, KBFLAG_NEEDCLIENT,
+	{ "resizeright", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT,
 	    {.i = (CWM_RIGHT|CWM_RESIZE)} },
-	{ "resizeleft", kbfunc_moveresize, KBFLAG_NEEDCLIENT,
+	{ "resizeleft", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT,
 	    {.i = (CWM_LEFT|CWM_RESIZE)} },
-	{ "bigresizeup", kbfunc_moveresize, KBFLAG_NEEDCLIENT,
+	{ "bigresizeup", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT,
 	    {.i = (CWM_UP|CWM_RESIZE|CWM_BIGMOVE)} },
-	{ "bigresizedown", kbfunc_moveresize, KBFLAG_NEEDCLIENT,
+	{ "bigresizedown", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT,
 	    {.i = (CWM_DOWN|CWM_RESIZE|CWM_BIGMOVE)} },
-	{ "bigresizeright", kbfunc_moveresize, KBFLAG_NEEDCLIENT,
+	{ "bigresizeright", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT,
 	    {.i = (CWM_RIGHT|CWM_RESIZE|CWM_BIGMOVE)} },
-	{ "bigresizeleft", kbfunc_moveresize, KBFLAG_NEEDCLIENT,
+	{ "bigresizeleft", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT,
 	    {.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,
+	{ "ptrmoveup", kbfunc_client_moveresize, 0,
+	    {.i = (CWM_UP|CWM_PTRMOVE)} },
+	{ "ptrmovedown", kbfunc_client_moveresize, 0,
+	    {.i = (CWM_DOWN|CWM_PTRMOVE)} },
+	{ "ptrmoveleft", kbfunc_client_moveresize, 0,
+	    {.i = (CWM_LEFT|CWM_PTRMOVE)} },
+	{ "ptrmoveright", kbfunc_client_moveresize, 0,
 	    {.i = (CWM_RIGHT|CWM_PTRMOVE)} },
-	{ "bigptrmoveup", kbfunc_moveresize, 0,
+	{ "bigptrmoveup", kbfunc_client_moveresize, 0,
 	    {.i = (CWM_UP|CWM_PTRMOVE|CWM_BIGMOVE)} },
-	{ "bigptrmovedown", kbfunc_moveresize, 0,
+	{ "bigptrmovedown", kbfunc_client_moveresize, 0,
 	    {.i = (CWM_DOWN|CWM_PTRMOVE|CWM_BIGMOVE)} },
-	{ "bigptrmoveleft", kbfunc_moveresize, 0,
+	{ "bigptrmoveleft", kbfunc_client_moveresize, 0,
 	    {.i = (CWM_LEFT|CWM_PTRMOVE|CWM_BIGMOVE)} },
-	{ "bigptrmoveright", kbfunc_moveresize, 0,
+	{ "bigptrmoveright", kbfunc_client_moveresize, 0,
 	    {.i = (CWM_RIGHT|CWM_PTRMOVE|CWM_BIGMOVE)} },
 	{ "htile", kbfunc_tile, KBFLAG_NEEDCLIENT,
 	    {.i = CWM_TILE_HORIZ } },
@@ -538,15 +541,15 @@ conf_unbind_kbd(struct conf *c, struct keybinding *unbind)
 static struct {
 	char *tag;
 	void (*handler)(struct client_ctx *, void *);
-	int context;
+	int flags;
 } name_to_mousefunc[] = {
-	{ "window_move", mousefunc_window_move, MOUSEBIND_CTX_WIN },
-	{ "window_resize", mousefunc_window_resize, MOUSEBIND_CTX_WIN },
-	{ "window_grouptoggle", mousefunc_window_grouptoggle,
+	{ "window_move", mousefunc_client_move, MOUSEBIND_CTX_WIN },
+	{ "window_resize", mousefunc_client_resize, MOUSEBIND_CTX_WIN },
+	{ "window_grouptoggle", mousefunc_client_grouptoggle,
 	    MOUSEBIND_CTX_WIN },
-	{ "window_lower", mousefunc_window_lower, MOUSEBIND_CTX_WIN },
-	{ "window_raise", mousefunc_window_raise, MOUSEBIND_CTX_WIN },
-	{ "window_hide", mousefunc_window_hide, MOUSEBIND_CTX_WIN },
+	{ "window_lower", mousefunc_client_lower, MOUSEBIND_CTX_WIN },
+	{ "window_raise", mousefunc_client_raise, MOUSEBIND_CTX_WIN },
+	{ "window_hide", mousefunc_client_hide, MOUSEBIND_CTX_WIN },
 	{ "menu_group", mousefunc_menu_group, MOUSEBIND_CTX_ROOT },
 	{ "menu_unhide", mousefunc_menu_unhide, MOUSEBIND_CTX_ROOT },
 	{ "menu_cmd", mousefunc_menu_cmd, MOUSEBIND_CTX_ROOT },
@@ -594,8 +597,8 @@ conf_bind_mouse(struct conf *c, char *name, char *binding)
 		if (strcmp(name_to_mousefunc[i].tag, binding) != 0)
 			continue;
 
-		current_binding->context = name_to_mousefunc[i].context;
 		current_binding->callback = name_to_mousefunc[i].handler;
+		current_binding->flags = name_to_mousefunc[i].flags;
 		TAILQ_INSERT_TAIL(&c->mousebindingq, current_binding, entry);
 		return (1);
 	}
@@ -642,7 +645,7 @@ conf_grab_mouse(Window win)
 	struct mousebinding	*mb;
 
 	TAILQ_FOREACH(mb, &Conf.mousebindingq, entry) {
-		if (mb->context != MOUSEBIND_CTX_WIN)
+		if (mb->flags != MOUSEBIND_CTX_WIN)
 			continue;
 		xu_btn_grab(win, mb->modmask, mb->button);
 	}
diff --git a/kbfunc.c b/kbfunc.c
index 79cb49b..906ca12 100644
--- a/kbfunc.c
+++ b/kbfunc.c
@@ -53,7 +53,7 @@ kbfunc_client_raise(struct client_ctx *cc, union arg *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, union arg *arg)
+kbfunc_client_moveresize(struct client_ctx *cc, union arg *arg)
 {
 	struct screen_ctx	*sc = cc->sc;
 	int			 x, y, flags, amt;
diff --git a/mousefunc.c b/mousefunc.c
index 90c7078..109b655 100644
--- a/mousefunc.c
+++ b/mousefunc.c
@@ -68,7 +68,7 @@ mousefunc_sweep_draw(struct client_ctx *cc)
 }
 
 void
-mousefunc_window_resize(struct client_ctx *cc, void *arg)
+mousefunc_client_resize(struct client_ctx *cc, void *arg)
 {
 	XEvent			 ev;
 	Time			 ltime = 0;
@@ -125,7 +125,7 @@ mousefunc_window_resize(struct client_ctx *cc, void *arg)
 }
 
 void
-mousefunc_window_move(struct client_ctx *cc, void *arg)
+mousefunc_client_move(struct client_ctx *cc, void *arg)
 {
 	XEvent			 ev;
 	Time			 ltime = 0;
@@ -177,26 +177,26 @@ mousefunc_window_move(struct client_ctx *cc, void *arg)
 }
 
 void
-mousefunc_window_grouptoggle(struct client_ctx *cc, void *arg)
+mousefunc_client_grouptoggle(struct client_ctx *cc, void *arg)
 {
 	group_sticky_toggle_enter(cc);
 }
 
 void
-mousefunc_window_lower(struct client_ctx *cc, void *arg)
+mousefunc_client_lower(struct client_ctx *cc, void *arg)
 {
 	client_ptrsave(cc);
 	client_lower(cc);
 }
 
 void
-mousefunc_window_raise(struct client_ctx *cc, void *arg)
+mousefunc_client_raise(struct client_ctx *cc, void *arg)
 {
 	client_raise(cc);
 }
 
 void
-mousefunc_window_hide(struct client_ctx *cc, void *arg)
+mousefunc_client_hide(struct client_ctx *cc, void *arg)
 {
 	client_hide(cc);
 }
diff --git a/xevents.c b/xevents.c
index ddbd8b6..4d31e65 100644
--- a/xevents.c
+++ b/xevents.c
@@ -253,12 +253,12 @@ xev_handle_buttonpress(XEvent *ee)
 
 	if (mb == NULL)
 		return;
-	if (mb->context == MOUSEBIND_CTX_ROOT) {
+	if (mb->flags == MOUSEBIND_CTX_ROOT) {
 		if (e->window != sc->rootwin)
 			return;
 		cc = &fakecc;
 		cc->sc = screen_fromroot(e->window);
-	} else if (cc == NULL) /* (mb->context == MOUSEBIND_CTX_WIN */
+	} else if (cc == NULL) /* (mb->flags == MOUSEBIND_CTX_WIN */
 		return;
 
 	(*mb->callback)(cc, e);