1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-27 08:52:30 +01:00

autoPlaceWindow: rewrite iteration to more comprehensible form

This commit is contained in:
Yuri Karaban
2014-04-12 18:55:55 +03:00
committed by Carlos R. Mafra
parent a7471fd82a
commit b1a67e4bc7

View File

@@ -423,30 +423,27 @@ center_place_window(WWindow *wwin, int *x_ret, int *y_ret,
static Bool static Bool
autoPlaceWindow(WWindow *wwin, int *x_ret, int *y_ret, autoPlaceWindow(WWindow *wwin, int *x_ret, int *y_ret,
unsigned int width, unsigned int height, int tryCount, WArea usableArea) unsigned int width, unsigned int height,
int tryCount, WArea usableArea)
{ {
WScreen *scr = wwin->screen_ptr; WScreen *scr = wwin->screen_ptr;
int test_x = 0, test_y = Y_ORIGIN; int x, y;
int swidth, sx; int sw, sh;
set_width_height(wwin, &width, &height); set_width_height(wwin, &width, &height);
swidth = usableArea.x2 - usableArea.x1; sw = usableArea.x2 - usableArea.x1;
sx = X_ORIGIN; sh = usableArea.y2 - usableArea.y1;
/* this was based on fvwm2's smart placement */ /* this was based on fvwm2's smart placement */
while (((test_y + height) < (usableArea.y2 - usableArea.y1))) { for (y = Y_ORIGIN; (y + height) < sh; y += PLACETEST_VSTEP) {
test_x = sx; for (x = X_ORIGIN; (x + width) < sw; x += PLACETEST_HSTEP) {
if (screen_has_space(scr, x, y,
while (((test_x + width) < swidth)) {
if (screen_has_space(scr, test_x, test_y,
width, height, tryCount)) { width, height, tryCount)) {
*x_ret = test_x; *x_ret = x;
*y_ret = test_y; *y_ret = y;
return True; return True;
} }
test_x += PLACETEST_HSTEP;
} }
test_y += PLACETEST_VSTEP;
} }
return False; return False;