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
@ -1616,24 +1616,16 @@ meta_window_actor_update_bounding_region_and_borders (MetaWindowActor *self,
|
|||||||
int height)
|
int height)
|
||||||
{
|
{
|
||||||
MetaWindowActorPrivate *priv = self->priv;
|
MetaWindowActorPrivate *priv = self->priv;
|
||||||
MetaFrame *frame;
|
|
||||||
MetaFrameBorders borders;
|
MetaFrameBorders borders;
|
||||||
cairo_rectangle_int_t bounding_rectangle;
|
cairo_rectangle_int_t bounding_rectangle;
|
||||||
|
|
||||||
bounding_rectangle.x = 0;
|
meta_frame_calc_borders (priv->window->frame, &borders);
|
||||||
bounding_rectangle.y = 0;
|
|
||||||
|
|
||||||
frame = priv->window->frame;
|
|
||||||
if (frame != NULL)
|
|
||||||
{
|
|
||||||
meta_frame_calc_borders (frame, &borders);
|
|
||||||
|
|
||||||
bounding_rectangle.x = borders.invisible.left;
|
bounding_rectangle.x = borders.invisible.left;
|
||||||
bounding_rectangle.y = borders.invisible.top;
|
bounding_rectangle.y = borders.invisible.top;
|
||||||
|
|
||||||
width -= borders.invisible.left + borders.invisible.right;
|
width -= borders.invisible.left + borders.invisible.right;
|
||||||
height -= borders.invisible.top + borders.invisible.bottom;
|
height -= borders.invisible.top + borders.invisible.bottom;
|
||||||
}
|
|
||||||
|
|
||||||
bounding_rectangle.width = width;
|
bounding_rectangle.width = width;
|
||||||
bounding_rectangle.height = height;
|
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_shaped_texture_set_shape_region (META_SHAPED_TEXTURE (priv->actor), NULL);
|
||||||
meta_window_actor_clear_shape_region (self);
|
meta_window_actor_clear_shape_region (self);
|
||||||
|
|
||||||
if (priv->window->frame)
|
|
||||||
meta_frame_calc_borders (priv->window->frame, &borders);
|
meta_frame_calc_borders (priv->window->frame, &borders);
|
||||||
else
|
|
||||||
meta_frame_borders_clear (&borders);
|
|
||||||
|
|
||||||
region = meta_window_get_frame_bounds (priv->window);
|
region = meta_window_get_frame_bounds (priv->window);
|
||||||
if (region != NULL)
|
if (region != NULL)
|
||||||
|
@ -573,7 +573,7 @@ place_window_if_needed(MetaWindow *window,
|
|||||||
META_MAXIMIZE_VERTICAL : 0), &info->current);
|
META_MAXIMIZE_VERTICAL : 0), &info->current);
|
||||||
|
|
||||||
/* maximization may have changed frame geometry */
|
/* maximization may have changed frame geometry */
|
||||||
if (window->frame && !window->fullscreen)
|
if (!window->fullscreen)
|
||||||
meta_frame_calc_borders (window->frame, info->borders);
|
meta_frame_calc_borders (window->frame, info->borders);
|
||||||
|
|
||||||
if (window->fullscreen_after_placement)
|
if (window->fullscreen_after_placement)
|
||||||
|
@ -322,6 +322,11 @@ void
|
|||||||
meta_frame_calc_borders (MetaFrame *frame,
|
meta_frame_calc_borders (MetaFrame *frame,
|
||||||
MetaFrameBorders *borders)
|
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,
|
meta_ui_get_frame_borders (frame->window->screen->ui,
|
||||||
frame->xwindow,
|
frame->xwindow,
|
||||||
borders);
|
borders);
|
||||||
|
@ -3704,6 +3704,7 @@ meta_window_can_tile_side_by_side (MetaWindow *window)
|
|||||||
{
|
{
|
||||||
const MetaMonitorInfo *monitor;
|
const MetaMonitorInfo *monitor;
|
||||||
MetaRectangle tile_area;
|
MetaRectangle tile_area;
|
||||||
|
MetaFrameBorders borders;
|
||||||
|
|
||||||
if (!meta_window_can_tile_maximized (window))
|
if (!meta_window_can_tile_maximized (window))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -3717,15 +3718,10 @@ meta_window_can_tile_side_by_side (MetaWindow *window)
|
|||||||
|
|
||||||
tile_area.width /= 2;
|
tile_area.width /= 2;
|
||||||
|
|
||||||
if (window->frame)
|
|
||||||
{
|
|
||||||
MetaFrameBorders borders;
|
|
||||||
|
|
||||||
meta_frame_calc_borders (window->frame, &borders);
|
meta_frame_calc_borders (window->frame, &borders);
|
||||||
|
|
||||||
tile_area.width -= (borders.visible.left + borders.visible.right);
|
tile_area.width -= (borders.visible.left + borders.visible.right);
|
||||||
tile_area.height -= (borders.visible.top + borders.visible.bottom);
|
tile_area.height -= (borders.visible.top + borders.visible.bottom);
|
||||||
}
|
|
||||||
|
|
||||||
return tile_area.width >= window->size_hints.min_width &&
|
return tile_area.width >= window->size_hints.min_width &&
|
||||||
tile_area.height >= window->size_hints.min_height;
|
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)" : "",
|
is_user_action ? " (user move/resize)" : "",
|
||||||
old_rect.x, old_rect.y, old_rect.width, old_rect.height);
|
old_rect.x, old_rect.y, old_rect.width, old_rect.height);
|
||||||
|
|
||||||
if (window->frame)
|
|
||||||
meta_frame_calc_borders (window->frame,
|
meta_frame_calc_borders (window->frame,
|
||||||
&borders);
|
&borders);
|
||||||
|
|
||||||
@ -5109,10 +5104,8 @@ meta_window_move_frame (MetaWindow *window,
|
|||||||
{
|
{
|
||||||
int x = root_x_nw;
|
int x = root_x_nw;
|
||||||
int y = root_y_nw;
|
int y = root_y_nw;
|
||||||
|
|
||||||
if (window->frame)
|
|
||||||
{
|
|
||||||
MetaFrameBorders borders;
|
MetaFrameBorders borders;
|
||||||
|
|
||||||
meta_frame_calc_borders (window->frame, &borders);
|
meta_frame_calc_borders (window->frame, &borders);
|
||||||
|
|
||||||
/* root_x_nw and root_y_nw correspond to where the top of
|
/* 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;
|
x += window->frame->child_x - borders.invisible.left;
|
||||||
y += window->frame->child_y - borders.invisible.top;
|
y += window->frame->child_y - borders.invisible.top;
|
||||||
}
|
|
||||||
meta_window_move (window, user_op, x, y);
|
meta_window_move (window, user_op, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5170,10 +5163,9 @@ meta_window_move_resize_frame (MetaWindow *window,
|
|||||||
int root_y_nw,
|
int root_y_nw,
|
||||||
int w,
|
int w,
|
||||||
int h)
|
int h)
|
||||||
{
|
|
||||||
if (window->frame)
|
|
||||||
{
|
{
|
||||||
MetaFrameBorders borders;
|
MetaFrameBorders borders;
|
||||||
|
|
||||||
meta_frame_calc_borders (window->frame, &borders);
|
meta_frame_calc_borders (window->frame, &borders);
|
||||||
/* offset by the distance between the origin of the window
|
/* offset by the distance between the origin of the window
|
||||||
* and the origin of the enclosing window decorations ( + border)
|
* 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;
|
root_y_nw += borders.visible.top;
|
||||||
w -= borders.visible.left + borders.visible.right;
|
w -= borders.visible.left + borders.visible.right;
|
||||||
h -= borders.visible.top + borders.visible.bottom;
|
h -= borders.visible.top + borders.visible.bottom;
|
||||||
}
|
|
||||||
meta_window_move_resize (window, user_op, root_x_nw, root_y_nw, w, h);
|
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
|
static void
|
||||||
update_net_frame_extents (MetaWindow *window)
|
update_net_frame_extents (MetaWindow *window)
|
||||||
{
|
{
|
||||||
unsigned long data[4] = { 0, 0, 0, 0 };
|
unsigned long data[4];
|
||||||
|
|
||||||
if (window->frame)
|
|
||||||
{
|
|
||||||
MetaFrameBorders borders;
|
MetaFrameBorders borders;
|
||||||
|
|
||||||
meta_frame_calc_borders (window->frame, &borders);
|
meta_frame_calc_borders (window->frame, &borders);
|
||||||
@ -5829,7 +5818,6 @@ update_net_frame_extents (MetaWindow *window)
|
|||||||
data[2] = borders.visible.top;
|
data[2] = borders.visible.top;
|
||||||
/* Bottom */
|
/* Bottom */
|
||||||
data[3] = borders.visible.bottom;
|
data[3] = borders.visible.bottom;
|
||||||
}
|
|
||||||
|
|
||||||
meta_topic (META_DEBUG_GEOMETRY,
|
meta_topic (META_DEBUG_GEOMETRY,
|
||||||
"Setting _NET_FRAME_EXTENTS on managed window 0x%lx "
|
"Setting _NET_FRAME_EXTENTS on managed window 0x%lx "
|
||||||
|
Loading…
Reference in New Issue
Block a user