diff --git a/src/core/constraints.c b/src/core/constraints.c index 82e19ee29..a205ea0fd 100644 --- a/src/core/constraints.c +++ b/src/core/constraints.c @@ -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; } diff --git a/src/core/window-private.h b/src/core/window-private.h index 60f8f5e8e..23662ca6a 100644 --- a/src/core/window-private.h +++ b/src/core/window-private.h @@ -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 diff --git a/src/core/window.c b/src/core/window.c index 79f0b2e39..aa6c568f5 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -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); }