From b040562d5740483ac47ee567776aa949dc1f0e13 Mon Sep 17 00:00:00 2001 From: Matthias Kruk Date: Sun, 28 Feb 2021 15:04:46 +0900 Subject: [PATCH] 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. --- dwm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 * -- 2.47.3