summary refs log tree commit diff
diff options
context:
space:
mode:
authorokan <okan>2019-03-08 17:40:43 +0000
committerokan <okan>2019-03-08 17:40:43 +0000
commit4470a247c8d30f0c7acdc44905feecd0ed3edf10 (patch)
treee84aa7c385895bb2f004714920552379a9918964
parenteab4b7e4b5f026d6859d92a18e1630197bd602e0 (diff)
downloadcwm-4470a247c8d30f0c7acdc44905feecd0ed3edf10.tar.gz
cwm-4470a247c8d30f0c7acdc44905feecd0ed3edf10.tar.xz
cwm-4470a247c8d30f0c7acdc44905feecd0ed3edf10.zip
Similar to keypress event, fetch the screen from the event root window in the
buttonpress handler; bail if we don't manage the screen. Allows us to find the
current client based on the screen/event root.
-rw-r--r--xevents.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/xevents.c b/xevents.c
index cb2cfee..c35e87a 100644
--- a/xevents.c
+++ b/xevents.c
@@ -237,28 +237,26 @@ xev_handle_buttonpress(XEvent *ee)
 	LOG_DEBUG3("root: 0x%lx window: 0x%lx subwindow: 0x%lx",
 	    e->root, e->window, e->subwindow);
 
+	if ((sc = screen_find(e->root)) == NULL)
+		return;
+
 	e->state &= ~IGNOREMODMASK;
 
 	TAILQ_FOREACH(mb, &Conf.mousebindq, entry) {
 		if (e->button == mb->press.button && e->state == mb->modmask)
 			break;
 	}
-
 	if (mb == NULL)
 		return;
 	mb->cargs->xev = CWM_XEV_BTN;
 	switch (mb->context) {
 	case CWM_CONTEXT_CC:
 		if (((cc = client_find(e->window)) == NULL) &&
-		    ((cc = client_current(NULL)) == NULL))
+		    ((cc = client_current(sc)) == NULL))
 			return;
 		(*mb->callback)(cc, mb->cargs);
 		break;
 	case CWM_CONTEXT_SC:
-		if (e->window != e->root)
-			return;
-		if ((sc = screen_find(e->window)) == NULL)
-			return;
 		(*mb->callback)(sc, mb->cargs);
 		break;
 	case CWM_CONTEXT_NONE: