commit 9897d9d9dd955ecc1172b8cc89457aae48fc8024
parent 4946d89409a1a7ee1415e96a0dfebfcebea34d4f
Author: Moritz Wilhelmy <moritz plus suckless at wzff dot de>
Date: Sat, 11 Sep 2010 22:11:25 +0200
dwm: added warp patch from dwm-gtx
Diffstat:
2 files changed, 123 insertions(+), 0 deletions(-)
diff --git a/dwm.suckless.org/patches/dwm-r1525-warp.diff b/dwm.suckless.org/patches/dwm-r1525-warp.diff
@@ -0,0 +1,99 @@
+diff -r c361034c5a1c dwm.c
+--- a/dwm.c Sat Sep 11 19:00:18 2010 +0000
++++ b/dwm.c Sat Sep 11 21:47:56 2010 +0200
+@@ -236,6 +236,7 @@
+ static void updatetitle(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);
+@@ -274,6 +275,7 @@
+ static DC dc;
+ static Monitor *mons = NULL, *selmon = NULL;
+ static Window root;
++static Bool warpmouse = True;
+
+ /* configuration, allows nested code to access above variables */
+ #include "config.h"
+@@ -452,10 +454,12 @@
+ focus(c);
+ click = ClkClientWin;
+ }
++ warpmouse = False;
+ for(i = 0; i < LENGTH(buttons); i++)
+ if(click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button
+ && CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state))
+ buttons[i].func(click == ClkTagBar && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg);
++ warpmouse = True;
+ }
+
+ void
+@@ -854,6 +858,7 @@
+ unfocus(selmon->sel, True);
+ selmon = m;
+ focus(NULL);
++ warp(selmon->sel);
+ }
+
+ void
+@@ -879,6 +884,7 @@
+ if(c) {
+ focus(c);
+ restack(selmon);
++ warp(c);
+ }
+ }
+
+@@ -1150,6 +1156,7 @@
+ XMapWindow(dpy, c->win);
+ setclientstate(c, NormalState);
+ arrange(c->mon);
++ warp(c);
+ }
+
+ void
+@@ -1609,6 +1616,7 @@
+ if(selmon->sel && arg->ui & TAGMASK) {
+ selmon->sel->tags = arg->ui & TAGMASK;
+ arrange(selmon);
++ warp(selmon->sel);
+ }
+ }
+
+@@ -1689,6 +1697,7 @@
+ if(newtags) {
+ selmon->sel->tags = newtags;
+ arrange(selmon);
++ warp(selmon->sel);
+ }
+ }
+
+@@ -1962,6 +1971,26 @@
+ arrange(selmon);
+ }
+
++void
++warp(const Client *c) {
++ Window dummy;
++ int x, y, di;
++ unsigned int dui;
++
++ if(!c || !warpmouse)
++ return;
++ XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui);
++ if(x > c->x && y > c->y && x < c->y + c->w && y < c->y + c->h)
++ return;
++ XSelectInput(dpy, root, SubstructureRedirectMask
++ & EnterWindowMask);
++ XWarpPointer(dpy, None, c->win, 0, 0, 0, 0,
++ c->w / 2, c->h / 2);
++ XSelectInput(dpy, root, SubstructureRedirectMask | SubstructureNotifyMask
++ | EnterWindowMask | LeaveWindowMask | StructureNotifyMask);
++}
++
++
+ Client *
+ wintoclient(Window w) {
+ Client *c;
diff --git a/dwm.suckless.org/patches/warp.md b/dwm.suckless.org/patches/warp.md
@@ -0,0 +1,24 @@
+WARP
+====
+
+Description
+-----------
+
+This patch warps the mouse cursor each time another window gets focused to the
+middle of the window. It was shamelessly copied by me from dwm-gtx 5.2 without
+any modifications except those to make it work on newer vanilla-dwm.
+
+Download
+--------
+
+* [dwm-r1525-warp.diff](dwm-r1525-warp.diff) (2.3k) (20100911)
+
+Author
+------
+
+* Enno Boland (Gottox)
+
+Contributor
+-----------
+
+* Moritz Wilhelmy (n0nsense) <moritz plus dwm at wzff dot de>