mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-20 21:08:08 +01:00
More (un)maximize tweaks.
Update the saved X co-ordinate of a window which was moved when maximized (only) vertically so that unmaximizing the window restores its dimensions without warping it back to its previous X position. Similarly update the saved Y co-ordinate of a window which was moved when maximized (only) horizontally. Handle Maximus as a special case. We remember the Maximusized X and Y co-ordinates then adjust the restored co-ordinates relative to the delta between the window's position just after Maximusizing and its position just before restoring. So for example if a window is Maximusized, moved 100 pixels to the left and restored, it will end up 100 pixels left of its original geometry. Also fix "jumping window" bug reported by Christian Wittmer: This "jumping window" happens only when you 1) open new xterm (STRG +n) 2) current position is (+64, +0) 3) maximize window vertically 4) undo maximizing 5) move window to the right or left (up or down as you like) I moved right to (+450, +0) 6) maximize vertically again 7) and undo maximizing 8) window jumps back to (+64, ..) position If you move a new opened window to a new position (e.g. +200, +200) and then start with "3)". window is jumping back "+200, +200"
This commit is contained in:
committed by
Carlos R. Mafra
parent
8edb9dad81
commit
81eefca4ef
@@ -287,14 +287,20 @@ void wUnshadeWindow(WWindow *wwin)
|
||||
/* Set the old coordinates using the current values */
|
||||
static void save_old_geometry(WWindow *wwin, int directions)
|
||||
{
|
||||
if (directions & MAX_HORIZONTAL || ! wwin->old_geometry.width) {
|
||||
wwin->old_geometry.width = wwin->client.width;
|
||||
/* never been saved? */
|
||||
if (! wwin->old_geometry.width)
|
||||
directions |= SAVE_GEOMETRY_X | SAVE_GEOMETRY_WIDTH;
|
||||
if (! wwin->old_geometry.height)
|
||||
directions |= SAVE_GEOMETRY_Y | SAVE_GEOMETRY_HEIGHT;
|
||||
|
||||
if (directions & SAVE_GEOMETRY_X)
|
||||
wwin->old_geometry.x = wwin->frame_x;
|
||||
}
|
||||
if (directions & MAX_VERTICAL || ! wwin->old_geometry.height) {
|
||||
wwin->old_geometry.height = wwin->client.height;
|
||||
if (directions & SAVE_GEOMETRY_Y)
|
||||
wwin->old_geometry.y = wwin->frame_y;
|
||||
}
|
||||
if (directions & SAVE_GEOMETRY_WIDTH)
|
||||
wwin->old_geometry.width = wwin->client.width;
|
||||
if (directions & SAVE_GEOMETRY_HEIGHT)
|
||||
wwin->old_geometry.height = wwin->client.height;
|
||||
}
|
||||
|
||||
static void remember_geometry(WWindow *wwin, int *x, int *y, int *w, int *h)
|
||||
@@ -312,6 +318,27 @@ static void remember_geometry(WWindow *wwin, int *x, int *y, int *w, int *h)
|
||||
*h = wwin->old_geometry.height ? wwin->old_geometry.height : wwin->client.height;
|
||||
}
|
||||
|
||||
/* Remember geometry for unmaximizing */
|
||||
void update_saved_geometry(WWindow *wwin)
|
||||
{
|
||||
/* NOT if we aren't already maximized
|
||||
* we'll save geometry when maximizing */
|
||||
if (!wwin->flags.maximized)
|
||||
return;
|
||||
|
||||
/* NOT if we are fully maximized */
|
||||
if ((wwin->flags.maximized & MAX_MAXIMUS) ||
|
||||
((wwin->flags.maximized & MAX_HORIZONTAL) &&
|
||||
(wwin->flags.maximized & MAX_VERTICAL)))
|
||||
return;
|
||||
|
||||
/* save the co-ordinate in the axis in which we AREN'T maximized */
|
||||
if (wwin->flags.maximized & MAX_HORIZONTAL)
|
||||
save_old_geometry(wwin, SAVE_GEOMETRY_Y);
|
||||
if (wwin->flags.maximized & MAX_VERTICAL)
|
||||
save_old_geometry(wwin, SAVE_GEOMETRY_X);
|
||||
}
|
||||
|
||||
#define IS_MAX_HORIZONTALLY(directions) ((directions & MAX_HORIZONTAL) | (directions & MAX_LEFTHALF) | (directions & MAX_RIGHTHALF))
|
||||
void wMaximizeWindow(WWindow *wwin, int directions)
|
||||
{
|
||||
@@ -336,17 +363,20 @@ void wMaximizeWindow(WWindow *wwin, int directions)
|
||||
adj_size = FRAME_BORDER_WIDTH * 2 * has_border;
|
||||
|
||||
/* save old coordinates before we change the current values
|
||||
* always if the window is not currently maximized at all
|
||||
* but never if the window has been Maximusized */
|
||||
if (!(wwin->flags.old_maximized & MAX_MAXIMUS)) {
|
||||
if (!wwin->flags.maximized)
|
||||
save_directions |= SAVE_GEOMETRY_ALL;
|
||||
else if (!(wwin->flags.old_maximized & MAX_MAXIMUS)) {
|
||||
if ((directions & MAX_VERTICAL) &&
|
||||
!(wwin->flags.maximized & MAX_VERTICAL))
|
||||
save_directions |= MAX_VERTICAL;
|
||||
save_directions |= SAVE_GEOMETRY_Y | SAVE_GEOMETRY_HEIGHT;
|
||||
if (IS_MAX_HORIZONTALLY(directions) &&
|
||||
!IS_MAX_HORIZONTALLY(wwin->flags.maximized))
|
||||
save_directions |= MAX_HORIZONTAL;
|
||||
save_directions |= SAVE_GEOMETRY_X | SAVE_GEOMETRY_WIDTH;
|
||||
}
|
||||
if ((directions & MAX_MAXIMUS) && !wwin->flags.maximized)
|
||||
save_directions |= MAX_VERTICAL | MAX_HORIZONTAL;
|
||||
save_directions |= SAVE_GEOMETRY_ALL;
|
||||
save_old_geometry(wwin, save_directions);
|
||||
|
||||
totalArea.x1 = 0;
|
||||
@@ -445,6 +475,8 @@ void wMaximizeWindow(WWindow *wwin, int directions)
|
||||
new_y -= wwin->frame->top_width;
|
||||
new_height += wwin->frame->top_width - 1;
|
||||
}
|
||||
wwin->maximus_x = new_x;
|
||||
wwin->maximus_y = new_y;
|
||||
wwin->flags.old_maximized |= MAX_MAXIMUS;
|
||||
}
|
||||
|
||||
@@ -673,9 +705,16 @@ void wUnmaximizeWindow(WWindow *wwin)
|
||||
wwin->flags.skip_next_animation = 1;
|
||||
wUnshadeWindow(wwin);
|
||||
}
|
||||
|
||||
/* Use old coordinates if they are set, current values otherwise */
|
||||
remember_geometry(wwin, &x, &y, &w, &h);
|
||||
|
||||
/* unMaximusize relative to original position */
|
||||
if (wwin->flags.maximized & MAX_MAXIMUS) {
|
||||
x += wwin->frame_x - wwin->maximus_x;
|
||||
y += wwin->frame_y - wwin->maximus_y;
|
||||
}
|
||||
|
||||
wwin->flags.maximized = 0;
|
||||
wwin->flags.old_maximized = 0;
|
||||
wWindowConfigure(wwin, x, y, w, h);
|
||||
|
||||
Reference in New Issue
Block a user