mirror of
https://github.com/brl/mutter.git
synced 2025-01-22 09:29:25 +00:00
window: Remember relative position after constraining with custom rule
In order to allow a window with a custom rule placement to be moved together with its parent, the final rule used derived from the constraining were used for subsequent constraints. This was not enough as some constraining cannot be translated into a rule, such as sliding across some axis. Instead, make it a bit simpler and just remember the position relative to the parent window, and use that the next time. This is a rework of 5376c31a33020d7dc5a69b129f2dd4f42d0890a1 which caused the unwanted side effects. Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/332
This commit is contained in:
parent
6267732bec
commit
fa1add2ee6
@ -788,6 +788,8 @@ constrain_custom_rule (MetaWindow *window,
|
||||
MetaRectangle intersection;
|
||||
gboolean constraint_satisfied;
|
||||
MetaPlacementRule *current_rule;
|
||||
MetaWindow *parent;
|
||||
MetaRectangle parent_rect;
|
||||
|
||||
if (priority > PRIORITY_CUSTOM_RULE)
|
||||
return TRUE;
|
||||
@ -796,11 +798,15 @@ constrain_custom_rule (MetaWindow *window,
|
||||
if (!placement_rule)
|
||||
return TRUE;
|
||||
|
||||
if (window->constrained_placement_rule)
|
||||
if (window->placement_rule_constrained)
|
||||
{
|
||||
meta_window_process_placement (window,
|
||||
window->constrained_placement_rule,
|
||||
&info->current.x, &info->current.y);
|
||||
parent = meta_window_get_transient_for (window);
|
||||
meta_window_get_frame_rect (parent, &parent_rect);
|
||||
info->current.x =
|
||||
parent_rect.x + window->constrained_placement_rule_offset_x;
|
||||
info->current.y =
|
||||
parent_rect.y + window->constrained_placement_rule_offset_y;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -886,8 +892,12 @@ constrain_custom_rule (MetaWindow *window,
|
||||
}
|
||||
|
||||
done:
|
||||
g_clear_pointer (&window->constrained_placement_rule, g_free);
|
||||
window->constrained_placement_rule = current_rule;
|
||||
window->placement_rule_constrained = TRUE;
|
||||
|
||||
parent = meta_window_get_transient_for (window);
|
||||
meta_window_get_frame_rect (parent, &parent_rect);
|
||||
window->constrained_placement_rule_offset_x = info->current.x - parent_rect.x;
|
||||
window->constrained_placement_rule_offset_y = info->current.y - parent_rect.y;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -524,7 +524,9 @@ struct _MetaWindow
|
||||
guint bypass_compositor;
|
||||
|
||||
MetaPlacementRule *placement_rule;
|
||||
MetaPlacementRule *constrained_placement_rule;
|
||||
gboolean placement_rule_constrained;
|
||||
int constrained_placement_rule_offset_x;
|
||||
int constrained_placement_rule_offset_y;
|
||||
};
|
||||
|
||||
struct _MetaWindowClass
|
||||
|
@ -313,7 +313,6 @@ meta_window_finalize (GObject *object)
|
||||
g_free (window->gtk_app_menu_object_path);
|
||||
g_free (window->gtk_menubar_object_path);
|
||||
g_free (window->placement_rule);
|
||||
g_free (window->constrained_placement_rule);
|
||||
|
||||
G_OBJECT_CLASS (meta_window_parent_class)->finalize (object);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user