xdg_shell: handle inert popups

xdg_popups can be destroyed by the compositor when closed. When this happens,
wlroots makes the xdg_popup surface inert and resets the xdg_surface role to
NONE.

Currently, wlroots sends a protocol error and asserts that an xdg_surface has
a role when committed. This is racy if at the same time the client commits an
xdg_popup and the compositor closes it. This patch removes the assertion and
ignores commits on xdg_surfaces without a role set.
This commit is contained in:
Ilia Bozhinov 2020-10-27 18:28:39 +01:00 committed by Simon Ser
parent 372a52ecc0
commit 9595f95452
1 changed files with 5 additions and 2 deletions

View File

@ -336,7 +336,9 @@ static void xdg_surface_handle_surface_commit(struct wl_listener *listener,
return; return;
} }
if (surface->role == WLR_XDG_SURFACE_ROLE_NONE) { // surface->role might be NONE for inert popups
// So we check surface->surface->role
if (surface->surface->role == NULL) {
wl_resource_post_error(surface->resource, wl_resource_post_error(surface->resource,
XDG_SURFACE_ERROR_NOT_CONSTRUCTED, XDG_SURFACE_ERROR_NOT_CONSTRUCTED,
"xdg_surface must have a role"); "xdg_surface must have a role");
@ -361,7 +363,8 @@ void handle_xdg_surface_commit(struct wlr_surface *wlr_surface) {
switch (surface->role) { switch (surface->role) {
case WLR_XDG_SURFACE_ROLE_NONE: case WLR_XDG_SURFACE_ROLE_NONE:
assert(false); // inert toplevel or popup
return;
case WLR_XDG_SURFACE_ROLE_TOPLEVEL: case WLR_XDG_SURFACE_ROLE_TOPLEVEL:
handle_xdg_surface_toplevel_committed(surface); handle_xdg_surface_toplevel_committed(surface);
break; break;