commit 8c48ad24c802e0449ad6cc374b97bbbbb35da233
Author: Winston Weinert <[email protected]>
Date:   Tue Dec 15 19:28:28 2015 -0600

    Fix dwm warp patch and rewrite description
    
    Here are the improvements made:
    
    1. If mouse cursor is on focused window's border, it'll warp to window
    center anyway
    
    2. If topbar = 1 and mouse cursor is touching the screen's top edge,
    it'll warp to the window center anyway
    
    I additionally cleaned up a few lines of code.

diff --git a/dwm.suckless.org/patches/dwm-6.1-warp.diff 
b/dwm.suckless.org/patches/dwm-6.1-warp.diff
index dd758e4..c7f017c 100644
--- a/dwm.suckless.org/patches/dwm-6.1-warp.diff
+++ b/dwm.suckless.org/patches/dwm-6.1-warp.diff
@@ -1,8 +1,7 @@
-diff --git a/dwm.c b/dwm.c
-index 0362114..d975c68 100644
---- a/dwm.c
-+++ b/dwm.c
-@@ -227,6 +227,7 @@ static void updatewindowtype(Client *c);
+diff -ruN dwm-6.1-orig/dwm.c dwm-6.1/dwm.c
+--- dwm-6.1-orig/dwm.c 2015-11-08 16:39:37.000000000 -0600
++++ dwm-6.1/dwm.c      2015-12-14 19:17:19.656091228 -0600
+@@ -227,6 +227,7 @@
  static void updatetitle(Client *c);
  static void updatewmhints(Client *c);
  static void view(const Arg *arg);
@@ -10,7 +9,7 @@ index 0362114..d975c68 100644
  static Client *wintoclient(Window w);
  static Monitor *wintomon(Window w);
  static int xerror(Display *dpy, XErrorEvent *ee);
-@@ -840,6 +841,7 @@ focusmon(const Arg *arg)
+@@ -840,6 +841,7 @@
                                        in gedit and anjuta */
        selmon = m;
        focus(NULL);
@@ -18,7 +17,7 @@ index 0362114..d975c68 100644
  }
  
  void
-@@ -1384,6 +1386,8 @@ restack(Monitor *m)
+@@ -1384,6 +1386,8 @@
        }
        XSync(dpy, False);
        while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
@@ -27,26 +26,27 @@ index 0362114..d975c68 100644
  }
  
  void
-@@ -2040,6 +2044,27 @@ view(const Arg *arg)
+@@ -2040,6 +2044,28 @@
        arrange(selmon);
  }
  
 +void
 +warp(const Client *c)
 +{
-+      Window dummy;
-+      int x, y, di;
-+      unsigned int dui;
++      int x, y;
 +
 +      if (!c) {
-+              XWarpPointer(dpy, None, root, 0, 0, 0, 0, selmon->wx + 
selmon->ww / 2, selmon->wy + selmon->wh/2);
++              XWarpPointer(dpy, None, root, 0, 0, 0, 0, selmon->wx + 
selmon->ww/2, selmon->wy + selmon->wh/2);
 +              return;
 +      }
 +
-+      XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui);
-+
-+      if ((x > c->x && y > c->y && x < c->x + c->w && y < c->y + c->h) ||
-+         (y > c->mon->by && y < c->mon->by + bh))
++      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);
diff --git a/dwm.suckless.org/patches/warp.md b/dwm.suckless.org/patches/warp.md
index c4f4d70..7167804 100644
--- a/dwm.suckless.org/patches/warp.md
+++ b/dwm.suckless.org/patches/warp.md
@@ -4,14 +4,15 @@ warp
 Description
 -----------
 
-This patch warps the mouse cursor each time another window gets focused to the
-middle of the window.
+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.
 
 Download
 --------
 
 * [dwm-5.9-warp.diff](dwm-5.9-warp.diff) (20111028)
-* [dwm-6.1-warp.diff](dwm-6.1-warp.diff) (20151109)
+* [dwm-6.1-warp.diff](dwm-6.1-warp.diff) (20151215)
 
 Author
 ------
@@ -19,3 +20,4 @@ Author
 * Evan Gates (emg) <[email protected]>
 * Enno Boland (Gottox)
 * Jochen Sprickerhof
+* Winston Weinert (winny) <[email protected]>


Reply via email to