From e2f73e90e5885b2b603f7fd57ece6cb8c9affec7 Mon Sep 17 00:00:00 2001 From: Window Maker Date: Mon, 25 May 2026 13:03:31 +0200 Subject: [PATCH] WINGs/wayland: handle xdg_toplevel close by synthesizing WM_DELETE_WINDOW The close button press from the compositor sends xdg_toplevel.close, but the handler only set a flag without notifying the WINGs event system. Synthesize a WME_CLIENT_MESSAGE with deleteWindowAtom so the window closeAction callback fires and the app shuts down gracefully. --- WINGs/wclient_wl.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/WINGs/wclient_wl.c b/WINGs/wclient_wl.c index 361a398..85fbf13 100644 --- a/WINGs/wclient_wl.c +++ b/WINGs/wclient_wl.c @@ -364,9 +364,17 @@ xdg_toplevel_handle_close(void *data, struct xdg_toplevel *xt) { (void)xt; WLClientToplevel *top = data; - top->want_close = 1; - /* TODO: synthesize a WMEvent close so the WINGs app can shut down - * gracefully. For now we just exit on next event-loop turn. */ + if (!top || !top->view) return; + + W_Screen *scr = top->view->screen; + WMEvent ev; + memset(&ev, 0, sizeof(ev)); + ev.type = WME_CLIENT_MESSAGE; + ev.window = top->view->window; + ev.u.clientMessage.message_type = scr->protocolsAtom; + ev.u.clientMessage.format = 32; + ev.u.clientMessage.data.l[0] = scr->deleteWindowAtom; + W_WL_EnqueueEvent(scr, &ev, top->view); } static void