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

- Fixed compilation warnings.

- Readded 'Auto placement' mode, with the old behavior, and made
  'Smart placement' mode behave in the new way.
  Auto and Smart are no longer aliases.
This commit is contained in:
dan
1999-09-17 16:18:37 +00:00
parent a66bff850c
commit ac64e68fcb
6 changed files with 135 additions and 6 deletions

View File

@@ -43,6 +43,8 @@ Changes since version 0.60.0:
- fixed crash when more than 1 dockapp fails to launch on startup - fixed crash when more than 1 dockapp fails to launch on startup
- added a different dock setup config for each screen size - added a different dock setup config for each screen size
- fixed PPosition handling - fixed PPosition handling
- New "Smart placement" mode. 'Smart' is no longer an alias to 'Auto' but
a different mode of placing windows. 'Auto' keeps the old behavior.
Changes since version 0.53.0: Changes since version 0.53.0:

View File

@@ -76,7 +76,8 @@ static char *placements[] = {
"auto", "auto",
"random", "random",
"manual", "manual",
"cascade" "cascade",
"smart"
}; };
@@ -126,7 +127,7 @@ getPlacement(char *str)
if (!str) if (!str)
return 0; return 0;
if (strcasecmp(str, "auto")==0 || strcasecmp(str, "smart")==0) if (strcasecmp(str, "auto")==0)
return 0; return 0;
else if (strcasecmp(str, "random")==0) else if (strcasecmp(str, "random")==0)
return 1; return 1;
@@ -134,6 +135,8 @@ getPlacement(char *str)
return 2; return 2;
else if (strcasecmp(str, "cascade")==0) else if (strcasecmp(str, "cascade")==0)
return 3; return 3;
else if (strcasecmp(str, "smart")==0)
return 4;
else else
wwarning(_("bad option value %s in WindowPlacement. Using default value"), wwarning(_("bad option value %s in WindowPlacement. Using default value"),
str); str);
@@ -241,6 +244,7 @@ createPanel(Panel *p)
WMAddPopUpButtonItem(panel->placP, _("Random")); WMAddPopUpButtonItem(panel->placP, _("Random"));
WMAddPopUpButtonItem(panel->placP, _("Manual")); WMAddPopUpButtonItem(panel->placP, _("Manual"));
WMAddPopUpButtonItem(panel->placP, _("Cascade")); WMAddPopUpButtonItem(panel->placP, _("Cascade"));
WMAddPopUpButtonItem(panel->placP, _("Smart"));
panel->porigL = WMCreateLabel(panel->placF); panel->porigL = WMCreateLabel(panel->placF);
WMResizeWidget(panel->porigL, 120, 32); WMResizeWidget(panel->porigL, 120, 32);

View File

