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
This commit is contained in:
@ -118,7 +118,7 @@ typedef struct
|
||||
{
|
||||
MetaRectangle orig;
|
||||
MetaRectangle current;
|
||||
MetaFrameGeometry *fgeom;
|
||||
MetaFrameBorders *borders;
|
||||
ActionType action_type;
|
||||
gboolean is_user_action;
|
||||
|
||||
@ -194,7 +194,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,
|
||||
@ -204,11 +204,11 @@ static void place_window_if_needed (MetaWindow *window,
|
||||
static void update_onscreen_requirements (MetaWindow *window,
|
||||
ConstraintInfo *info);
|
||||
static void extend_by_frame (MetaRectangle *rect,
|
||||
const MetaFrameGeometry *fgeom);
|
||||
const MetaFrameBorders *borders);
|
||||
static void unextend_by_frame (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);
|
||||
@ -279,7 +279,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,
|
||||
@ -302,7 +302,7 @@ meta_window_constrain (MetaWindow *window,
|
||||
|
||||
setup_constraint_info (&info,
|
||||
window,
|
||||
orig_fgeom,
|
||||
orig_borders,
|
||||
flags,
|
||||
resize_gravity,
|
||||
orig,
|
||||
@ -337,14 +337,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,
|
||||
@ -357,10 +357,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;
|
||||
@ -461,7 +461,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"
|
||||
@ -471,8 +470,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" :
|
||||
@ -513,7 +510,7 @@ place_window_if_needed(MetaWindow *window,
|
||||
MetaWorkspace *cur_workspace;
|
||||
const MetaMonitorInfo *monitor_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;
|
||||
|
||||
@ -573,7 +570,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)
|
||||
{
|
||||
@ -634,7 +631,7 @@ update_onscreen_requirements (MetaWindow *window,
|
||||
/* The require onscreen/on-single-monitor and titlebar_visible
|
||||
* stuff is relative to the outer window, not the inner
|
||||
*/
|
||||
extend_by_frame (&info->current, info->fgeom);
|
||||
extend_by_frame (&info->current, info->borders);
|
||||
|
||||
/* Update whether we want future constraint runs to require the
|
||||
* window to be on fully onscreen.
|
||||
@ -670,7 +667,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,
|
||||
@ -683,32 +680,32 @@ 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 (&info->current, info->borders);
|
||||
}
|
||||
|
||||
static void
|
||||
extend_by_frame (MetaRectangle *rect,
|
||||
const MetaFrameGeometry *fgeom)
|
||||
const MetaFrameBorders *borders)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
static void
|
||||
unextend_by_frame (MetaRectangle *rect,
|
||||
const MetaFrameGeometry *fgeom)
|
||||
const MetaFrameBorders *borders)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
static inline void
|
||||
get_size_limits (const MetaWindow *window,
|
||||
const MetaFrameGeometry *fgeom,
|
||||
const MetaFrameBorders *borders,
|
||||
gboolean include_frame,
|
||||
MetaRectangle *min_size,
|
||||
MetaRectangle *max_size)
|
||||
@ -723,8 +720,8 @@ 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 = borders->visible.left + borders->visible.right;
|
||||
int fh = borders->visible.top + borders->visible.bottom;
|
||||
|
||||
min_size->width += fw;
|
||||
min_size->height += fh;
|
||||
@ -761,18 +758,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);
|
||||
|
||||
@ -831,19 +828,19 @@ 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 (&target_size, info->borders);
|
||||
meta_rectangle_expand_to_avoiding_struts (&target_size,
|
||||
&info->entire_monitor,
|
||||
direction,
|
||||
active_workspace_struts);
|
||||
}
|
||||
/* Now make target_size = maximized size of client window */
|
||||
unextend_by_frame (&target_size, info->fgeom);
|
||||
unextend_by_frame (&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)
|
||||
@ -897,12 +894,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 (&target_size, info->fgeom);
|
||||
unextend_by_frame (&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)
|
||||
@ -945,7 +942,7 @@ constrain_fullscreen (MetaWindow *window,
|
||||
|
||||
monitor = info->entire_monitor;
|
||||
|
||||
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 (&monitor, &min_size);
|
||||
too_small = !meta_rectangle_could_fit_rect (&max_size, &monitor);
|
||||
if (too_big || too_small)
|
||||
@ -1054,7 +1051,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);
|
||||
@ -1246,8 +1243,8 @@ do_screen_and_monitor_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);
|
||||
get_size_limits (window, info->borders, TRUE, &min_size, &max_size);
|
||||
extend_by_frame (&info->current, info->borders);
|
||||
|
||||
if (info->action_type != ACTION_MOVE)
|
||||
{
|
||||
@ -1267,7 +1264,7 @@ do_screen_and_monitor_relative_constraints (
|
||||
&info->current);
|
||||
if (exit_early || constraint_satisfied || check_only)
|
||||
{
|
||||
unextend_by_frame (&info->current, info->fgeom);
|
||||
unextend_by_frame (&info->current, info->borders);
|
||||
return constraint_satisfied;
|
||||
}
|
||||
|
||||
@ -1291,7 +1288,7 @@ do_screen_and_monitor_relative_constraints (
|
||||
info->fixed_directions,
|
||||
&info->current);
|
||||
|
||||
unextend_by_frame (&info->current, info->fgeom);
|
||||
unextend_by_frame (&info->current, info->borders);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -1404,8 +1401,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;
|
||||
@ -1479,8 +1476,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;
|
||||
|
Reference in New Issue
Block a user