]> nyquistdev.net Git - dwm-config.git/commitdiff
goto window dwm shortcut
authorA-Larsen <austin.larsen@mailfence.com>
Tue, 13 Oct 2026 14:28:05 +0000 (10:28 -0400)
committerA-Larsen <austin.larsen@mailfence.com>
Tue, 13 Oct 2026 14:28:05 +0000 (10:28 -0400)
dwm
dwm.c
dwm.o

diff --git a/dwm b/dwm
index 3f6f18e39b18c7b835efc7ae6979c5fa409f6fe5..8c55f19b71f5ba7ade53ba457015fa78a2b09eff 100755 (executable)
Binary files a/dwm and b/dwm differ
diff --git a/dwm.c b/dwm.c
index 5ad38e4e1fc953e39774c9507b5ac30b00083770..782a4452250127ef966d7185e28a5b61d5a6555b 100644 (file)
--- a/dwm.c
+++ b/dwm.c
@@ -1099,24 +1099,28 @@ clientmessage(XEvent *e)
                || cme->data.l[2] == netatom[NetWMFullscreen])
                        setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD    */
                                || (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen)));
-       } else if (cme->message_type == netatom[NetActiveWindow]) {
-//             /* cme->data.l[0] == 2 means it came from an external pager/script like wmctrl */
-        if (cme->data.l[0] == 2) {
-            /* --- NATIVE TAG, MONITOR, AND MOUSE JUMP ON ACTIVATION --- */
-            selmon = c->mon;
-            if (!(c->tags & selmon->tagset[selmon->seltags])) {
-                view(&(Arg){ .ui = c->tags });
-            }
-            focus(c);
-            restack(selmon);
+    } else if (cme->message_type == netatom[NetActiveWindow]) {
+        /* cme->data.l[0] == 2 means it came from an external pager/script like wmctrl */
+               if (cme->data.l[0] == 2) {
+                       /* --- SAFE CROSS-MONITOR ACTIVATION --- */
+                       if (c->mon != selmon) {
+                               unfocus(selmon->sel, 0);
+                               selmon = c->mon;
+                       }
+                       if (!(c->tags & selmon->tagset[selmon->seltags])) {
+                               view(&(Arg){ .ui = c->tags });
+                       }
 
-            /* Optional: Warp cursor to the center of the target monitor */
-            XWarpPointer(dpy, None, root, 0, 0, 0, 0,
-                         selmon->wx + selmon->ww / 2,
-                         selmon->wy + selmon->wh / 2);
-            /* ------------------------------------------------------- */
+                       /* Warp pointer first to prevent focus-follows-mouse race conditions */
+                       XWarpPointer(dpy, None, root, 0, 0, 0, 0,
+                                    selmon->wx + selmon->ww / 2,
+                                    selmon->wy + selmon->wh / 2);
 
-        } else if (c != selmon->sel && !c->isurgent)
+                       focus(c);
+                       XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
+                       restack(selmon);
+                       /* ------------------------------------- */
+               } else if (c != selmon->sel && !c->isurgent)
                        seturgent(c, 1);
        }
 }
diff --git a/dwm.o b/dwm.o
index ab42e77222eefffdb38a70c64f4fa8baff240949..265338e59e73bf78fd5111349466e80a5050f56d 100644 (file)
Binary files a/dwm.o and b/dwm.o differ