From: Ioan Moldovan <[email protected]>
The original behaviour was a bit frustrating because it used the first
small mouse move to deduce the user's wished direction, but that is a bit
imprecise.
This patch divides the window in 9 rectangles:
- 4 for corners, used for diagonal resizing
- 4 for middles of sides, for resizing Up, Down, Left and Right
- 1 useless in the middle of the the window, which falls back on diagonal
resizing
This leads to a more predictive behaviour.
---
src/moveres.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/src/moveres.c b/src/moveres.c
index 6754be2..3d707d7 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 vertically */
+ xdir = 0;
+ } else if ((abs(y) > wwin->client.height/2 - spaceh/2) &&
+ (abs(y) < wwin->client.height/2 + spaceh/2)) {
+ /* Resize horizontally */
+ ydir = 0;
}
return (xdir | ydir);
}
--
2.0.1
--
To unsubscribe, send mail to [email protected].