wayland: Let MetaWaylandXdgPopup dismiss incorrectly placed popups
It's a xdg_popup detail, and not until the actual position is finalized is the actual correctness known. https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
This commit is contained in:
parent
d02c124e1d
commit
132fbf49d7
@ -145,8 +145,6 @@ typedef struct
|
||||
*/
|
||||
GList *usable_screen_region;
|
||||
GList *usable_monitor_region;
|
||||
|
||||
gboolean should_unmanage;
|
||||
} ConstraintInfo;
|
||||
|
||||
static gboolean do_screen_and_monitor_relative_constraints (MetaWindow *window,
|
||||
@ -255,14 +253,6 @@ 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 */
|
||||
@ -322,12 +312,6 @@ 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++;
|
||||
}
|
||||
@ -439,8 +423,6 @@ 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"
|
||||
@ -855,27 +837,8 @@ constrain_custom_rule (MetaWindow *window,
|
||||
switch (window->placement_state)
|
||||
{
|
||||
case META_PLACEMENT_STATE_CONSTRAINED:
|
||||
{
|
||||
MetaRectangle parent_buffer_rect;
|
||||
|
||||
meta_window_get_buffer_rect (parent, &parent_buffer_rect);
|
||||
if (!meta_rectangle_overlap (&adjusted_unconstrained,
|
||||
&parent_buffer_rect) &&
|
||||
!meta_rectangle_is_adjacent_to (&adjusted_unconstrained,
|
||||
&parent_buffer_rect))
|
||||
{
|
||||
g_warning ("Buggy client caused popup to be placed outside of "
|
||||
"parent window");
|
||||
info->should_unmanage = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
info->current = adjusted_unconstrained;
|
||||
goto done;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case META_PLACEMENT_STATE_UNCONSTRAINED:
|
||||
break;
|
||||
}
|
||||
|
@ -1600,32 +1600,6 @@ meta_window_unmanage (MetaWindow *window,
|
||||
g_object_unref (window);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
unmanage_window_idle_callback (gpointer user_data)
|
||||
{
|
||||
MetaWindow *window = META_WINDOW (user_data);
|
||||
uint32_t timestamp;
|
||||
|
||||
window->unmanage_idle_id = 0;
|
||||
|
||||
timestamp = meta_display_get_current_time_roundtrip (window->display);
|
||||
meta_window_unmanage (window, timestamp);
|
||||
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
void
|
||||
meta_window_unmanage_on_idle (MetaWindow *window)
|
||||
{
|
||||
if (window->unmanage_idle_id)
|
||||
return;
|
||||
|
||||
window->unmanage_idle_id = g_idle_add_full (G_PRIORITY_HIGH_IDLE,
|
||||
unmanage_window_idle_callback,
|
||||
window,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
set_wm_state (MetaWindow *window)
|
||||
{
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "wayland/meta-wayland-xdg-shell.h"
|
||||
|
||||
#include "backends/meta-logical-monitor.h"
|
||||
#include "core/boxes-private.h"
|
||||
#include "core/window-private.h"
|
||||
#include "wayland/meta-wayland-outputs.h"
|
||||
#include "wayland/meta-wayland-popup.h"
|
||||
@ -511,16 +512,22 @@ meta_wayland_xdg_popup_unmap (MetaWaylandXdgPopup *xdg_popup)
|
||||
meta_wayland_shell_surface_destroy_window (shell_surface);
|
||||
}
|
||||
|
||||
static void
|
||||
dismiss_popup (MetaWaylandXdgPopup *xdg_popup)
|
||||
{
|
||||
if (xdg_popup->popup)
|
||||
meta_wayland_popup_dismiss (xdg_popup->popup);
|
||||
else
|
||||
meta_wayland_xdg_popup_unmap (xdg_popup);
|
||||
}
|
||||
|
||||
static void
|
||||
xdg_popup_destructor (struct wl_resource *resource)
|
||||
{
|
||||
MetaWaylandXdgPopup *xdg_popup =
|
||||
META_WAYLAND_XDG_POPUP (wl_resource_get_user_data (resource));
|
||||
|
||||
if (xdg_popup->popup)
|
||||
meta_wayland_popup_dismiss (xdg_popup->popup);
|
||||
else
|
||||
meta_wayland_xdg_popup_unmap (xdg_popup);
|
||||
dismiss_popup (xdg_popup);
|
||||
|
||||
xdg_popup->resource = NULL;
|
||||
}
|
||||
@ -1031,6 +1038,9 @@ meta_wayland_xdg_popup_apply_state (MetaWaylandSurfaceRole *surface_role,
|
||||
MetaWaylandSurface *surface =
|
||||
meta_wayland_surface_role_get_surface (surface_role);
|
||||
MetaWindow *window;
|
||||
MetaRectangle buffer_rect;
|
||||
MetaWindow *parent_window;
|
||||
MetaRectangle parent_buffer_rect;
|
||||
|
||||
if (xdg_popup->setup.parent_surface)
|
||||
finish_popup_setup (xdg_popup);
|
||||
@ -1072,6 +1082,17 @@ meta_wayland_xdg_popup_apply_state (MetaWaylandSurfaceRole *surface_role,
|
||||
window_geometry = meta_wayland_xdg_surface_get_window_geometry (xdg_surface);
|
||||
meta_window_wayland_finish_move_resize (window, window_geometry, pending);
|
||||
}
|
||||
|
||||
parent_window = xdg_popup->parent_surface->window;
|
||||
meta_window_get_buffer_rect (window, &buffer_rect);
|
||||
meta_window_get_buffer_rect (parent_window, &parent_buffer_rect);
|
||||
if (!meta_rectangle_overlap (&buffer_rect, &parent_buffer_rect) &&
|
||||
!meta_rectangle_is_adjacent_to (&buffer_rect, &parent_buffer_rect))
|
||||
{
|
||||
g_warning ("Buggy client caused popup to be placed outside of "
|
||||
"parent window");
|
||||
dismiss_popup (xdg_popup);
|
||||
}
|
||||
}
|
||||
|
||||
static MetaWaylandSurface *
|
||||
@ -1092,10 +1113,7 @@ meta_wayland_xdg_popup_reset (MetaWaylandXdgSurface *xdg_surface)
|
||||
MetaWaylandXdgSurfaceClass *xdg_surface_class =
|
||||
META_WAYLAND_XDG_SURFACE_CLASS (meta_wayland_xdg_popup_parent_class);
|
||||
|
||||
if (xdg_popup->popup)
|
||||
meta_wayland_popup_dismiss (xdg_popup->popup);
|
||||
else
|
||||
meta_wayland_xdg_popup_unmap (xdg_popup);
|
||||
dismiss_popup (xdg_popup);
|
||||
|
||||
xdg_popup->dismissed_by_client = TRUE;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user