summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter de Ridder <cavalier@the-cavalry.org>2014-12-23 15:41:05 +0100
committerPeter de Ridder <cavalier@the-cavalry.org>2015-01-20 18:59:03 +0100
commitcd73bb720ebac5af4ffc57297083dca846dc1c62 (patch)
treee9f72fcf80f1f71640787c60f6faf1daacfd1e9c
parent1ebb9878542f1ddfe287da30167a5065aa379aea (diff)
downloadxfwm4-cd73bb720ebac5af4ffc57297083dca846dc1c62.tar.gz
Restore window size for corner tiling
-rw-r--r--src/client.c50
-rw-r--r--src/client.h3
-rw-r--r--src/events.c16
-rw-r--r--src/moveresize.c42
-rw-r--r--src/netwm.c8
-rw-r--r--src/placement.c4
-rw-r--r--src/session.c3
7 files changed, 88 insertions, 38 deletions
diff --git a/src/client.c b/src/client.c
index c1a5496f6..8b4641ed5 100644
--- a/src/client.c
+++ b/src/client.c
@@ -299,7 +299,7 @@ clientUpdateAllFrames (ScreenInfo *screen_info, int mask)
if (mask & UPDATE_MAXIMIZE)
{
/* Recompute size and position of maximized windows */
- if (FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED_HORIZ | CLIENT_FLAG_MAXIMIZED_VERT))
+ if (FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED))
{
clientRecomputeMaximizeSize (c);
@@ -1498,7 +1498,7 @@ clientSaveSizePos (Client *c)
{
g_return_if_fail (c != NULL);
- if (!FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED_HORIZ) && !FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED_VERT))
+ if (!FLAG_TEST (c->flags, CLIENT_FLAG_RESTORE_SIZE_POS))
{
c->old_x = c->x;
c->old_width = c->width;
@@ -1507,6 +1507,25 @@ clientSaveSizePos (Client *c)
}
}
+gboolean
+clientRestoreSizePos (Client *c)
+{
+ g_return_if_fail (c != NULL);
+
+ if (FLAG_TEST (c->flags, CLIENT_FLAG_RESTORE_SIZE_POS))
+ {
+ c->x = c->old_x;
+ c->width = c->old_width;
+ c->y = c->old_y;
+ c->height = c->old_height;
+
+ FLAG_UNSET (c->flags, CLIENT_FLAG_RESTORE_SIZE_POS);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
Client *
clientFrame (DisplayInfo *display_info, Window w, gboolean recapture)
{
@@ -3090,7 +3109,7 @@ clientRemoveMaximizeFlag (Client *c)
TRACE ("Removing maximize flag on client \"%s\" (0x%lx)", c->name,
c->window);
- FLAG_UNSET (c->flags, CLIENT_FLAG_MAXIMIZED);
+ FLAG_UNSET (c->flags, CLIENT_FLAG_MAXIMIZED | CLIENT_FLAG_RESTORE_SIZE_POS);
frameQueueDraw (c, FALSE);
clientSetNetActions (c);
clientSetNetState (c);
@@ -3108,7 +3127,7 @@ clientNewMaxState (Client *c, XWindowChanges *wc, int mode)
*/
if (FLAG_TEST_ALL (c->flags, CLIENT_FLAG_MAXIMIZED))
{
- FLAG_UNSET (c->flags, CLIENT_FLAG_MAXIMIZED);
+ FLAG_UNSET (c->flags, CLIENT_FLAG_MAXIMIZED | CLIENT_FLAG_RESTORE_SIZE_POS);
wc->x = c->old_x;
wc->y = c->old_y;
wc->width = c->old_width;
@@ -3132,11 +3151,15 @@ clientNewMaxState (Client *c, XWindowChanges *wc, int mode)
{
if (!FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED_HORIZ))
{
- FLAG_SET (c->flags, CLIENT_FLAG_MAXIMIZED_HORIZ);
+ FLAG_SET (c->flags, CLIENT_FLAG_MAXIMIZED_HORIZ | CLIENT_FLAG_RESTORE_SIZE_POS);
}
else
{
FLAG_UNSET (c->flags, CLIENT_FLAG_MAXIMIZED_HORIZ);
+ if (!FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED))
+ {
+ FLAG_UNSET (c->flags, CLIENT_FLAG_RESTORE_SIZE_POS);
+ }
wc->x = c->old_x;
wc->y = c->old_y;
wc->width = c->old_width;
@@ -3148,11 +3171,15 @@ clientNewMaxState (Client *c, XWindowChanges *wc, int mode)
{
if (!FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED_VERT))
{
- FLAG_SET (c->flags, CLIENT_FLAG_MAXIMIZED_VERT);
+ FLAG_SET (c->flags, CLIENT_FLAG_MAXIMIZED_VERT | CLIENT_FLAG_RESTORE_SIZE_POS);
}
else
{
FLAG_UNSET (c->flags, CLIENT_FLAG_MAXIMIZED_VERT);
+ if (!FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED))
+ {
+ FLAG_UNSET (c->flags, CLIENT_FLAG_RESTORE_SIZE_POS);
+ }
wc->x = c->old_x;
wc->y = c->old_y;
wc->width = c->old_width;
@@ -3300,8 +3327,7 @@ clientToggleMaximized (Client *c, int mode, gboolean restore_position)
wc.height = c->height;
if (restore_position &&
- FLAG_TEST (mode, CLIENT_FLAG_MAXIMIZED) &&
- !FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED))
+ FLAG_TEST (mode, CLIENT_FLAG_MAXIMIZED))
{
clientSaveSizePos (c);
}
@@ -3348,7 +3374,7 @@ clientToggleMaximized (Client *c, int mode, gboolean restore_position)
}
gboolean
-clientTile (Client *c, gint cx, gint cy, tilePositionType tile, gboolean send_configure)
+clientTile (Client *c, gint cx, gint cy, tilePositionType tile, gboolean send_configure, gboolean restore_position)
{
DisplayInfo *display_info;
ScreenInfo *screen_info;
@@ -3397,6 +3423,11 @@ clientTile (Client *c, gint cx, gint cy, tilePositionType tile, gboolean send_co
break;
}
+ if (restore_position)
+ {
+ clientSaveSizePos (c);
+ }
+
old_flags = c->flags;
FLAG_UNSET (c->flags, CLIENT_FLAG_MAXIMIZED);
clientNewMaxState (c, &wc, mode);
@@ -3405,6 +3436,7 @@ clientTile (Client *c, gint cx, gint cy, tilePositionType tile, gboolean send_co
c->flags = old_flags;
return FALSE;
}
+ FLAG_SET (c->flags, CLIENT_FLAG_RESTORE_SIZE_POS);
c->x = wc.x;
c->y = wc.y;
diff --git a/src/client.h b/src/client.h
index 94edadcbf..4f90258b9 100644
--- a/src/client.h
+++ b/src/client.h
@@ -171,6 +171,7 @@
#define CLIENT_FLAG_XSYNC_ENABLED (1L<<23)
#define CLIENT_FLAG_XSYNC_EXT_COUNTER (1L<<24)
#define CLIENT_FLAG_XSYNC_CONFIGURE (1L<<25)
+#define CLIENT_FLAG_RESTORE_SIZE_POS (1L<<26)
#define WM_FLAG_DELETE (1L<<0)
#define WM_FLAG_INPUT (1L<<1)
@@ -400,6 +401,7 @@ void clientGetWMNormalHints (Client *,
void clientGetWMProtocols (Client *);
void clientUpdateIcon (Client *);
void clientSaveSizePos (Client *);
+gboolean clientRestoreSizePos (Client *);
Client *clientFrame (DisplayInfo *,
Window,
gboolean);
@@ -466,6 +468,7 @@ gboolean clientTile (Client *,
gint,
gint,
tilePositionType,
+ gboolean,
gboolean);
void clientUpdateOpacity (Client *);
void clientUpdateAllOpacity (ScreenInfo *);
diff --git a/src/events.c b/src/events.c
index 1da35c327..db4e836aa 100644
--- a/src/events.c
+++ b/src/events.c
@@ -431,42 +431,42 @@ handleKeyPress (DisplayInfo *display_info, XKeyEvent * ev)
case KEY_TILE_DOWN:
clientTile (c, frameX (c) + frameWidth (c) / 2,
frameY (c) + frameHeight (c) / 2,
- TILE_DOWN, TRUE);
+ TILE_DOWN, TRUE, TRUE);
break;
case KEY_TILE_LEFT:
clientTile (c, frameX (c) + frameWidth (c) / 2,
frameY (c) + frameHeight (c) / 2,
- TILE_LEFT, TRUE);
+ TILE_LEFT, TRUE, TRUE);
break;
case KEY_TILE_RIGHT:
clientTile (c, frameX (c) + frameWidth (c) / 2,
frameY (c) + frameHeight (c) / 2,
- TILE_RIGHT, TRUE);
+ TILE_RIGHT, TRUE, TRUE);
break;
case KEY_TILE_UP:
clientTile (c, frameX (c) + frameWidth (c) / 2,
frameY (c) + frameHeight (c) / 2,
- TILE_UP, TRUE);
+ TILE_UP, TRUE, TRUE);
break;
case KEY_TILE_DOWN_LEFT:
clientTile (c, frameX (c) + frameWidth (c) / 2,
frameY (c) + frameHeight (c) / 2,
- TILE_DOWN_LEFT, TRUE);
+ TILE_DOWN_LEFT, TRUE, TRUE);
break;
case KEY_TILE_DOWN_RIGHT:
clientTile (c, frameX (c) + frameWidth (c) / 2,
frameY (c) + frameHeight (c) / 2,
- TILE_DOWN_RIGHT, TRUE);
+ TILE_DOWN_RIGHT, TRUE, TRUE);
break;
case KEY_TILE_UP_LEFT:
clientTile (c, frameX (c) + frameWidth (c) / 2,
frameY (c) + frameHeight (c) / 2,
- TILE_UP_LEFT, TRUE);
+ TILE_UP_LEFT, TRUE, TRUE);
break;
case KEY_TILE_UP_RIGHT:
clientTile (c, frameX (c) + frameWidth (c) / 2,
frameY (c) + frameHeight (c) / 2,
- TILE_UP_RIGHT, TRUE);
+ TILE_UP_RIGHT, TRUE, TRUE);
break;
default:
break;
diff --git a/src/moveresize.c b/src/moveresize.c
index 2093a771a..95fd73418 100644
--- a/src/moveresize.c
+++ b/src/moveresize.c
@@ -796,12 +796,12 @@ clientMoveTile (Client *c, XMotionEvent *xevent)
/* mouse pointer on left edge excluding corners */
if (x < disp_x + dist)
{
- return clientTile (c, x, y, TILE_LEFT, !screen_info->params->box_move);
+ return clientTile (c, x, y, TILE_LEFT, !screen_info->params->box_move, FALSE);
}
/* mouse pointer on right edge excluding corners */
if (x >= disp_max_x - dist)
{
- return clientTile (c, x, y, TILE_RIGHT, !screen_info->params->box_move);
+ return clientTile (c, x, y, TILE_RIGHT, !screen_info->params->box_move, FALSE);
}
}
@@ -818,25 +818,25 @@ clientMoveTile (Client *c, XMotionEvent *xevent)
if (((x < disp_x + dist_corner) && (y < disp_y + dist))
|| ((x < disp_x + dist) && (y < disp_y + dist_corner)))
{
- return clientTile (c, x, y, TILE_UP_LEFT, !screen_info->params->box_move);
+ return clientTile (c, x, y, TILE_UP_LEFT, !screen_info->params->box_move, FALSE);
}
/* mouse pointer on top right corner */
if (((x >= disp_max_x - dist_corner) && (y < disp_y + dist))
|| ((x >= disp_max_x - dist) && (y < disp_y + dist_corner)))
{
- return clientTile (c, x, y, TILE_UP_RIGHT, !screen_info->params->box_move);
+ return clientTile (c, x, y, TILE_UP_RIGHT, !screen_info->params->box_move, FALSE);
}
/* mouse pointer on bottom left corner */
if (((x < disp_x + dist_corner) && (y >= disp_max_y - dist))
|| ((x < disp_x + dist) && (y >= disp_max_y - dist_corner)))
{
- return clientTile (c, x, y, TILE_DOWN_LEFT, !screen_info->params->box_move);
+ return clientTile (c, x, y, TILE_DOWN_LEFT, !screen_info->params->box_move, FALSE);
}
/* mouse pointer on bottom right corner */
if (((x >= disp_max_x - dist_corner) && (y >= disp_max_y - dist))
|| ((x >= disp_max_x - dist) && (y >= disp_max_y - dist_corner)))
{
- return clientTile (c, x, y, TILE_DOWN_RIGHT, !screen_info->params->box_move);
+ return clientTile (c, x, y, TILE_DOWN_RIGHT, !screen_info->params->box_move, FALSE);
}
}
@@ -855,6 +855,7 @@ clientMoveEventFilter (XEvent * xevent, gpointer data)
XWindowChanges wc;
int prev_x, prev_y;
unsigned long cancel_maximize_flags;
+ unsigned long cancel_restore_size_flags;
TRACE ("entering clientMoveEventFilter");
@@ -924,8 +925,13 @@ clientMoveEventFilter (XEvent * xevent, gpointer data)
c->x = passdata->cancel_x;
c->y = passdata->cancel_y;
/* Restore the width height to correct the outline */
- c->width = passdata->cancel_w;
- c->height = passdata->cancel_h;
+ if (c->width != passdata->cancel_w ||
+ c->height != passdata->cancel_h)
+ {
+ c->width = passdata->cancel_w;
+ c->height = passdata->cancel_h;
+ passdata->move_resized = TRUE;
+ }
if (screen_info->current_ws != passdata->cancel_workspace)
{
@@ -942,6 +948,11 @@ clientMoveEventFilter (XEvent * xevent, gpointer data)
passdata->move_resized = TRUE;
}
}
+ cancel_restore_size_flags = passdata->cancel_flags & CLIENT_FLAG_RESTORE_SIZE_POS;
+ if (!FLAG_TEST_AND_NOT(c->flags, cancel_restore_size_flags, CLIENT_FLAG_RESTORE_SIZE_POS))
+ {
+ FLAG_TOGGLE (c->flags, CLIENT_FLAG_RESTORE_SIZE_POS);
+ }
if (screen_info->params->box_move)
{
if (passdata->wireframe)
@@ -989,19 +1000,25 @@ clientMoveEventFilter (XEvent * xevent, gpointer data)
xevent->xmotion.time);
}
- if (FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED))
+ if (FLAG_TEST (c->flags, CLIENT_FLAG_RESTORE_SIZE_POS))
{
if ((ABS (xevent->xmotion.x_root - passdata->mx) > 15) ||
(ABS (xevent->xmotion.y_root - passdata->my) > 15))
{
+ gboolean size_changed;
/* to keep the distance from the edges of the window proportional. */
double xratio, yratio;
xratio = (xevent->xmotion.x_root - frameExtentX (c)) / (double) frameExtentWidth (c);
yratio = (xevent->xmotion.y_root - frameExtentY (c)) / (double) frameExtentHeight (c);
- if (clientToggleMaximized (c, c->flags & CLIENT_FLAG_MAXIMIZED, FALSE))
+ size_changed = clientToggleMaximized (c, c->flags & CLIENT_FLAG_MAXIMIZED, FALSE);
+ if (clientRestoreSizePos (c))
+ {
+ size_changed = TRUE;
+ }
+ if (size_changed)
{
passdata->move_resized = TRUE;
@@ -1097,10 +1114,7 @@ clientMoveEventFilter (XEvent * xevent, gpointer data)
if (!moving)
{
TRACE ("event loop now finished");
- if (!FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED))
- {
- clientSaveSizePos (c);
- }
+ clientSaveSizePos (c);
gtk_main_quit ();
}
diff --git a/src/netwm.c b/src/netwm.c
index 4e45ddcd1..ee3cd4dfb 100644
--- a/src/netwm.c
+++ b/src/netwm.c
@@ -172,12 +172,12 @@ clientGetNetState (Client * c)
if (FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED_HORIZ))
{
TRACE ("clientGetNetState : maximized horiz from session management");
- FLAG_SET (c->flags, CLIENT_FLAG_MAXIMIZED_HORIZ);
+ FLAG_SET (c->flags, CLIENT_FLAG_MAXIMIZED_HORIZ | CLIENT_FLAG_RESTORE_SIZE_POS);
}
if (FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED_VERT))
{
TRACE ("clientGetNetState : maximized vert from session management");
- FLAG_SET (c->flags, CLIENT_FLAG_MAXIMIZED_VERT);
+ FLAG_SET (c->flags, CLIENT_FLAG_MAXIMIZED_VERT | CLIENT_FLAG_RESTORE_SIZE_POS);
}
}
@@ -202,12 +202,12 @@ clientGetNetState (Client * c)
else if ((atoms[i] == display_info->atoms[NET_WM_STATE_MAXIMIZED_HORZ]))
{
TRACE ("clientGetNetState : maximized horiz");
- FLAG_SET (c->flags, CLIENT_FLAG_MAXIMIZED_HORIZ);
+ FLAG_SET (c->flags, CLIENT_FLAG_MAXIMIZED_HORIZ | CLIENT_FLAG_RESTORE_SIZE_POS);
}
else if ((atoms[i] == display_info->atoms[NET_WM_STATE_MAXIMIZED_VERT]))
{
TRACE ("clientGetNetState : maximized vert");
- FLAG_SET (c->flags, CLIENT_FLAG_MAXIMIZED_VERT);
+ FLAG_SET (c->flags, CLIENT_FLAG_MAXIMIZED_VERT | CLIENT_FLAG_RESTORE_SIZE_POS);
}
else if ((atoms[i] == display_info->atoms[NET_WM_STATE_FULLSCREEN]))
{
diff --git a/src/placement.c b/src/placement.c
index fd86b7367..a804c4c87 100644
--- a/src/placement.c
+++ b/src/placement.c
@@ -525,7 +525,7 @@ clientAutoMaximize (Client * c, int full_w, int full_h)
TRACE ("The application \"%s\" has requested a window width "
"(%u) equal or larger than the actual width available in the workspace (%u), "
"the window will be maximized horizontally.", c->name, frameExtentWidth (c), full_w);
- FLAG_SET (c->flags, CLIENT_FLAG_MAXIMIZED_HORIZ);
+ FLAG_SET (c->flags, CLIENT_FLAG_MAXIMIZED_HORIZ | CLIENT_FLAG_RESTORE_SIZE_POS);
}
if (!FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED_VERT) &&
@@ -534,7 +534,7 @@ clientAutoMaximize (Client * c, int full_w, int full_h)
TRACE ("The application \"%s\" has requested a window height "
"(%u) equal or larger than the actual height available in the workspace (%u), "
"the window will be maximized vertically.", c->name, frameExtentHeight (c), full_h);
- FLAG_SET (c->flags, CLIENT_FLAG_MAXIMIZED_VERT);
+ FLAG_SET (c->flags, CLIENT_FLAG_MAXIMIZED_VERT | CLIENT_FLAG_RESTORE_SIZE_POS);
}
}
diff --git a/src/session.c b/src/session.c
index 137c9787c..286ddb5e7 100644
--- a/src/session.c
+++ b/src/session.c
@@ -710,7 +710,8 @@ sessionMatchWinToSM (Client * c)
FLAG_SET (c->flags,
matches[i].
flags & (CLIENT_FLAG_STICKY | CLIENT_FLAG_SHADED |
- CLIENT_FLAG_MAXIMIZED | CLIENT_FLAG_ICONIFIED));
+ CLIENT_FLAG_MAXIMIZED | CLIENT_FLAG_ICONIFIED |
+ CLIENT_FLAG_RESTORE_SIZE_POS));
FLAG_SET (c->xfwm_flags, XFWM_FLAG_WORKSPACE_SET);
return TRUE;
}