Simplify the frame testing logic in callers to grab borders
A lot of code did something similar to: MetaFrameBorders borders; if (window->frame) meta_frame_calc_borders (window->frame, &borders); else meta_frame_borders_clear (&borders); Sometimes, the else part was omitted and we were unknowingly using uninitalized values for OR windows. Clean this up by just testing for a NULL frame in meta_frame_calc_borders and clearing for the caller if so. https://bugzilla.gnome.org/show_bug.cgi?id=643606
This commit is contained in:
parent
578b1c06c7
commit
8c1b2d5eda
4 changed files with 53 additions and 71 deletions
|
@ -1616,24 +1616,16 @@ meta_window_actor_update_bounding_region_and_borders (MetaWindowActor *self,
|
|||
int height)
|
||||
{
|
||||
MetaWindowActorPrivate *priv = self->priv;
|
||||
MetaFrame *frame;
|
||||
MetaFrameBorders borders;
|
||||
cairo_rectangle_int_t bounding_rectangle;
|
||||
|
||||
bounding_rectangle.x = 0;
|
||||
bounding_rectangle.y = 0;
|
||||
|
||||
frame = priv->window->frame;
|
||||
if (frame != NULL)
|
||||
{
|
||||
meta_frame_calc_borders (frame, &borders);
|
||||
meta_frame_calc_borders (priv->window->frame, &borders);
|
||||
|
||||
bounding_rectangle.x = borders.invisible.left;
|
||||
bounding_rectangle.y = borders.invisible.top;
|
||||
|
||||
width -= borders.invisible.left + borders.invisible.right;
|
||||
height -= borders.invisible.top + borders.invisible.bottom;
|
||||
}
|
||||
|
||||
bounding_rectangle.width = width;
|
||||
bounding_rectangle.height = height;
|
||||
|
@ -2163,10 +2155,7 @@ check_needs_reshape (MetaWindowActor *self)
|
|||
meta_shaped_texture_set_shape_region (META_SHAPED_TEXTURE (priv->actor), NULL);
|
||||
meta_window_actor_clear_shape_region (self);
|
||||
|
||||
if (priv->window->frame)
|
||||
meta_frame_calc_borders (priv->window->frame, &borders);
|
||||
else
|
||||
meta_frame_borders_clear (&borders);
|
||||
|
||||
region = meta_window_get_frame_bounds (priv->window);
|
||||
if (region != NULL)
|
||||
|
|
|
@ -573,7 +573,7 @@ place_window_if_needed(MetaWindow *window,
|
|||
META_MAXIMIZE_VERTICAL : 0), &info->current);
|
||||
|
||||
/* maximization may have changed frame geometry */
|
||||
if (window->frame && !window->fullscreen)
|
||||
if (!window->fullscreen)
|
||||
meta_frame_calc_borders (window->frame, info->borders);
|
||||
|
||||
if (window->fullscreen_after_placement)
|
||||
|
|
|
@ -322,6 +322,11 @@ void
|
|||
meta_frame_calc_borders (MetaFrame *frame,
|
||||
MetaFrameBorders *borders)
|
||||
{
|
||||
/* Save on if statements and potential uninitialized values
|
||||
* in callers -- if there's no frame, then zero the borders. */
|
||||
if (frame == NULL)
|
||||
meta_frame_borders_clear (borders);
|
||||
else
|
||||
meta_ui_get_frame_borders (frame->window->screen->ui,
|
||||
frame->xwindow,
|
||||
borders);
|
||||
|
|
|
@ -3704,6 +3704,7 @@ meta_window_can_tile_side_by_side (MetaWindow *window)
|
|||
{
|
||||
const MetaMonitorInfo *monitor;
|
||||
MetaRectangle tile_area;
|
||||
MetaFrameBorders borders;
|
||||
|
||||
if (!meta_window_can_tile_maximized (window))
|
||||
return FALSE;
|
||||
|
@ -3717,15 +3718,10 @@ meta_window_can_tile_side_by_side (MetaWindow *window)
|
|||
|
||||
tile_area.width /= 2;
|
||||
|
||||
if (window->frame)
|
||||
{
|
||||
MetaFrameBorders borders;
|
||||
|
||||
meta_frame_calc_borders (window->frame, &borders);
|
||||
|
||||
tile_area.width -= (borders.visible.left + borders.visible.right);
|
||||
tile_area.height -= (borders.visible.top + borders.visible.bottom);
|
||||
}
|
||||
|
||||
return tile_area.width >= window->size_hints.min_width &&
|
||||
tile_area.height >= window->size_hints.min_height;
|
||||
|
@ -4646,7 +4642,6 @@ meta_window_move_resize_internal (MetaWindow *window,
|
|||
is_user_action ? " (user move/resize)" : "",
|
||||
old_rect.x, old_rect.y, old_rect.width, old_rect.height);
|
||||
|
||||
if (window->frame)
|
||||
meta_frame_calc_borders (window->frame,
|
||||
&borders);
|
||||
|
||||
|
@ -5109,10 +5104,8 @@ meta_window_move_frame (MetaWindow *window,
|
|||
{
|
||||
int x = root_x_nw;
|
||||
int y = root_y_nw;
|
||||
|
||||
if (window->frame)
|
||||
{
|
||||
MetaFrameBorders borders;
|
||||
|
||||
meta_frame_calc_borders (window->frame, &borders);
|
||||
|
||||
/* root_x_nw and root_y_nw correspond to where the top of
|
||||
|
@ -5122,7 +5115,7 @@ meta_window_move_frame (MetaWindow *window,
|
|||
*/
|
||||
x += window->frame->child_x - borders.invisible.left;
|
||||
y += window->frame->child_y - borders.invisible.top;
|
||||
}
|
||||
|
||||
meta_window_move (window, user_op, x, y);
|
||||
}
|
||||
|
||||
|
@ -5171,9 +5164,8 @@ meta_window_move_resize_frame (MetaWindow *window,
|
|||
int w,
|
||||
int h)
|
||||
{
|
||||
if (window->frame)
|
||||
{
|
||||
MetaFrameBorders borders;
|
||||
|
||||
meta_frame_calc_borders (window->frame, &borders);
|
||||
/* offset by the distance between the origin of the window
|
||||
* and the origin of the enclosing window decorations ( + border)
|
||||
|
@ -5182,7 +5174,7 @@ meta_window_move_resize_frame (MetaWindow *window,
|
|||
root_y_nw += borders.visible.top;
|
||||
w -= borders.visible.left + borders.visible.right;
|
||||
h -= borders.visible.top + borders.visible.bottom;
|
||||
}
|
||||
|
||||
meta_window_move_resize (window, user_op, root_x_nw, root_y_nw, w, h);
|
||||
}
|
||||
|
||||
|
@ -5814,10 +5806,7 @@ meta_window_get_net_wm_desktop (MetaWindow *window)
|
|||
static void
|
||||
update_net_frame_extents (MetaWindow *window)
|
||||
{
|
||||
unsigned long data[4] = { 0, 0, 0, 0 };
|
||||
|
||||
if (window->frame)
|
||||
{
|
||||
unsigned long data[4];
|
||||
MetaFrameBorders borders;
|
||||
|
||||
meta_frame_calc_borders (window->frame, &borders);
|
||||
|
@ -5829,7 +5818,6 @@ update_net_frame_extents (MetaWindow *window)
|
|||
data[2] = borders.visible.top;
|
||||
/* Bottom */
|
||||
data[3] = borders.visible.bottom;
|
||||
}
|
||||
|
||||
meta_topic (META_DEBUG_GEOMETRY,
|
||||
"Setting _NET_FRAME_EXTENTS on managed window 0x%lx "
|
||||
|
|
Loading…
Reference in a new issue