diff options
author | Victor Kareh <[email protected]> | 2019-04-12 07:58:30 -0400 |
---|---|---|
committer | Victor Kareh <[email protected]> | 2019-06-05 10:49:37 -0400 |
commit | c66b32666e48996b97e691ed002f86b6ff18dec5 (patch) | |
tree | 3e5d1b07331ab708cac920fcfe62e504aa2481ad /src/core/constraints.c | |
parent | 707eb409e7dfeec276f6dfa3e667a0140b3300aa (diff) | |
download | marco-c66b32666e48996b97e691ed002f86b6ff18dec5.tar.bz2 marco-c66b32666e48996b97e691ed002f86b6ff18dec5.tar.xz |
Replace public MetaFrameGeometry with MetaFrameBorders
There were actually *two* MetaFrameGeometry structs: one in theme-private.h,
one in frame.h. The latter public struct was populated by a mix of (void*)
casting and int pointers, usually pulling directly from the data in the private
struct.
Remove the public struct, replace it with MetaFrameBorders and scrap all
the pointer hacks to populate it, instead relying on both structs being used
in common code.
This commit should be relatively straightforward, and it should not do any
tricky logic at all, just a sophisticated find and replace.
https://bugzilla.gnome.org/show_bug.cgi?id=644930
upstream commit: https://gitlab.gnome.org/GNOME/metacity/commit/72224a165
NOTE: Patch copied from metacity and adapted for marco.
Diffstat (limited to 'src/core/constraints.c')
-rw-r--r-- | src/core/constraints.c | 105 |
1 files changed, 51 insertions, 54 deletions
diff --git a/src/core/constraints.c b/src/core/constraints.c index 2c56c780..1eaed498 100644 --- a/src/core/constraints.c +++ b/src/core/constraints.c @@ -117,7 +117,7 @@ typedef struct { MetaRectangle orig; MetaRectangle current; - MetaFrameGeometry *fgeom; + MetaFrameBorders *borders; ActionType action_type; gboolean is_user_action; @@ -189,7 +189,7 @@ static gboolean constrain_partially_onscreen (MetaWindow *window, static void setup_constraint_info (ConstraintInfo *info, MetaWindow *window, - MetaFrameGeometry *orig_fgeom, + MetaFrameBorders *orig_borders, MetaMoveResizeFlags flags, int resize_gravity, const MetaRectangle *orig, @@ -200,12 +200,12 @@ static void update_onscreen_requirements (MetaWindow *window, ConstraintInfo *info); static void extend_by_frame (MetaWindow *window, MetaRectangle *rect, - const MetaFrameGeometry *fgeom); + const MetaFrameBorders *borders); static void unextend_by_frame (MetaWindow *window, MetaRectangle *rect, - const MetaFrameGeometry *fgeom); + const MetaFrameBorders *borders); static inline void get_size_limits (const MetaWindow *window, - const MetaFrameGeometry *fgeom, + const MetaFrameBorders *borders, gboolean include_frame, MetaRectangle *min_size, MetaRectangle *max_size); @@ -281,7 +281,7 @@ do_all_constraints (MetaWindow *window, void meta_window_constrain (MetaWindow *window, - MetaFrameGeometry *orig_fgeom, + MetaFrameBorders *orig_borders, MetaMoveResizeFlags flags, int resize_gravity, const MetaRectangle *orig, @@ -304,7 +304,7 @@ meta_window_constrain (MetaWindow *window, setup_constraint_info (&info, window, - orig_fgeom, + orig_borders, flags, resize_gravity, orig, @@ -339,14 +339,14 @@ meta_window_constrain (MetaWindow *window, * not gobject-style--gobject would be more pain than it's worth) or * smart pointers would be so much nicer here. *shrug* */ - if (!orig_fgeom) - g_free (info.fgeom); + if (!orig_borders) + g_free (info.borders); } static void setup_constraint_info (ConstraintInfo *info, MetaWindow *window, - MetaFrameGeometry *orig_fgeom, + MetaFrameBorders *orig_borders, MetaMoveResizeFlags flags, int resize_gravity, const MetaRectangle *orig, @@ -359,10 +359,10 @@ setup_constraint_info (ConstraintInfo *info, info->current = *new; /* Create a fake frame geometry if none really exists */ - if (orig_fgeom && !window->fullscreen) - info->fgeom = orig_fgeom; + if (orig_borders && !window->fullscreen) + info->borders = orig_borders; else - info->fgeom = g_new0 (MetaFrameGeometry, 1); + info->borders = g_new0 (MetaFrameBorders, 1); if (flags & META_IS_MOVE_ACTION && flags & META_IS_RESIZE_ACTION) info->action_type = ACTION_MOVE_AND_RESIZE; @@ -469,7 +469,6 @@ setup_constraint_info (ConstraintInfo *info, "Setting up constraint info:\n" " orig: %d,%d +%d,%d\n" " new : %d,%d +%d,%d\n" - " fgeom: %d,%d,%d,%d\n" " action_type : %s\n" " is_user_action : %s\n" " resize_gravity : %s\n" @@ -479,8 +478,6 @@ setup_constraint_info (ConstraintInfo *info, info->orig.x, info->orig.y, info->orig.width, info->orig.height, info->current.x, info->current.y, info->current.width, info->current.height, - info->fgeom->left_width, info->fgeom->right_width, - info->fgeom->top_height, info->fgeom->bottom_height, (info->action_type == ACTION_MOVE) ? "Move" : (info->action_type == ACTION_RESIZE) ? "Resize" : (info->action_type == ACTION_MOVE_AND_RESIZE) ? "Move&Resize" : @@ -521,7 +518,7 @@ place_window_if_needed(MetaWindow *window, MetaWorkspace *cur_workspace; const MetaXineramaScreenInfo *xinerama_info; - meta_window_place (window, info->fgeom, info->orig.x, info->orig.y, + meta_window_place (window, info->borders, info->orig.x, info->orig.y, &placed_rect.x, &placed_rect.y); did_placement = TRUE; @@ -581,7 +578,7 @@ place_window_if_needed(MetaWindow *window, /* maximization may have changed frame geometry */ if (window->frame && !window->fullscreen) - meta_frame_calc_geometry (window->frame, info->fgeom); + meta_frame_calc_borders (window->frame, info->borders); if (window->fullscreen_after_placement) { @@ -639,7 +636,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 (window, &info->current, info->fgeom); + extend_by_frame (window, &info->current, info->borders); /* Update whether we want future constraint runs to require the * window to be on fully onscreen. @@ -675,7 +672,7 @@ update_onscreen_requirements (MetaWindow *window, MetaRectangle titlebar_rect; titlebar_rect = info->current; - titlebar_rect.height = info->fgeom->top_height; + titlebar_rect.height = info->borders->visible.top; old = window->require_titlebar_visible; window->require_titlebar_visible = meta_rectangle_overlaps_with_region (info->usable_screen_region, @@ -688,20 +685,20 @@ update_onscreen_requirements (MetaWindow *window, } /* Don't forget to restore the position of the window */ - unextend_by_frame (window, &info->current, info->fgeom); + unextend_by_frame (window, &info->current, info->borders); } static void extend_by_frame (MetaWindow *window, MetaRectangle *rect, - const MetaFrameGeometry *fgeom) + const MetaFrameBorders *borders) { 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; + rect->x -= borders->visible.left; + rect->y -= borders->visible.top; + rect->width += borders->visible.left + borders->visible.right; + rect->height += borders->visible.top + borders->visible.bottom; } else { @@ -715,14 +712,14 @@ extend_by_frame (MetaWindow *window, static void unextend_by_frame (MetaWindow *window, MetaRectangle *rect, - const MetaFrameGeometry *fgeom) + const MetaFrameBorders *borders) { 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; + rect->x += borders->visible.left; + rect->y += borders->visible.top; + rect->width -= borders->visible.left + borders->visible.right; + rect->height -= borders->visible.top + borders->visible.bottom; } else { @@ -735,7 +732,7 @@ unextend_by_frame (MetaWindow *window, static inline void get_size_limits (const MetaWindow *window, - const MetaFrameGeometry *fgeom, + const MetaFrameBorders *borders, gboolean include_frame, MetaRectangle *min_size, MetaRectangle *max_size) @@ -755,8 +752,8 @@ get_size_limits (const MetaWindow *window, if (window->frame) { - fw = fgeom->left_width + fgeom->right_width; - fh = fgeom->top_height + fgeom->bottom_height; + fw = borders->visible.left + borders->visible.right; + fh = borders->visible.top + borders->visible.bottom; min_size->width += fw; min_size->height += fh; @@ -807,18 +804,18 @@ constrain_modal_dialog (MetaWindow *window, y = 0; if (parent->frame) { - MetaFrameGeometry fgeom; + MetaFrameBorders borders; x += parent->frame->rect.x; y += parent->frame->rect.y; - meta_frame_calc_geometry (parent->frame, &fgeom); - y += fgeom.top_height; + meta_frame_calc_borders (parent->frame, &borders); + y += borders.visible.top; - y += info->fgeom->top_height; + y += info->borders->visible.top; } else - y = parent->rect.y + info->fgeom->top_height; + y = parent->rect.y + info->borders->visible.top; constraint_already_satisfied = (x == info->current.x) && (y == info->current.y); @@ -874,19 +871,19 @@ constrain_maximization (MetaWindow *window, active_workspace_struts = window->screen->active_workspace->all_struts; target_size = info->current; - extend_by_frame (window, &target_size, info->fgeom); + extend_by_frame (window, &target_size, info->borders); 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 (window, &target_size, info->fgeom); + unextend_by_frame (window, &target_size, info->borders); /* Check min size constraints; max size constraints are ignored for maximized * windows, as per bug 327543. */ - get_size_limits (window, info->fgeom, FALSE, &min_size, &max_size); + get_size_limits (window, info->borders, FALSE, &min_size, &max_size); hminbad = target_size.width < min_size.width && window->maximized_horizontally; vminbad = target_size.height < min_size.height && window->maximized_vertically; if (hminbad || vminbad) @@ -942,12 +939,12 @@ constrain_tiling (MetaWindow *window, * use an external function for the actual calculation */ meta_window_get_current_tile_area (window, &target_size); - unextend_by_frame (window, &target_size, info->fgeom); + unextend_by_frame (window, &target_size, info->borders); /* Check min size constraints; max size constraints are ignored as for * maximized windows. */ - get_size_limits (window, info->fgeom, FALSE, &min_size, &max_size); + get_size_limits (window, info->borders, FALSE, &min_size, &max_size); hminbad = target_size.width < min_size.width; vminbad = target_size.height < min_size.height; if (hminbad || vminbad) @@ -1095,7 +1092,7 @@ constrain_fullscreen (MetaWindow *window, xinerama = info->entire_xinerama; - get_size_limits (window, info->fgeom, FALSE, &min_size, &max_size); + get_size_limits (window, info->borders, FALSE, &min_size, &max_size); too_big = !meta_rectangle_could_fit_rect (&xinerama, &min_size); too_small = !meta_rectangle_could_fit_rect (&max_size, &xinerama); if (too_big || too_small) @@ -1203,7 +1200,7 @@ constrain_size_limits (MetaWindow *window, return TRUE; /* Determine whether constraint is already satisfied; exit if it is */ - get_size_limits (window, info->fgeom, FALSE, &min_size, &max_size); + get_size_limits (window, info->borders, FALSE, &min_size, &max_size); /* We ignore max-size limits for maximized windows; see #327543 */ if (window->maximized_horizontally) max_size.width = MAX (max_size.width, info->current.width); @@ -1394,8 +1391,8 @@ 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 (window, &info->current, info->fgeom); + get_size_limits (window, info->borders, TRUE, &min_size, &max_size); + extend_by_frame (window, &info->current, info->borders); if (info->action_type != ACTION_MOVE) { @@ -1415,7 +1412,7 @@ do_screen_and_xinerama_relative_constraints ( &info->current); if (exit_early || constraint_satisfied || check_only) { - unextend_by_frame (window, &info->current, info->fgeom); + unextend_by_frame (window, &info->current, info->borders); return constraint_satisfied; } @@ -1439,7 +1436,7 @@ do_screen_and_xinerama_relative_constraints ( info->fixed_directions, &info->current); - unextend_by_frame (window, &info->current, info->fgeom); + unextend_by_frame (window, &info->current, info->borders); return TRUE; } @@ -1551,8 +1548,8 @@ constrain_titlebar_visible (MetaWindow *window, */ if (window->frame) { - bottom_amount = info->current.height + info->fgeom->bottom_height; - vert_amount_onscreen = info->fgeom->top_height; + bottom_amount = info->current.height + info->borders->visible.bottom; + vert_amount_onscreen = info->borders->visible.top; } else bottom_amount = vert_amount_offscreen; @@ -1626,8 +1623,8 @@ constrain_partially_onscreen (MetaWindow *window, */ if (window->frame) { - bottom_amount = info->current.height + info->fgeom->bottom_height; - vert_amount_onscreen = info->fgeom->top_height; + bottom_amount = info->current.height + info->borders->visible.bottom; + vert_amount_onscreen = info->borders->visible.top; } else bottom_amount = vert_amount_offscreen; |