constraints: Make current placement rule stack allocated

We're not going to keep it past the function scope, so no reason to put
it on the heap. We also didn't free it, so this'll fix a memory leak.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/653
This commit is contained in:
Jonas Ådahl 2018-10-20 15:46:37 +02:00
parent 76abe87090
commit 71a62bb18f

View File

@ -787,7 +787,7 @@ constrain_custom_rule (MetaWindow *window,
MetaPlacementRule *placement_rule;
MetaRectangle intersection;
gboolean constraint_satisfied;
MetaPlacementRule *current_rule;
MetaPlacementRule current_rule;
MetaWindow *parent;
MetaRectangle parent_rect;
@ -820,25 +820,24 @@ constrain_custom_rule (MetaWindow *window,
if (check_only)
return constraint_satisfied;
current_rule = g_new0 (MetaPlacementRule, 1);
*current_rule = *placement_rule;
current_rule = *placement_rule;
if (constraint_satisfied)
goto done;
if (info->current.width != intersection.width &&
(current_rule->constraint_adjustment &
(current_rule.constraint_adjustment &
META_PLACEMENT_CONSTRAINT_ADJUSTMENT_FLIP_X))
{
try_flip_window_position (window, info, current_rule,
try_flip_window_position (window, info, &current_rule,
META_PLACEMENT_CONSTRAINT_ADJUSTMENT_FLIP_X,
&info->current, &intersection);
}
if (info->current.height != intersection.height &&
(current_rule->constraint_adjustment &
(current_rule.constraint_adjustment &
META_PLACEMENT_CONSTRAINT_ADJUSTMENT_FLIP_Y))
{
try_flip_window_position (window, info, current_rule,
try_flip_window_position (window, info, &current_rule,
META_PLACEMENT_CONSTRAINT_ADJUSTMENT_FLIP_Y,
&info->current, &intersection);
}
@ -852,7 +851,7 @@ constrain_custom_rule (MetaWindow *window,
if (constraint_satisfied)
goto done;
if (current_rule->constraint_adjustment &
if (current_rule.constraint_adjustment &
META_PLACEMENT_CONSTRAINT_ADJUSTMENT_SLIDE_X)
{
if (info->current.x != intersection.x)
@ -860,7 +859,7 @@ constrain_custom_rule (MetaWindow *window,
else if (info->current.width != intersection.width)
info->current.x -= info->current.width - intersection.width;
}
if (current_rule->constraint_adjustment &
if (current_rule.constraint_adjustment &
META_PLACEMENT_CONSTRAINT_ADJUSTMENT_SLIDE_Y)
{
if (info->current.y != intersection.y)
@ -878,13 +877,13 @@ constrain_custom_rule (MetaWindow *window,
if (constraint_satisfied)
goto done;
if (current_rule->constraint_adjustment &
if (current_rule.constraint_adjustment &
META_PLACEMENT_CONSTRAINT_ADJUSTMENT_RESIZE_X)
{
info->current.x = intersection.x;
info->current.width = intersection.width;
}
if (current_rule->constraint_adjustment &
if (current_rule.constraint_adjustment &
META_PLACEMENT_CONSTRAINT_ADJUSTMENT_RESIZE_Y)
{
info->current.y = intersection.y;