[wiki] [sites] [dwm][patch][warp] fix unwanted change of stack order || Jonas Dujava

From: <git_AT_suckless.org>
Date: Fri, 26 May 2023 23:20:30 +0200

commit 98d3275eb3dc2316531cf2d5e0857edec05ffd84
Author: Jonas Dujava <jonas.dujava_AT_gmail.com>
Date: Fri May 26 23:12:30 2023 +0200

    [dwm][patch][warp] fix unwanted change of stack order

diff --git a/dwm.suckless.org/patches/warp/dwm-warp-6.4.diff b/dwm.suckless.org/patches/warp/dwm-warp-6.4.diff
new file mode 100644
index 00000000..02fcdba1
--- /dev/null
+++ b/dwm.suckless.org/patches/warp/dwm-warp-6.4.diff
_AT_@ -0,0 +1,79 @@
+From a229c36f51ad6f8b40109ed53c643f242351962a Mon Sep 17 00:00:00 2001
+From: Jonas Dujava <jonas.dujava_AT_gmail.com>
+Date: Fri, 26 May 2023 22:14:48 +0200
+Subject: [PATCH] Warp patch
+
+Warps the mouse cursor to the center of the currently focused
+window or screen when the mouse cursor is
+ (a) on a different screen, or
+ (b) on top of a different window.
+
+This version properly handles warping to windows that have not been
+mapped yet (before it resulted in a change of the stack order).
+See the discussion in (thanks goes to Bakkeby):
+ https://github.com/bakkeby/patches/issues/60
+---
+ dwm.c | 26 ++++++++++++++++++++++++++
+ 1 file changed, 26 insertions(+)
+
+diff --git a/dwm.c b/dwm.c
+index e5efb6a..7ea6c14 100644
+--- a/dwm.c
++++ b/dwm.c
+_AT_@ -228,6 +228,7 @@ static void updatetitle(Client *c);
+ static void updatewindowtype(Client *c);
+ static void updatewmhints(Client *c);
+ static void view(const Arg *arg);
++static void warp(const Client *c);
+ static Client *wintoclient(Window w);
+ static Monitor *wintomon(Window w);
+ static int xerror(Display *dpy, XErrorEvent *ee);
+_AT_@ -834,6 +835,7 @@ focusmon(const Arg *arg)
+ unfocus(selmon->sel, 0);
+ selmon = m;
+ focus(NULL);
++ warp(selmon->sel);
+ }
+
+ void
+_AT_@ -1366,6 +1368,8 @@ restack(Monitor *m)
+ wc.sibling = c->win;
+ }
+ }
++ if (m == selmon && (m->tagset[m->seltags] & m->sel->tags) && m->lt[m->sellt]->arrange != &monocle)
++ warp(m->sel);
+ XSync(dpy, False);
+ while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
+ }
+_AT_@ -2044,6 +2048,28 @@ view(const Arg *arg)
+ arrange(selmon);
+ }
+
++void
++warp(const Client *c)
++{
++ int x, y;
++
++ if (!c) {
++ XWarpPointer(dpy, None, root, 0, 0, 0, 0, selmon->wx + selmon->ww / 2, selmon->wy + selmon->wh / 2);
++ return;
++ }
++
++ if (!getrootptr(&x, &y) ||
++ (x > c->x - c->bw &&
++ y > c->y - c->bw &&
++ x < c->x + c->w + c->bw*2 &&
++ y < c->y + c->h + c->bw*2) ||
++ (y > c->mon->by && y < c->mon->by + bh) ||
++ (c->mon->topbar && !y))
++ return;
++
++ XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w / 2, c->h / 2);
++}
++
+ Client *
+ wintoclient(Window w)
+ {
+--
+2.40.1
+
diff --git a/dwm.suckless.org/patches/warp/index.md b/dwm.suckless.org/patches/warp/index.md
index 7fbe3e02..d5900149 100644
--- a/dwm.suckless.org/patches/warp/index.md
+++ b/dwm.suckless.org/patches/warp/index.md
_AT_@ -4,14 +4,16 @@ warp
 Description
 -----------
 This patch warps the mouse cursor to the center of the currently focused window
-or screen when the mouse cursor is (a) on a different screen or (b) on top of a
-different window.
+or screen when the mouse cursor is
+ (a) on a different screen, or
+ (b) on top of a different window.
 
 Download
 --------
 * [dwm-warp-5.9.diff](dwm-warp-5.9.diff) (20111028)
 * [dwm-warp-6.1.diff](dwm-warp-6.1.diff) (20151215)
 * [dwm-warp-6.2.diff](dwm-warp-6.2.diff)
+* [dwm-warp-6.4.diff](dwm-warp-6.4.diff)
 
 Author
 ------
_AT_@ -19,3 +21,4 @@ Author
 * Enno Boland (Gottox)
 * [Jochen Sprickerhof](mailto:project_AT_firstname.lastname.de) (don't warp in monocle)
 * Winston Weinert (winny) <winston_AT_ml1.net>
+* Jonáš Dujava - (6.4, fixed the unwanted change of the stack order)
Received on Fri May 26 2023 - 23:20:30 CEST

This archive was generated by hypermail 2.3.0 : Fri May 26 2023 - 23:24:56 CEST