@@ -147,6 +147,7 @@ typedef enum {
#define WPM_CASCADE 1 #define WPM_CASCADE 1
#define WPM_SMART 2 #define WPM_SMART 2
#define WPM_RANDOM 3 #define WPM_RANDOM 3
#define WPM_AUTO 4
/* text justification */ /* text justification */
#define WTJ_CENTER 0 #define WTJ_CENTER 0

View File

@@ -231,7 +231,7 @@ static WOptionEnumeration seColormapModes[] = {
}; };
static WOptionEnumeration sePlacements[] = { static WOptionEnumeration sePlacements[] = {
{"Auto", WPM_SMART, 0}, {"Smart", WPM_SMART, 1}, {"Auto", WPM_AUTO, 0}, {"Smart", WPM_SMART, 0},
{"Cascade", WPM_CASCADE, 0}, {"Cascade", WPM_CASCADE, 0},
{"Random", WPM_RANDOM, 0}, {"Random", WPM_RANDOM, 0},
{"Manual", WPM_MANUAL, 0}, {"Manual", WPM_MANUAL, 0},

View File

@@ -412,6 +412,118 @@ smartPlaceWindow(WWindow *wwin, int *x_ret, int *y_ret,
} }
static Bool
autoPlaceWindow(WWindow *wwin, int *x_ret, int *y_ret,
unsigned int width, unsigned int height, int tryCount)
{
WScreen *scr = wwin->screen_ptr;
int test_x = 0, test_y = Y_ORIGIN(scr);
int loc_ok = False, tw,tx,ty,th;
int swidth, sx;
WWindow *test_window;
int extra_height;
WArea usableArea = scr->totalUsableArea;
if (wwin->frame)
extra_height = wwin->frame->top_width + wwin->frame->bottom_width + 2;
else
extra_height = 24; /* random value */
swidth = usableArea.x2-usableArea.x1;
sx = X_ORIGIN(scr);
/* this was based on fvwm2's smart placement */
height += extra_height;
while (((test_y + height) < (scr->scr_height)) && (!loc_ok)) {
test_x = sx;
while (((test_x + width) < swidth) && (!loc_ok)) {
loc_ok = True;
test_window = scr->focused_window;
while ((test_window != NULL) && (loc_ok == True)) {
if (test_window->frame->core->stacking->window_level
< WMNormalLevel && tryCount > 0) {
test_window = test_window->next;
continue;
}
#if 0
tw = test_window->client.width;
if (test_window->flags.shaded)
th = test_window->frame->top_width;
else
th = test_window->client.height + extra_height;
#else
tw = test_window->frame->core->width;
th = test_window->frame->core->height;
#endif
tx = test_window->frame_x;
ty = test_window->frame_y;
if ((tx < (test_x + width)) && ((tx + tw) > test_x) &&
(ty < (test_y + height)) && ((ty + th) > test_y) &&
(test_window->flags.mapped ||
(test_window->flags.shaded &&
!(test_window->flags.miniaturized ||
test_window->flags.hidden)))) {
loc_ok = False;
}
test_window = test_window->next;
}
test_window = scr->focused_window;
while ((test_window != NULL) && (loc_ok == True)) {
if (test_window->frame->core->stacking->window_level
< WMNormalLevel && tryCount > 0) {
test_window = test_window->prev;
continue;
}
#if 0
tw = test_window->client.width;
if (test_window->flags.shaded)
th = test_window->frame->top_width;
else
th = test_window->client.height + extra_height;
#else
tw = test_window->frame->core->width;
th = test_window->frame->core->height;
#endif
tx = test_window->frame_x;
ty = test_window->frame_y;
if ((tx < (test_x + width)) && ((tx + tw) > test_x) &&
(ty < (test_y + height)) && ((ty + th) > test_y) &&
(test_window->flags.mapped ||
(test_window->flags.shaded &&
!(test_window->flags.miniaturized ||
test_window->flags.hidden)))) {
loc_ok = False;
}
test_window = test_window->prev;
}
if (loc_ok == True) {
*x_ret = test_x;
*y_ret = test_y;
break;
}
test_x += PLACETEST_HSTEP;
}
test_y += PLACETEST_VSTEP;
}
return loc_ok;
}
static void static void
cascadeWindow(WScreen *scr, WWindow *wwin, int *x_ret, int *y_ret, cascadeWindow(WScreen *scr, WWindow *wwin, int *x_ret, int *y_ret,
unsigned int width, unsigned int height, int h) unsigned int width, unsigned int height, int h)
@@ -452,8 +564,18 @@ PlaceWindow(WWindow *wwin, int *x_ret, int *y_ret,
smartPlaceWindow(wwin, x_ret, y_ret, width, height); smartPlaceWindow(wwin, x_ret, y_ret, width, height);
break; break;
case WPM_AUTO:
if (autoPlaceWindow(wwin, x_ret, y_ret, width, height, 0)) {
break;
} else if (autoPlaceWindow(wwin, x_ret, y_ret, width, height, 1)) {
break;
}
/* there isn't a break here, because if we fail, it should fall
through to cascade placement, as people who want tiling want
automagicness aren't going to want to place their window */
case WPM_CASCADE: case WPM_CASCADE:
if (wPreferences.window_placement == WPM_SMART) if (wPreferences.window_placement == WPM_AUTO)
scr->cascade_index++; scr->cascade_index++;
cascadeWindow(scr, wwin, x_ret, y_ret, width, height, h); cascadeWindow(scr, wwin, x_ret, y_ret, width, height, h);

View File

@@ -1270,9 +1270,9 @@ typedef struct {
static int static int
myCompare(dir_data *d1, dir_data *d2) myCompare(const void *d1, const void *d2)
{ {
return strcmp(d1->name, d2->name); return strcmp(((dir_data*) d1)->name, ((dir_data*) d2)->name);
} }