summarylogtreecommitdiffstats
path: root/dwm.c
diff options
context:
space:
mode:
authorMarkus Teich2017-01-07 17:21:29 +0100
committerAnselm R Garbe2017-03-28 20:23:34 +0200
commit96e70e0f9b25cb0b7af1cbb1249efd58ed8fe28a (patch)
treecf3222d14569ded712198bffa5cbded8ed591680 /dwm.c
parentf009f2eb17d8cef6cdb5d3b96a3a2672e03cd89d (diff)
downloadaur-96e70e0f9b25cb0b7af1cbb1249efd58ed8fe28a.tar.gz
Button passthrough when client is not focused
Before this change it is not possible to press a button in a client on the first click if the client is not yet focused. The first click on the button would only focus the client and a second click on the button is needed to activate it. This situation can occur when moving the mouse over a client (therefore focusing it) and then moving the focus to another client with keyboard shortcuts. After this commit the behavior is fixed and button presses on unfocused clients are passed to the client correctly.
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/dwm.c b/dwm.c
index 3f80b632eca..9c01d1a154e 100644
--- a/dwm.c
+++ b/dwm.c
@@ -446,6 +446,8 @@ buttonpress(XEvent *e)
click = ClkWinTitle;
} else if ((c = wintoclient(ev->window))) {
focus(c);
+ restack(selmon);
+ XAllowEvents(dpy, ReplayPointer, CurrentTime);
click = ClkClientWin;
}
for (i = 0; i < LENGTH(buttons); i++)
@@ -932,17 +934,16 @@ grabbuttons(Client *c, int focused)
unsigned int i, j;
unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
- if (focused) {
- for (i = 0; i < LENGTH(buttons); i++)
- if (buttons[i].click == ClkClientWin)
- for (j = 0; j < LENGTH(modifiers); j++)
- XGrabButton(dpy, buttons[i].button,
- buttons[i].mask | modifiers[j],
- c->win, False, BUTTONMASK,
- GrabModeAsync, GrabModeSync, None, None);
- } else
+ if (!focused)
XGrabButton(dpy, AnyButton, AnyModifier, c->win, False,
- BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
+ BUTTONMASK, GrabModeSync, GrabModeSync, None, None);
+ for (i = 0; i < LENGTH(buttons); i++)
+ if (buttons[i].click == ClkClientWin)
+ for (j = 0; j < LENGTH(modifiers); j++)
+ XGrabButton(dpy, buttons[i].button,
+ buttons[i].mask | modifiers[j],
+ c->win, False, BUTTONMASK,
+ GrabModeAsync, GrabModeSync, None, None);
}
}