[hackers] [dwm] Button passthrough when client is not focused || Markus Teich

From: <git_AT_suckless.org>
Date: Tue, 28 Mar 2017 20:23:53 +0200 (CEST)

commit 022d07605412bc5bd9726f74af9355c562ba4957
Author: Markus Teich <markus.teich_AT_stusta.mhn.de>
AuthorDate: Sat Jan 7 17:21:29 2017 +0100
Commit: Anselm R Garbe <anselm_AT_garbe.us>
CommitDate: Tue Mar 28 20:23:34 2017 +0200

    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.

diff --git a/dwm.c b/dwm.c
index 3f80b63..9c01d1a 100644
--- a/dwm.c
+++ b/dwm.c
_AT_@ -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++)
_AT_@ -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);
         }
 }
 
Received on Tue Mar 28 2017 - 20:23:53 CEST

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 20:24:25 CEST