From 80e9482292437d4de84d234a3b847de345ce19af Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Tue, 18 May 2021 17:19:07 +0100 Subject: [PATCH] xdg-shell: Fail xdg_surface creation when surface has role If a given wl_surface already has a role (e.g. cursor or subsurface), there is nothing you can do with an xdg_surface which won't raise an error, apart from destroying it. As of wayland/wayland-protocols@11fecf080860 this is now explicitly specified to be illegal, so disallow it within libweston-desktop. This avoids us tying ourselves in knots with surface-private ownership. Signed-off-by: Daniel Stone --- libweston-desktop/xdg-shell.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libweston-desktop/xdg-shell.c b/libweston-desktop/xdg-shell.c index 00f8f015..6ebb22c0 100644 --- a/libweston-desktop/xdg-shell.c +++ b/libweston-desktop/xdg-shell.c @@ -1422,6 +1422,13 @@ weston_desktop_xdg_shell_protocol_get_xdg_surface(struct wl_client *wl_client, wl_resource_get_user_data(surface_resource); struct weston_desktop_xdg_surface *surface; + if (wsurface->committed) { + wl_resource_post_error(resource, + XDG_WM_BASE_ERROR_ROLE, + "xdg_surface must not have any other role"); + return; + } + if (wsurface->buffer_ref.buffer != NULL) { wl_resource_post_error(resource, XDG_SURFACE_ERROR_UNCONFIGURED_BUFFER,