added cursorwarp patch

This commit is contained in:
Victor Ișan 2026-07-07 18:55:05 +02:00
parent 6736ef661d
commit 358147ecec
2 changed files with 60 additions and 0 deletions

8
dwm.c
View File

@ -926,6 +926,8 @@ focusmon(const Arg *arg)
unfocus(selmon->sel, 0); unfocus(selmon->sel, 0);
selmon = m; selmon = m;
focus(NULL); focus(NULL);
if (selmon->sel)
XWarpPointer(dpy, None, selmon->sel->win, 0, 0, 0, 0, selmon->sel->w/2, selmon->sel->h/2);
} }
void void
@ -951,6 +953,7 @@ focusstack(const Arg *arg)
if (c) { if (c) {
focus(c); focus(c);
restack(selmon); restack(selmon);
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w/2, c->h/2);
} }
} }
@ -1181,6 +1184,8 @@ manage(Window w, XWindowAttributes *wa)
c->mon->sel = c; c->mon->sel = c;
arrange(c->mon); arrange(c->mon);
XMapWindow(dpy, c->win); XMapWindow(dpy, c->win);
if (c && c->mon == selmon)
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w/2, c->h/2);
if (term) if (term)
swallow(term, c); swallow(term, c);
focus(NULL); focus(NULL);
@ -1931,6 +1936,9 @@ unmanage(Client *c, int destroyed)
arrange(m); arrange(m);
focus(NULL); focus(NULL);
updateclientlist(); updateclientlist();
if (m == selmon && m->sel)
XWarpPointer(dpy, None, m->sel->win, 0, 0, 0, 0,
m->sel->w/2, m->sel->h/2);
} }
} }

View File

@ -0,0 +1,52 @@
From 94362c75d92a77d11dfbfecce89394b2e0078cd0 Mon Sep 17 00:00:00 2001
From: Finn Rayment <finn@rayment.fr>
Date: Sun, 21 Aug 2022 13:56:50 +1000
Subject: [PATCH] Added cursor warp for refocus and window spawn/death
---
dwm.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/dwm.c b/dwm.c
index a96f33c..f0e8a39 100644
--- a/dwm.c
+++ b/dwm.c
@@ -831,6 +831,8 @@ focusmon(const Arg *arg)
unfocus(selmon->sel, 0);
selmon = m;
focus(NULL);
+ if (selmon->sel)
+ XWarpPointer(dpy, None, selmon->sel->win, 0, 0, 0, 0, selmon->sel->w/2, selmon->sel->h/2);
}
void
@@ -856,6 +858,7 @@ focusstack(const Arg *arg)
if (c) {
focus(c);
restack(selmon);
+ XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w/2, c->h/2);
}
}
@@ -1077,6 +1080,8 @@ manage(Window w, XWindowAttributes *wa)
c->mon->sel = c;
arrange(c->mon);
XMapWindow(dpy, c->win);
+ if (c && c->mon == selmon)
+ XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w/2, c->h/2);
focus(NULL);
}
@@ -1788,6 +1793,9 @@ unmanage(Client *c, int destroyed)
focus(NULL);
updateclientlist();
arrange(m);
+ if (m == selmon && m->sel)
+ XWarpPointer(dpy, None, m->sel->win, 0, 0, 0, 0,
+ m->sel->w/2, m->sel->h/2);
}
void
--
2.35.1