]> git.corax.cc Git - dwm/commitdiff
Make the pointer follow the focus
authorMatthias Kruk <m@m10k.eu>
Sun, 28 Feb 2021 06:04:46 +0000 (15:04 +0900)
committerMatthias Kruk <m@m10k.eu>
Sun, 28 Feb 2021 06:04:46 +0000 (15:04 +0900)
When the pointer moves to a different client, the focus follows the
pointer, putting the client under the pointer in focus. However, when
the focus is changed using the keyboard, the pointer remains over the
client that is now out-of-focus. If using multiple screens, or if a
client decides to hide the pointer because it is over a text input,
this can make it very annoying to figure out the pointer location.
This commit makes sure that the pointer follows the focus when it
moves to a different client.

dwm.c

diff --git a/dwm.c b/dwm.c
index 902b125a30dc3f268fe89732fed2e0f73c617e17..d4a50e4afe2082b1c60fd309e765a77d0adf6d1a 100755 (executable)
--- a/dwm.c
+++ b/dwm.c
@@ -1705,6 +1705,7 @@ void
 setfocus(Client *c) {
        if(!c->neverfocus)
                XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
+       XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w / 2, c->h / 2);
        sendevent(c->win, wmatom[WMTakeFocus], NoEventMask, wmatom[WMTakeFocus], CurrentTime, 0, 0, 0);
 }
 
@@ -2448,8 +2449,8 @@ view(const Arg *arg) {
        selmon->seltags ^= 1; /* toggle sel tagset */
        if(arg->ui & TAGMASK)
                selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
-       focus(NULL);
        arrange(selmon);
+       focus(NULL);
 }
 
 Client *