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

index acb14fb537ac24544eb30cb050de05b67b18155e..9bc0e219536d29b8067e2a04383dfe5fd6d7af54 100644 (file)
@@ -179,6 +179,7 @@ static const char *ffsrecstopcmd[]  = { "/usr/local/bin/ffsrec-stop-recording",
 static const char *wakeupcmd[]  = { "/usr/local/bin/wake-up", "toggle", NULL };
 static const char *calendarcmd[]  = { "/usr/local/bin/dwm-calendar", NULL };
 static const char *windowcontainercmd[]  = { "/usr/local/bin/dwm-window-container-toggle", NULL };
+static const char *gotowindowcmd[]  = { "/usr/local/bin/dwm-goto-window", NULL };
 
 static const Key keys[] = {
        /* modifier                     key        function        argument */
@@ -196,7 +197,8 @@ static const Key keys[] = {
        { MODKEY|ShiftMask,             XK_m,      spawn,          {.v = cpucmd } },
        // { MODKEY,                       XK_e,      spawn,          {.v = calc_mccw_cmd } },
        // { MODKEY|ControlMask,           XK_e,      spawn,          {.v = calc_mcw_cmd } },
-    { MODKEY,                       XK_o,      focuscalculator, {0} },
+    { MODKEY,                       XK_c,      focuscalculator, {0} },
+    { MODKEY,                       XK_o,      spawn,          {.v = gotowindowcmd} },
        { MODKEY|ShiftMask,             XK_f,      spawn,          {.v = facecamcmd } },
        { MODKEY|ShiftMask,             XK_b,      spawn,          {.v = brightnesscmd} },
        { MODKEY|ShiftMask,             XK_p,      spawn,          {.v = calendarcmd} },
index acb14fb537ac24544eb30cb050de05b67b18155e..9bc0e219536d29b8067e2a04383dfe5fd6d7af54 100644 (file)
--- a/config.h
+++ b/config.h
@@ -179,6 +179,7 @@ static const char *ffsrecstopcmd[]  = { "/usr/local/bin/ffsrec-stop-recording",
 static const char *wakeupcmd[]  = { "/usr/local/bin/wake-up", "toggle", NULL };
 static const char *calendarcmd[]  = { "/usr/local/bin/dwm-calendar", NULL };
 static const char *windowcontainercmd[]  = { "/usr/local/bin/dwm-window-container-toggle", NULL };
+static const char *gotowindowcmd[]  = { "/usr/local/bin/dwm-goto-window", NULL };
 
 static const Key keys[] = {
        /* modifier                     key        function        argument */
@@ -196,7 +197,8 @@ static const Key keys[] = {
        { MODKEY|ShiftMask,             XK_m,      spawn,          {.v = cpucmd } },
        // { MODKEY,                       XK_e,      spawn,          {.v = calc_mccw_cmd } },
        // { MODKEY|ControlMask,           XK_e,      spawn,          {.v = calc_mcw_cmd } },
-    { MODKEY,                       XK_o,      focuscalculator, {0} },
+    { MODKEY,                       XK_c,      focuscalculator, {0} },
+    { MODKEY,                       XK_o,      spawn,          {.v = gotowindowcmd} },
        { MODKEY|ShiftMask,             XK_f,      spawn,          {.v = facecamcmd } },
        { MODKEY|ShiftMask,             XK_b,      spawn,          {.v = brightnesscmd} },
        { MODKEY|ShiftMask,             XK_p,      spawn,          {.v = calendarcmd} },
diff --git a/dwm b/dwm
index 78f5eeab6d1bc2e1678a994120b4101408e3dded..3f6f18e39b18c7b835efc7ae6979c5fa409f6fe5 100755 (executable)
Binary files a/dwm and b/dwm differ
diff --git a/dwm.c b/dwm.c
index 578ccf0b86583e4cd6f25236f824b62acc1cd666..5ad38e4e1fc953e39774c9507b5ac30b00083770 100644 (file)
--- a/dwm.c
+++ b/dwm.c
@@ -1100,11 +1100,62 @@ clientmessage(XEvent *e)
                        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]) {
-               if (c != selmon->sel && !c->isurgent)
+//             /* 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);
+
+            /* 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);
+            /* ------------------------------------------------------- */
+
+        } else if (c != selmon->sel && !c->isurgent)
                        seturgent(c, 1);
        }
 }
 
+// void
+// clientmessage(XEvent *e)
+// {
+//     XClientMessageEvent *cme = &e->xclient;
+//     Client *c = wintoclient(cme->window);
+
+//     if (!c)
+//             return;
+//     if (cme->message_type == netatom[NetWMState]) {
+//             if (cme->data.l[1] == netatom[NetWMFullscreen]
+//             || 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 || c->switchto) {
+//                     selmon = c->mon;
+//                     if (!(c->tags & selmon->tagset[selmon->seltags])) {
+//                             view(&(Arg){ .ui = c->tags });
+//                     }
+//                     focus(c);
+//                     restack(selmon);
+
+//                     XWarpPointer(dpy, None, root, 0, 0, 0, 0,
+//                                  selmon->wx + selmon->ww / 2,
+//                                  selmon->wy + selmon->wh / 2);
+//             c->switchto = 0;
+//             } else {
+//                     /* App launch when switchto is false: focus quietly without moving tags */
+//                     focus(c);
+//                     restack(selmon);
+//             }
+//     }
+// }
+
 void
 configure(Client *c)
 {
diff --git a/dwm.o b/dwm.o
index 42f27b55be1cf0d8234adef74356e3df513ed147..ab42e77222eefffdb38a70c64f4fa8baff240949 100644 (file)
Binary files a/dwm.o and b/dwm.o differ