From fe2ec1fb9e4cc28e2403f3abd43aea59c054495e Mon Sep 17 00:00:00 2001 From: Window Maker Date: Mon, 25 May 2026 13:32:59 +0200 Subject: [PATCH] wayland: pump client display in main loop for close button support In-process WINGs clients have their own wl_display connection that needs to be dispatched for xdg_toplevel.close to be received. Add W_WLClientDispatchPending() and call it each main loop iteration so protocol events reach the client-side handlers promptly. --- WINGs/wclient_wl.c | 9 +++++++++ src/backend/wayland/wl_backend.c | 2 ++ 2 files changed, 11 insertions(+) diff --git a/WINGs/wclient_wl.c b/WINGs/wclient_wl.c index 85fbf13..83240ad 100644 --- a/WINGs/wclient_wl.c +++ b/WINGs/wclient_wl.c @@ -1186,6 +1186,15 @@ wlclient_dispatch(int timeout_ms, void *userdata) wl_display_dispatch_pending(ctx->display); } +/* Pump the client-side Wayland display so pending events (like + * xdg_toplevel.close) are dispatched. Called from the compositor + * main loop. */ +void W_WLClientDispatchPending(void) +{ + if (g_wlclient_ctx) + wlclient_dispatch(0, g_wlclient_ctx); +} + /* ------------------------------------------------------------------ */ /* Public API */ /* ------------------------------------------------------------------ */ diff --git a/src/backend/wayland/wl_backend.c b/src/backend/wayland/wl_backend.c index ccf92e0..d76a081 100644 --- a/src/backend/wayland/wl_backend.c +++ b/src/backend/wayland/wl_backend.c @@ -3675,6 +3675,8 @@ wl_event_loop_run(void) struct wl_event_loop *loop = wl_display_get_event_loop(wl_state.display); while (!wl_state.terminate) { wl_display_flush_clients(wl_state.display); + extern void W_WLClientDispatchPending(void); + W_WLClientDispatchPending(); wl_event_loop_dispatch(loop, 16); /* Schedule frame AFTER dispatch so the frame event on the next * iteration renders content from commits processed above. */