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 <ofourdan@redhat.com>
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1853
Fixes: 295fb7165 - xwayland: Commit after acknowledging configure
Fixes: d370f1e58 - xwayland: add fullscreen mode for rootful
This commit is contained in:
Olivier Fourdan 2025-12-05 11:08:35 +01:00
parent eccee47185
commit d1ea5d6ca2
2 changed files with 12 additions and 2 deletions

View file

@ -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

View file

@ -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);