From d1ea5d6ca2e0902bd5347d6e7741a69f87601540 Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Fri, 5 Dec 2025 11:08:35 +0100 Subject: [PATCH] xwayland: Avoid spurious surface commit running rootfull We cannot commit the Wayland surface before it gets a surface attached. Not doing so may cause mutter to log a warning when Xwayland is started rootful: | Buggy client (org.freedesktop.Xwayland) committed initial non-empty | content without acknowledging configuration, working around. Or running rootful with decorate: Wayland surface in handle_libdecor_configure() as this also generates warnings with mutter: | Client provided invalid window geometry for xdg_surface#nn | (org.freedesktop.Xwayland - Wnn (Xwayland on :nn)). Working around. | | Buggy client (org.freedesktop.Xwayland) committed initial non-empty | content without acknowledging configuration, working around. This is actually mutter being nice, as this should be treated as a protocol error and Xwayland would be terminated. Signed-off-by: Olivier Fourdan Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1853 Fixes: 295fb7165 - xwayland: Commit after acknowledging configure Fixes: d370f1e58 - xwayland: add fullscreen mode for rootful --- hw/xwayland/xwayland-window.c | 13 +++++++++++-- hw/xwayland/xwayland-window.h | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/hw/xwayland/xwayland-window.c b/hw/xwayland/xwayland-window.c index dac4b4ed6..990deb3a8 100644 --- a/hw/xwayland/xwayland-window.c +++ b/hw/xwayland/xwayland-window.c @@ -360,6 +360,13 @@ unregister_damage(struct xwl_window *xwl_window) dixSetPrivate(&surface_window->devPrivates, &xwl_damage_private_key, NULL); } +static void +xwl_window_maybe_commit_surface(struct xwl_window *xwl_window) +{ + if (xwl_window->has_buffer_attached) + wl_surface_commit(xwl_window->surface); +} + static Bool xwl_window_update_fractional_scale(struct xwl_window *xwl_window, int fractional_scale_numerator) @@ -993,7 +1000,7 @@ handle_libdecor_configure(struct libdecor_frame *frame, xwl_window_update_libdecor_size(xwl_window, configuration, round(new_width), round(new_height)); - wl_surface_commit(xwl_window->surface); + xwl_window_maybe_commit_surface(xwl_window); } static void @@ -1039,7 +1046,7 @@ xdg_surface_handle_configure(void *data, xwl_window_set_fullscreen(xwl_window); xdg_surface_ack_configure(xdg_surface, serial); - wl_surface_commit(xwl_window->surface); + xwl_window_maybe_commit_surface(xwl_window); } static const struct xdg_surface_listener xdg_surface_listener = { @@ -1488,6 +1495,7 @@ ensure_surface_for_window(WindowPtr window) xwl_window->viewport_scale_x = 1.0; xwl_window->viewport_scale_y = 1.0; xwl_window->surface_scale = 1; + xwl_window->has_buffer_attached = FALSE; xorg_list_init(&xwl_window->xwl_output_list); xwl_window->surface = wl_compositor_create_surface(xwl_screen->compositor); if (xwl_window->surface == NULL) { @@ -2034,6 +2042,7 @@ xwl_window_attach_buffer(struct xwl_window *xwl_window) } wl_surface_attach(xwl_window->surface, buffer, 0, 0); + xwl_window->has_buffer_attached = TRUE; /* Arbitrary limit to try to avoid flooding the Wayland * connection. If we flood it too much anyway, this could diff --git a/hw/xwayland/xwayland-window.h b/hw/xwayland/xwayland-window.h index ae3e531c6..83cc054c6 100644 --- a/hw/xwayland/xwayland-window.h +++ b/hw/xwayland/xwayland-window.h @@ -109,6 +109,7 @@ struct xwl_window { struct wp_fractional_scale_v1 *fractional_scale; int fractional_scale_numerator; struct wp_linux_drm_syncobj_surface_v1 *surface_sync; + Bool has_buffer_attached; }; struct xwl_window *xwl_window_get(WindowPtr window);