summaryrefslogtreecommitdiff
path: root/src/core/constraints.c
diff options
context:
space:
mode:
authorOmar Zeidan <[email protected]>2017-12-11 14:54:17 +0100
committerraveit65 <[email protected]>2017-12-20 20:42:12 +0100
commit6219f8e8bcaeefb9185a3c3f5f20de4e2fa8f18f (patch)
treee3652b4e35ca31478ef9f62f89765ff6d97e7b3a /src/core/constraints.c
parent01f68e8f9f1541393e6e069db08f834d4ef18691 (diff)
downloadmarco-6219f8e8bcaeefb9185a3c3f5f20de4e2fa8f18f.tar.bz2
marco-6219f8e8bcaeefb9185a3c3f5f20de4e2fa8f18f.tar.xz
Allow horizontal and vertical resizing when corner tiled
Diffstat (limited to 'src/core/constraints.c')
-rw-r--r--src/core/constraints.c128
1 files changed, 103 insertions, 25 deletions
diff --git a/src/core/constraints.c b/src/core/constraints.c
index 512e6404..b4f9b551 100644
--- a/src/core/constraints.c
+++ b/src/core/constraints.c
@@ -206,6 +206,11 @@ static inline void get_size_limits (const MetaWindow *window,
MetaRectangle *min_size,
MetaRectangle *max_size);
+static void can_resize_tiled (guint tile_mode,
+ int resize_gravity,
+ gboolean *resize_horizontally,
+ gboolean *resize_vertically);
+
typedef gboolean (* ConstraintFunc) (MetaWindow *window,
ConstraintInfo *info,
ConstraintPriority priority,
@@ -876,13 +881,14 @@ constrain_tiling (MetaWindow *window,
gboolean hminbad, vminbad;
gboolean horiz_equal, vert_equal;
gboolean constraint_already_satisfied;
- gboolean allow_resize = FALSE;
+ gboolean allow_resize_horizontally = FALSE;
+ gboolean allow_resize_vertically = FALSE;
if (priority > PRIORITY_TILING)
return TRUE;
/* Determine whether constraint applies; exit if it doesn't */
- if (!META_WINDOW_SIDE_TILED (window))
+ if (!META_WINDOW_TILED(window))
return TRUE;
/* Calculate target_size - as the tile previews need this as well, we
@@ -912,46 +918,118 @@ constrain_tiling (MetaWindow *window,
/* Allow the user to resize horizontally when tiled */
if (info->is_user_action)
{
- /* Only allow resizing from the window side farther from the screen edge */
- switch (info->resize_gravity)
- {
- case NorthEastGravity:
- case EastGravity:
- case SouthEastGravity:
- if (window->tile_mode == META_TILE_RIGHT)
- allow_resize = TRUE;
- break;
- case NorthWestGravity:
- case WestGravity:
- case SouthWestGravity:
- if (window->tile_mode == META_TILE_LEFT)
- allow_resize = TRUE;
- break;
- }
-
- /* Mark window as being resized from a tiled state */
+ can_resize_tiled(window->tile_mode,
+ info->resize_gravity,
+ &allow_resize_horizontally,
+ &allow_resize_vertically);
+
window->tile_resized = TRUE;
}
if (window->tile_resized)
{
/* Maintain current tile size for user-resized windows */
+ target_size.y = info->orig.y;
+ target_size.height = info->orig.height;
target_size.x = info->orig.x;
target_size.width = info->orig.width;
}
/*** Enforce constraint ***/
- if (!allow_resize)
+ if (!allow_resize_vertically)
{
+ info->current.y = target_size.y;
+ info->current.height = target_size.height;
+ }
+
+ if(!allow_resize_horizontally)
+ {
info->current.x = target_size.x;
info->current.width = target_size.width;
}
- info->current.y = target_size.y;
- info->current.height = target_size.height;
-
+
return TRUE;
}
+static void
+can_resize_tiled (guint tile_mode,
+ int resize_gravity,
+ gboolean *resize_horizontally,
+ gboolean *resize_vertically)
+{
+ switch(tile_mode)
+ {
+ case META_TILE_RIGHT:
+ if (resize_gravity == EastGravity)
+ *resize_horizontally = TRUE;
+ break;
+ case META_TILE_LEFT:
+ if(resize_gravity == WestGravity)
+ *resize_horizontally = TRUE;
+ break;
+ case META_TILE_TOP_RIGHT:
+ switch(resize_gravity)
+ {
+ case EastGravity:
+ *resize_horizontally = TRUE;
+ break;
+ case NorthGravity:
+ *resize_vertically = TRUE;
+ break;
+ case NorthEastGravity:
+ *resize_horizontally = TRUE;
+ *resize_vertically = TRUE;
+ break;
+ }
+ break;
+ case META_TILE_TOP_LEFT:
+ switch(resize_gravity)
+ {
+ case WestGravity:
+ *resize_horizontally = TRUE;
+ break;
+ case NorthGravity:
+ *resize_vertically = TRUE;
+ break;
+ case NorthWestGravity:
+ *resize_horizontally = TRUE;
+ *resize_vertically = TRUE;
+ break;
+ }
+ break;
+ case META_TILE_BOTTOM_RIGHT:
+ switch(resize_gravity)
+ {
+ case EastGravity:
+ *resize_horizontally = TRUE;
+ break;
+ case SouthGravity:
+ *resize_vertically = TRUE;
+ break;
+ case SouthEastGravity:
+ *resize_horizontally = TRUE;
+ *resize_vertically = TRUE;
+ break;
+ }
+ break;
+ case META_TILE_BOTTOM_LEFT:
+ switch(resize_gravity)
+ {
+ case WestGravity:
+ *resize_horizontally = TRUE;
+ break;
+ case SouthGravity:
+ *resize_vertically = TRUE;
+ break;
+ case SouthWestGravity:
+ *resize_horizontally = TRUE;
+ *resize_vertically = TRUE;
+ break;
+ }
+ break;
+ }
+}
+
static gboolean
constrain_fullscreen (MetaWindow *window,
ConstraintInfo *info,
@@ -1003,7 +1081,7 @@ constrain_size_increments (MetaWindow *window,
/* Determine whether constraint applies; exit if it doesn't */
if (META_WINDOW_MAXIMIZED (window) || window->fullscreen ||
- META_WINDOW_SIDE_TILED (window) || info->action_type == ACTION_MOVE)
+ META_WINDOW_TILED (window) || info->action_type == ACTION_MOVE)
return TRUE;
/* Determine whether constraint is already satisfied; exit if it is */