From 776d11a9c8c552b1ed66af0154670c2d5ea63f52 Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Fri, 17 Oct 2025 11:40:23 -0400
Subject: [PATCH] wayland: Remove unnecessary flushes
Events are implicitly flushed during blocking dispatches and round-trips. Remove some unnecessary uses of wl_display_flush().
---
src/video/wayland/SDL_waylandevents.c | 2 --
src/video/wayland/SDL_waylandvideo.c | 4 ----
src/video/wayland/SDL_waylandwindow.c | 5 +----
3 files changed, 1 insertion(+), 10 deletions(-)
diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c
index 5d4bf4b04bb9d..08c012a4f321d 100644
--- a/src/video/wayland/SDL_waylandevents.c
+++ b/src/video/wayland/SDL_waylandevents.c
@@ -3654,8 +3654,6 @@ void Wayland_DisplayCreateSeat(SDL_VideoData *display, struct wl_seat *wl_seat,
if (display->tablet_manager) {
Wayland_SeatInitTabletSupport(seat);
}
-
- WAYLAND_wl_display_flush(display->display);
}
void Wayland_DisplayRemoveWindowReferencesFromSeats(SDL_VideoData *display, SDL_WindowData *window)
diff --git a/src/video/wayland/SDL_waylandvideo.c b/src/video/wayland/SDL_waylandvideo.c
index d4f97f6547f46..cd81e327b6b67 100644
--- a/src/video/wayland/SDL_waylandvideo.c
+++ b/src/video/wayland/SDL_waylandvideo.c
@@ -461,7 +461,6 @@ static void Wayland_DeleteDevice(SDL_VideoDevice *device)
{
SDL_VideoData *data = device->internal;
if (data->display && !data->display_externally_owned) {
- WAYLAND_wl_display_flush(data->display);
WAYLAND_wl_display_disconnect(data->display);
SDL_ClearProperty(SDL_GetGlobalProperties(), SDL_PROP_GLOBAL_VIDEO_WAYLAND_WL_DISPLAY_POINTER);
}
@@ -1454,9 +1453,6 @@ bool Wayland_VideoInit(SDL_VideoDevice *_this)
Wayland_FinalizeDisplays(data);
Wayland_InitMouse();
-
- WAYLAND_wl_display_flush(data->display);
-
Wayland_InitKeyboard(_this);
if (data->primary_selection_device_manager) {
diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c
index 2e8b65bb0c672..ee30e62328dbc 100644
--- a/src/video/wayland/SDL_waylandwindow.c
+++ b/src/video/wayland/SDL_waylandwindow.c
@@ -2027,8 +2027,7 @@ void Wayland_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window)
if (data->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_LIBDECOR) {
if (data->shell_surface.libdecor.frame) {
while (data->shell_surface_status == WAYLAND_SHELL_SURFACE_STATUS_WAITING_FOR_CONFIGURE) {
- WAYLAND_wl_display_flush(c->display);
- WAYLAND_wl_display_dispatch(c->display);
+ libdecor_dispatch(c->shell.libdecor, -1);
}
}
} else
@@ -2041,7 +2040,6 @@ void Wayland_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window)
wl_surface_commit(data->surface);
if (data->shell_surface.xdg.surface) {
while (data->shell_surface_status == WAYLAND_SHELL_SURFACE_STATUS_WAITING_FOR_CONFIGURE) {
- WAYLAND_wl_display_flush(c->display);
WAYLAND_wl_display_dispatch(c->display);
}
}
@@ -3266,7 +3264,6 @@ void Wayland_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window)
wind->icon_buffer_count = 0;
SDL_free(wind);
- WAYLAND_wl_display_flush(data->display);
}
window->internal = NULL;
}