From d240da419e51ae7b4ea392890062f54c984825c0 Mon Sep 17 00:00:00 2001 From: Frank Praznik Date: Fri, 24 Apr 2026 13:14:30 -0400 Subject: [PATCH] wayland: Avoid excessive exposure events during interactive resizes Only send the unblocking exposure event once per frame, so that clients using an event watcher won't redraw excessively. Also ensure that the unblocking exposure is always sent on the libdecor path. (cherry picked from commit 01a7588f8e593b93c75ca7adbc6ec595e84e9bce) --- src/video/wayland/SDL_waylandwindow.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c index 230125c10e..913209af06 100644 --- a/src/video/wayland/SDL_waylandwindow.c +++ b/src/video/wayland/SDL_waylandwindow.c @@ -758,10 +758,10 @@ static void handle_xdg_surface_configure(void *data, struct xdg_surface *xdg, ui wind->pending_config_ack = false; ConfigureWindowGeometry(window); xdg_surface_ack_configure(xdg, serial); - } else { + } else if (!wind->pending_config_ack) { wind->pending_config_ack = true; - // Send an exposure event so that clients doing deferred updates will trigger a frame callback and make guaranteed forward progress when resizing. + // Always send an exposure event during a new frame to ensure forward progress if the frame callback already occurred. SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_EXPOSED, 0, 0); } @@ -1462,6 +1462,11 @@ static void decoration_frame_configure(struct libdecor_frame *frame, struct libdecor_state *state = libdecor_state_new(wind->current.logical_width, wind->current.logical_height); libdecor_frame_commit(frame, state, configuration); libdecor_state_free(state); + + // Always send an exposure event during a new frame to ensure forward progress if the frame callback already occurred. + if (started_resize) { + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_EXPOSED, 0, 0); + } } if (wind->shell_surface_status == WAYLAND_SHELL_SURFACE_STATUS_WAITING_FOR_CONFIGURE) {