xwayland/xwm: fix window closing when props race

we need to recheck before closing, ideally on change but that's later
This commit is contained in:
Vaxry 2026-02-21 14:40:36 +00:00
parent d91952c555
commit a20142bcce
No known key found for this signature in database
GPG key ID: 665806380871D640
2 changed files with 14 additions and 4 deletions

View file

@ -7,8 +7,6 @@
#ifndef NO_XWAYLAND
#include <ranges>
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"];

View file

@ -112,6 +112,7 @@ class CXWaylandSurface {
void unmap();
void considerMap();
void setWithdrawn(bool withdrawn);
void recheckSupportedProps();
struct {
CHyprSignalListener destroyResource;