From 89295b91fb72c1fbf32c99012499b633f2f91ca3 Mon Sep 17 00:00:00 2001 From: Ioan Moldovan Date: Sat, 19 Jul 2014 18:50:43 +0200 Subject: [PATCH] wmaker: improve the behaviour of window resizing by user 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 6754be2c..3d707d74 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); }