>From e38f170245c0c4b56fafe57661aebeac87b06182 Mon Sep 17 00:00:00 2001
From: Ioan Moldovan <[email protected]>
Date: Thu, 3 Jul 2014 20:50:15 +0300
Subject: [PATCH] This patch optimizes resizing by deviding the window in 9
rectangles (4 for corners, 4 for middles, 1 useless) (The corner rectangles
are used for diagonal resizing, the middle ones are used for resizing Up,
Down, Left and Right and the one in the middle of the the window is not used)
---
src/moveres.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/src/moveres.c b/src/moveres.c
index 6754be2..232e395 100644
--- a/src/moveres.c
+++ b/src/moveres.c
@@ -1806,13 +1806,23 @@ static int getResizeDirection(WWindow * wwin, int x,
int y, int dx, int dy, int
/* if not resizing through the resizebar */
if (!(flags & RESIZEBAR)) {
+
int xdir = (abs(x) < (wwin->client.width / 2)) ? LEFT : RIGHT;
int ydir = (abs(y) < (wwin->client.height / 2)) ? UP : DOWN;
- if (abs(dx) < 2 || abs(dy) < 2) {
- if (abs(dy) > abs(dx))
- xdir = 0;
- else
- ydir = 0;
+
+ // How much resize space is allowed
+ int spacew = abs(wwin->client.width / 3);
+ int spaceh = abs(wwin->client.height / 3);
+
+ // Determine where x fits
+ if ((abs(x) > wwin->client.width/2 - spacew/2) && (abs(x) <
wwin->client.width/2 + spacew/2))
+ {
+ // Resize y
+ xdir = 0;
+ } else if ((abs(y) > wwin->client.height/2 - spaceh/2) &&
(abs(y) < wwin->client.height/2 + spaceh/2))
+ {
+ // Resize x
+ ydir = 0;
}
return (xdir | ydir);
}
--
1.8.5.5