window: Unmanage rule placed window if ending up outside of parent
If a client maps a persistent popup with a placement rule, then resizes the parent window so that the popup ends up outside of the parent, unmanage the popup and log a warning about the client being buggy. https://gitlab.gnome.org/GNOME/mutter/merge_requests/496
This commit is contained in:

committed by
Florian Müllner

parent
f2d7165a52
commit
b4f1569640
@ -145,6 +145,8 @@ typedef struct
|
||||
*/
|
||||
GList *usable_screen_region;
|
||||
GList *usable_monitor_region;
|
||||
|
||||
gboolean should_unmanage;
|
||||
} ConstraintInfo;
|
||||
|
||||
static gboolean do_screen_and_monitor_relative_constraints (MetaWindow *window,
|
||||
@ -253,6 +255,14 @@ do_all_constraints (MetaWindow *window,
|
||||
satisfied = satisfied &&
|
||||
(*constraint->func) (window, info, priority, check_only);
|
||||
|
||||
if (info->should_unmanage)
|
||||
{
|
||||
meta_topic (META_DEBUG_GEOMETRY,
|
||||
"constraint %s wants to unmanage window.\n",
|
||||
constraint->name);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!check_only)
|
||||
{
|
||||
/* Log how the constraint modified the position */
|
||||
@ -312,6 +322,12 @@ meta_window_constrain (MetaWindow *window,
|
||||
*/
|
||||
satisfied = do_all_constraints (window, &info, priority, check_only);
|
||||
|
||||
if (info.should_unmanage)
|
||||
{
|
||||
meta_window_unmanage_on_idle (window);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Drop the least important constraints if we can't satisfy them all */
|
||||
priority++;
|
||||
}
|
||||
@ -421,6 +437,8 @@ setup_constraint_info (ConstraintInfo *info,
|
||||
info->usable_monitor_region =
|
||||
meta_workspace_get_onmonitor_region (cur_workspace, logical_monitor);
|
||||
|
||||
info->should_unmanage = FALSE;
|
||||
|
||||
/* Log all this information for debugging */
|
||||
meta_topic (META_DEBUG_GEOMETRY,
|
||||
"Setting up constraint info:\n"
|
||||
@ -802,6 +820,8 @@ constrain_custom_rule (MetaWindow *window,
|
||||
|
||||
if (window->placement_rule_constrained)
|
||||
{
|
||||
MetaRectangle parent_buffer_rect;
|
||||
|
||||
parent = meta_window_get_transient_for (window);
|
||||
meta_window_get_frame_rect (parent, &parent_rect);
|
||||
info->current.x =
|
||||
@ -809,6 +829,16 @@ constrain_custom_rule (MetaWindow *window,
|
||||
info->current.y =
|
||||
parent_rect.y + window->constrained_placement_rule_offset_y;
|
||||
|
||||
meta_window_get_buffer_rect (parent, &parent_buffer_rect);
|
||||
if (!meta_rectangle_overlap (&info->current, &parent_buffer_rect) &&
|
||||
!meta_rectangle_is_adjacent_to (&info->current, &parent_buffer_rect))
|
||||
{
|
||||
g_warning ("Buggy client caused popup to be placed outside of parent "
|
||||
"window");
|
||||
info->should_unmanage = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user