diff options
author | Jonas Ã…dahl <jadahl@gmail.com> | 2022-09-28 22:52:54 +0200 |
---|---|---|
committer | Robert Mader <robert.mader@posteo.de> | 2022-12-03 09:37:38 +0000 |
commit | c880f5e3e8db0355c09b695bf8c9cd5c09d1dd2f (patch) | |
tree | c0beacb9798f54476113e750504587a66e4042c5 | |
parent | dece0ab14dcdc45eb449bf6b1bba40a659610303 (diff) | |
download | mutter-c880f5e3e8db0355c09b695bf8c9cd5c09d1dd2f.tar.gz |
wayland/xdg-shell: Send xdg_popup.popup_done when position invalid
A client may provide a positioner that places the window outside of its
parent. This isn't allowed, according to spec, so we hide the window and
log a warning. This, however, leads these affected clients with an
incorrect view of what is mapped or not, meaning it becomes harder to
recover.
Fix this by sending xdg_popup.done when we hide the popup due to an
invalid position. Don't error out the client, let the bug slide, as
that's a less jarring experience for existing applications that
reproduce this than being disconnected, which practically feels like a
crash.
Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2408
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2645>
(cherry picked from commit ac093dc65142803601838d32dd85ed993892c7f3)
-rw-r--r-- | src/wayland/meta-wayland-xdg-shell.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/src/wayland/meta-wayland-xdg-shell.c b/src/wayland/meta-wayland-xdg-shell.c index 59a0f443e..78624e8a6 100644 --- a/src/wayland/meta-wayland-xdg-shell.c +++ b/src/wayland/meta-wayland-xdg-shell.c @@ -184,6 +184,12 @@ surface_from_xdg_toplevel_resource (struct wl_resource *resource) return surface_from_xdg_surface_resource (resource); } +static MetaWaylandXdgPopup * +meta_wayland_xdg_popup_from_surface (MetaWaylandSurface *surface) +{ + return META_WAYLAND_XDG_POPUP (surface->role); +} + static void meta_wayland_xdg_surface_reset (MetaWaylandXdgSurface *xdg_surface) { @@ -1130,6 +1136,37 @@ finish_popup_setup (MetaWaylandXdgPopup *xdg_popup) } static void +dismiss_invalid_popup (MetaWaylandXdgPopup *xdg_popup) +{ + if (xdg_popup->popup) + { + while (TRUE) + { + MetaWaylandSurface *top_popup_surface; + MetaWaylandXdgPopup *top_xdg_popup; + + top_popup_surface = + meta_wayland_popup_get_top_popup (xdg_popup->popup); + if (!top_popup_surface) + break; + + top_xdg_popup = meta_wayland_xdg_popup_from_surface (top_popup_surface); + + xdg_popup_send_popup_done (top_xdg_popup->resource); + meta_wayland_popup_destroy (top_xdg_popup->popup); + + if (top_xdg_popup == xdg_popup) + break; + } + } + else + { + xdg_popup_send_popup_done (xdg_popup->resource); + meta_wayland_xdg_popup_unmap (xdg_popup); + } +} + +static void meta_wayland_xdg_popup_apply_state (MetaWaylandSurfaceRole *surface_role, MetaWaylandSurfaceState *pending) { @@ -1206,7 +1243,7 @@ meta_wayland_xdg_popup_post_apply_state (MetaWaylandSurfaceRole *surface_role, { g_warning ("Buggy client caused popup to be placed outside of " "parent window"); - dismiss_popup (xdg_popup); + dismiss_invalid_popup (xdg_popup); } } |