From bdddc3857c5c6e53bd0e94978ff26000a0f04d73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Sun, 14 Apr 2024 21:24:19 +0200 Subject: [PATCH] wayland: Always commit soon after xdg_surface.ack_configure It's mandatory to reply to a xdg_surface.configure with a xdg_surface.ack_configure, as well as a wl_surface.commit to have the ack_configure to have any effect. We failed to do that if the new configuration didn't cause any actual anything to change, meaning we'd just ack_configure, but potentially never commit. Fix this by requesting a 'after-paint' frame clock phase, while setting the pending commit state to true. If we were already to paint, the new requested phase would happen anyway, but to avoid double wl_surface.commit when also using eglSwapBuffers*(), also avoid performing the commit if we know the swap buffers will happen. --- gdk/wayland/gdkwindow-wayland.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gdk/wayland/gdkwindow-wayland.c b/gdk/wayland/gdkwindow-wayland.c index f09f651ac7..7c457dd675 100644 --- a/gdk/wayland/gdkwindow-wayland.c +++ b/gdk/wayland/gdkwindow-wayland.c @@ -1082,6 +1082,14 @@ gdk_window_impl_wayland_end_paint (GdkWindow *window) impl->pending_commit = TRUE; } + else if (window->current_paint.use_gl && + window->current_paint.surface_needs_composite && + impl->pending_commit) + { + /* Discard issuing pending commit, as when we reach here, it means it'll + * be done implicitly by eglSwapBuffers(). */ + impl->pending_commit = FALSE; + } gdk_wayland_window_sync_margin (window); gdk_wayland_window_sync_opaque_region (window); @@ -1714,6 +1722,7 @@ gdk_wayland_window_handle_configure (GdkWindow *window, GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl); GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (gdk_window_get_display (window)); + GdkFrameClock *frame_clock = gdk_window_get_frame_clock (window); GdkWindowState new_state; gboolean suspended; int width = impl->pending.width; @@ -1863,6 +1872,10 @@ gdk_wayland_window_handle_configure (GdkWindow *window, if (impl->hint != GDK_WINDOW_TYPE_HINT_DIALOG && new_state & GDK_WINDOW_STATE_FOCUSED) gdk_wayland_window_update_dialogs (window); + + impl->pending_commit = TRUE; + gdk_frame_clock_request_phase (frame_clock, + GDK_FRAME_CLOCK_PHASE_AFTER_PAINT); } static void