From a20142bccead74ea810fcfde54cd7eaa0d0fe5b0 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sat, 21 Feb 2026 14:40:36 +0000 Subject: [PATCH] xwayland/xwm: fix window closing when props race we need to recheck before closing, ideally on change but that's later --- src/xwayland/XSurface.cpp | 17 +++++++++++++---- src/xwayland/XSurface.hpp | 1 + 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/xwayland/XSurface.cpp b/src/xwayland/XSurface.cpp index ca4c4be5..5c5f3b5c 100644 --- a/src/xwayland/XSurface.cpp +++ b/src/xwayland/XSurface.cpp @@ -7,8 +7,6 @@ #ifndef NO_XWAYLAND -#include - CXWaylandSurface::CXWaylandSurface(uint32_t xID_, CBox geometry_, bool OR) : m_xID(xID_), m_geometry(geometry_), m_overrideRedirect(OR) { xcb_res_query_client_ids_cookie_t client_id_cookie = {0}; if (g_pXWayland->m_wm->m_xres) { @@ -42,6 +40,15 @@ CXWaylandSurface::CXWaylandSurface(uint32_t xID_, CBox geometry_, bool OR) : m_x free(reply); // NOLINT(cppcoreguidelines-no-malloc) } + // FIXME: this is a race, we need to listen to props changed + recheckSupportedProps(); + + m_events.resourceChange.listenStatic([this] { ensureListeners(); }); +} + +void CXWaylandSurface::recheckSupportedProps() { + m_supportedProps.clear(); + auto listCookie = xcb_list_properties(g_pXWayland->m_wm->getConnection(), m_xID); auto* listReply = xcb_list_properties_reply(g_pXWayland->m_wm->getConnection(), listCookie, nullptr); auto getCookie = xcb_get_property(g_pXWayland->m_wm->getConnection(), 0, m_xID, HYPRATOMS["WM_PROTOCOLS"], XCB_ATOM_ATOM, 0, 32); @@ -68,8 +75,6 @@ CXWaylandSurface::CXWaylandSurface(uint32_t xID_, CBox geometry_, bool OR) : m_x free(getReply); } - - m_events.resourceChange.listenStatic([this] { ensureListeners(); }); } void CXWaylandSurface::ensureListeners() { @@ -253,6 +258,10 @@ void CXWaylandSurface::restackToTop() { } void CXWaylandSurface::close() { + + // Recheck the supported props, check if we maybe have WM_DELETE_WINDOW. + recheckSupportedProps(); + if (m_supportedProps[HYPRATOMS["WM_DELETE_WINDOW"]]) { xcb_client_message_data_t msg = {}; msg.data32[0] = HYPRATOMS["WM_DELETE_WINDOW"]; diff --git a/src/xwayland/XSurface.hpp b/src/xwayland/XSurface.hpp index 6c00f915..a8ccac4d 100644 --- a/src/xwayland/XSurface.hpp +++ b/src/xwayland/XSurface.hpp @@ -112,6 +112,7 @@ class CXWaylandSurface { void unmap(); void considerMap(); void setWithdrawn(bool withdrawn); + void recheckSupportedProps(); struct { CHyprSignalListener destroyResource;