1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-22 05:48:01 +01:00

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.
This commit is contained in:
Ioan Moldovan
2014-07-19 18:50:43 +02:00
committed by Carlos R. Mafra
parent 029846dd14
commit 89295b91fb

View File

@@ -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 not resizing through the resizebar */
if (!(flags & RESIZEBAR)) { if (!(flags & RESIZEBAR)) {
int xdir = (abs(x) < (wwin->client.width / 2)) ? LEFT : RIGHT; int xdir = (abs(x) < (wwin->client.width / 2)) ? LEFT : RIGHT;
int ydir = (abs(y) < (wwin->client.height / 2)) ? UP : DOWN; int ydir = (abs(y) < (wwin->client.height / 2)) ? UP : DOWN;
if (abs(dx) < 2 || abs(dy) < 2) {
if (abs(dy) > abs(dx)) /* How much resize space is allowed */
xdir = 0; int spacew = abs(wwin->client.width / 3);
else int spaceh = abs(wwin->client.height / 3);
ydir = 0;
/* 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); return (xdir | ydir);
} }