[hackers] [dwm] [PATCH] Don't restrict snap in mousemove

From: Markus Teich <markus.teich_AT_stusta.mhn.de>
Date: Thu, 5 Jan 2017 13:16:44 +0100

This also fixes a bug where client windows only switch to floating mode when the
mouse is dragged in one specific direction.
---
Heyho,
this patch basically reverts 71365a[0] from 2008. I could not find a reasonable
explanation in the git log why this old patch was introduced and in the current
master it has a negative side effect. When dragging a client from tiling mode it
should change to floating mode after a movement of `snap` pixels. However
sometimes this only worked when dragging the window in a specific direction
while I feel it should work when dragging the window in any of the 4 directions.
0: http://git.suckless.org/dwm/commit/?id=71365a524f67235024de7db277c63f8ac4f46569
--Markus
 dwm.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/dwm.c b/dwm.c
index d27cb67..c1e09b5 100644
--- a/dwm.c
+++ b/dwm.c
_AT_@ -1170,20 +1170,17 @@ movemouse(const Arg *arg)
 
 			nx = ocx + (ev.xmotion.x - x);
 			ny = ocy + (ev.xmotion.y - y);
-			if (nx >= selmon->wx && nx <= selmon->wx + selmon->ww
-			&& ny >= selmon->wy && ny <= selmon->wy + selmon->wh) {
-				if (abs(selmon->wx - nx) < snap)
-					nx = selmon->wx;
-				else if (abs((selmon->wx + selmon->ww) - (nx + WIDTH(c))) < snap)
-					nx = selmon->wx + selmon->ww - WIDTH(c);
-				if (abs(selmon->wy - ny) < snap)
-					ny = selmon->wy;
-				else if (abs((selmon->wy + selmon->wh) - (ny + HEIGHT(c))) < snap)
-					ny = selmon->wy + selmon->wh - HEIGHT(c);
-				if (!c->isfloating && selmon->lt[selmon->sellt]->arrange
-				&& (abs(nx - c->x) > snap || abs(ny - c->y) > snap))
-					togglefloating(NULL);
-			}
+			if (abs(selmon->wx - nx) < snap)
+				nx = selmon->wx;
+			else if (abs((selmon->wx + selmon->ww) - (nx + WIDTH(c))) < snap)
+				nx = selmon->wx + selmon->ww - WIDTH(c);
+			if (abs(selmon->wy - ny) < snap)
+				ny = selmon->wy;
+			else if (abs((selmon->wy + selmon->wh) - (ny + HEIGHT(c))) < snap)
+				ny = selmon->wy + selmon->wh - HEIGHT(c);
+			if (!c->isfloating && selmon->lt[selmon->sellt]->arrange
+			&& (abs(nx - c->x) > snap || abs(ny - c->y) > snap))
+				togglefloating(NULL);
 			if (!selmon->lt[selmon->sellt]->arrange || c->isfloating)
 				resize(c, nx, ny, c->w, c->h, 1);
 			break;
-- 
2.10.2
Received on Thu Jan 05 2017 - 13:16:44 CET

This archive was generated by hypermail 2.3.0 : Thu Jan 05 2017 - 13:24:18 CET