dwm-cursorwarp-6.3.diff (1240B)
1 From 94362c75d92a77d11dfbfecce89394b2e0078cd0 Mon Sep 17 00:00:00 2001 2 From: Finn Rayment <finn@rayment.fr> 3 Date: Sun, 21 Aug 2022 13:56:50 +1000 4 Subject: [PATCH] Added cursor warp for refocus and window spawn/death 5 6 --- 7 dwm.c | 8 ++++++++ 8 1 file changed, 8 insertions(+) 9 10 diff --git a/dwm.c b/dwm.c 11 index a96f33c..f0e8a39 100644 12 --- a/dwm.c 13 +++ b/dwm.c 14 @@ -831,6 +831,8 @@ focusmon(const Arg *arg) 15 unfocus(selmon->sel, 0); 16 selmon = m; 17 focus(NULL); 18 + if (selmon->sel) 19 + XWarpPointer(dpy, None, selmon->sel->win, 0, 0, 0, 0, selmon->sel->w/2, selmon->sel->h/2); 20 } 21 22 void 23 @@ -856,6 +858,7 @@ focusstack(const Arg *arg) 24 if (c) { 25 focus(c); 26 restack(selmon); 27 + XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w/2, c->h/2); 28 } 29 } 30 31 @@ -1077,6 +1080,8 @@ manage(Window w, XWindowAttributes *wa) 32 c->mon->sel = c; 33 arrange(c->mon); 34 XMapWindow(dpy, c->win); 35 + if (c && c->mon == selmon) 36 + XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w/2, c->h/2); 37 focus(NULL); 38 } 39 40 @@ -1788,6 +1793,9 @@ unmanage(Client *c, int destroyed) 41 focus(NULL); 42 updateclientlist(); 43 arrange(m); 44 + if (m == selmon && m->sel) 45 + XWarpPointer(dpy, None, m->sel->win, 0, 0, 0, 0, 46 + m->sel->w/2, m->sel->h/2); 47 } 48 49 void 50 -- 51 2.35.1 52