From: Matthias Kruk Date: Sun, 28 Feb 2021 06:04:46 +0000 (+0900) Subject: Make the pointer follow the focus X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=b040562d5740483ac47ee567776aa949dc1f0e13;p=dwm Make the pointer follow the focus 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. --- diff --git a/dwm.c b/dwm.c index 902b125..d4a50e4 100755 --- 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 *