summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormonsta <[email protected]>2015-10-23 14:34:54 +0300
committermonsta <[email protected]>2015-10-26 11:02:58 +0300
commit4007ca1c695c84a3a82d1fcdf81950d4062ccdf0 (patch)
tree397c2c5195370361c407c900a05b21dcd61cd9e2
parentc340832a15d4b718f85e11fcc2d0bd73d492e102 (diff)
downloadmarco-4007ca1c695c84a3a82d1fcdf81950d4062ccdf0.tar.bz2
marco-4007ca1c695c84a3a82d1fcdf81950d4062ccdf0.tar.xz
constraints: take into account _GTK_FRAME_EXTENTS
ported from https://git.gnome.org/browse/metacity/commit/?id=8f699b71bd7e5581ec2f2804ea9650597618dfe1
-rw-r--r--src/core/constraints.c104
1 files changed, 78 insertions, 26 deletions
diff --git a/src/core/constraints.c b/src/core/constraints.c
index 08d1c70a..69263a51 100644
--- a/src/core/constraints.c
+++ b/src/core/constraints.c
@@ -194,9 +194,11 @@ static void place_window_if_needed (MetaWindow *window,
ConstraintInfo *info);
static void update_onscreen_requirements (MetaWindow *window,
ConstraintInfo *info);
-static void extend_by_frame (MetaRectangle *rect,
+static void extend_by_frame (MetaWindow *window,
+ MetaRectangle *rect,
const MetaFrameGeometry *fgeom);
-static void unextend_by_frame (MetaRectangle *rect,
+static void unextend_by_frame (MetaWindow *window,
+ MetaRectangle *rect,
const MetaFrameGeometry *fgeom);
static inline void get_size_limits (const MetaWindow *window,
const MetaFrameGeometry *fgeom,
@@ -627,7 +629,7 @@ update_onscreen_requirements (MetaWindow *window,
/* The require onscreen/on-single-xinerama and titlebar_visible
* stuff is relative to the outer window, not the inner
*/
- extend_by_frame (&info->current, info->fgeom);
+ extend_by_frame (window, &info->current, info->fgeom);
/* Update whether we want future constraint runs to require the
* window to be on fully onscreen.
@@ -676,27 +678,49 @@ update_onscreen_requirements (MetaWindow *window,
}
/* Don't forget to restore the position of the window */
- unextend_by_frame (&info->current, info->fgeom);
+ unextend_by_frame (window, &info->current, info->fgeom);
}
static void
-extend_by_frame (MetaRectangle *rect,
+extend_by_frame (MetaWindow *window,
+ MetaRectangle *rect,
const MetaFrameGeometry *fgeom)
{
- rect->x -= fgeom->left_width;
- rect->y -= fgeom->top_height;
- rect->width += fgeom->left_width + fgeom->right_width;
- rect->height += fgeom->top_height + fgeom->bottom_height;
+ if (window->frame)
+ {
+ rect->x -= fgeom->left_width;
+ rect->y -= fgeom->top_height;
+ rect->width += fgeom->left_width + fgeom->right_width;
+ rect->height += fgeom->top_height + fgeom->bottom_height;
+ }
+ else
+ {
+ rect->x += window->custom_frame_extents.left;
+ rect->y += window->custom_frame_extents.top;
+ rect->width -= window->custom_frame_extents.left + window->custom_frame_extents.right;
+ rect->height -= window->custom_frame_extents.top + window->custom_frame_extents.bottom;
+ }
}
static void
-unextend_by_frame (MetaRectangle *rect,
+unextend_by_frame (MetaWindow *window,
+ MetaRectangle *rect,
const MetaFrameGeometry *fgeom)
{
- rect->x += fgeom->left_width;
- rect->y += fgeom->top_height;
- rect->width -= fgeom->left_width + fgeom->right_width;
- rect->height -= fgeom->top_height + fgeom->bottom_height;
+ if (window->frame)
+ {
+ rect->x += fgeom->left_width;
+ rect->y += fgeom->top_height;
+ rect->width -= fgeom->left_width + fgeom->right_width;
+ rect->height -= fgeom->top_height + fgeom->bottom_height;
+ }
+ else
+ {
+ rect->x -= window->custom_frame_extents.left;
+ rect->y -= window->custom_frame_extents.top;
+ rect->width += window->custom_frame_extents.left + window->custom_frame_extents.right;
+ rect->height += window->custom_frame_extents.top + window->custom_frame_extents.bottom;
+ }
}
static inline void
@@ -716,13 +740,41 @@ get_size_limits (const MetaWindow *window,
if (include_frame)
{
- int fw = fgeom->left_width + fgeom->right_width;
- int fh = fgeom->top_height + fgeom->bottom_height;
+ int fw;
+ int fh;
+
+ if (window->frame)
+ {
+ fw = fgeom->left_width + fgeom->right_width;
+ fh = fgeom->top_height + fgeom->bottom_height;
- min_size->width += fw;
- min_size->height += fh;
- max_size->width += fw;
- max_size->height += fh;
+ min_size->width += fw;
+ min_size->height += fh;
+
+ /* Do check to avoid overflow (e.g. max_size->width & max_size->height
+ * may be set to G_MAXINT by meta_set_normal_hints()).
+ */
+ if (max_size->width < (G_MAXINT - fw))
+ max_size->width += fw;
+ else
+ max_size->width = G_MAXINT;
+
+ if (max_size->height < (G_MAXINT - fh))
+ max_size->height += fh;
+ else
+ max_size->height = G_MAXINT;
+ }
+ else
+ {
+ fw = window->custom_frame_extents.left + window->custom_frame_extents.right;
+ fh = window->custom_frame_extents.top + window->custom_frame_extents.bottom;
+
+ min_size->width -= fw;
+ min_size->height -= fh;
+
+ max_size->width -= fw;
+ max_size->height -= fh;
+ }
}
}
@@ -770,14 +822,14 @@ constrain_maximization (MetaWindow *window,
active_workspace_struts = window->screen->active_workspace->all_struts;
target_size = info->current;
- extend_by_frame (&target_size, info->fgeom);
+ extend_by_frame (window, &target_size, info->fgeom);
meta_rectangle_expand_to_avoiding_struts (&target_size,
&info->entire_xinerama,
direction,
active_workspace_struts);
}
/* Now make target_size = maximized size of client window */
- unextend_by_frame (&target_size, info->fgeom);
+ unextend_by_frame (window, &target_size, info->fgeom);
/* Check min size constraints; max size constraints are ignored for maximized
* windows, as per bug 327543.
@@ -836,7 +888,7 @@ constrain_tiling (MetaWindow *window,
* use an external function for the actual calculation
*/
meta_window_get_current_tile_area (window, &target_size);
- unextend_by_frame (&target_size, info->fgeom);
+ unextend_by_frame (window, &target_size, info->fgeom);
/* Check min size constraints; max size constraints are ignored as for
* maximized windows.
@@ -1183,7 +1235,7 @@ do_screen_and_xinerama_relative_constraints (
/* Determine whether constraint applies; exit if it doesn't */
how_far_it_can_be_smushed = info->current;
get_size_limits (window, info->fgeom, TRUE, &min_size, &max_size);
- extend_by_frame (&info->current, info->fgeom);
+ extend_by_frame (window, &info->current, info->fgeom);
if (info->action_type != ACTION_MOVE)
{
@@ -1203,7 +1255,7 @@ do_screen_and_xinerama_relative_constraints (
&info->current);
if (exit_early || constraint_satisfied || check_only)
{
- unextend_by_frame (&info->current, info->fgeom);
+ unextend_by_frame (window, &info->current, info->fgeom);
return constraint_satisfied;
}
@@ -1227,7 +1279,7 @@ do_screen_and_xinerama_relative_constraints (
info->fixed_directions,
&info->current);
- unextend_by_frame (&info->current, info->fgeom);
+ unextend_by_frame (window, &info->current, info->fgeom);
return TRUE;
}