summary refs log tree commit diff
diff options
context:
space:
mode:
authorokan <okan>2013-07-10 14:15:58 +0000
committerokan <okan>2013-07-10 14:15:58 +0000
commitbd7b8163bb0be2bd4904a179771a8f79163e8161 (patch)
tree80b60f037fa949a3a50d0dd42b19e38c318d76bf
parent95710383580ecf66a58f27ecaa62dfe6c714c682 (diff)
downloadcwm-bd7b8163bb0be2bd4904a179771a8f79163e8161.tar.gz
cwm-bd7b8163bb0be2bd4904a179771a8f79163e8161.tar.xz
cwm-bd7b8163bb0be2bd4904a179771a8f79163e8161.zip
bring buttonpress and keypress event handlers slightly closer together
-rw-r--r--xevents.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/xevents.c b/xevents.c
index 4d31e65..16bd10e 100644
--- a/xevents.c
+++ b/xevents.c
@@ -238,12 +238,8 @@ xev_handle_buttonpress(XEvent *ee)
 {
 	XButtonEvent		*e = &ee->xbutton;
 	struct client_ctx	*cc, fakecc;
-	struct screen_ctx	*sc;
 	struct mousebinding	*mb;
 
-	sc = screen_fromroot(e->root);
-	cc = client_find(e->window);
-
 	e->state &= ~IGNOREMODMASK;
 
 	TAILQ_FOREACH(mb, &Conf.mousebindingq, entry) {
@@ -253,13 +249,16 @@ xev_handle_buttonpress(XEvent *ee)
 
 	if (mb == NULL)
 		return;
-	if (mb->flags == MOUSEBIND_CTX_ROOT) {
-		if (e->window != sc->rootwin)
+	if (mb->flags == MOUSEBIND_CTX_WIN) {
+		if (((cc = client_find(e->window)) == NULL) &&
+		    (cc = client_current()) == NULL)
+			return;
+	} else { /* (mb->flags == MOUSEBIND_CTX_ROOT) */
+		if (e->window != e->root)
 			return;
 		cc = &fakecc;
 		cc->sc = screen_fromroot(e->window);
-	} else if (cc == NULL) /* (mb->flags == MOUSEBIND_CTX_WIN */
-		return;
+	}
 
 	(*mb->callback)(cc, e);
 }