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:
parent
d91952c555
commit
a20142bcce
2 changed files with 14 additions and 4 deletions
|
|
@ -7,8 +7,6 @@
|
||||||
|
|
||||||
#ifndef NO_XWAYLAND
|
#ifndef NO_XWAYLAND
|
||||||
|
|
||||||
#include <ranges>
|
|
||||||
|
|
||||||
CXWaylandSurface::CXWaylandSurface(uint32_t xID_, CBox geometry_, bool OR) : m_xID(xID_), m_geometry(geometry_), m_overrideRedirect(OR) {
|
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};
|
xcb_res_query_client_ids_cookie_t client_id_cookie = {0};
|
||||||
if (g_pXWayland->m_wm->m_xres) {
|
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)
|
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 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* 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);
|
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);
|
free(getReply);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_events.resourceChange.listenStatic([this] { ensureListeners(); });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CXWaylandSurface::ensureListeners() {
|
void CXWaylandSurface::ensureListeners() {
|
||||||
|
|
@ -253,6 +258,10 @@ void CXWaylandSurface::restackToTop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CXWaylandSurface::close() {
|
void CXWaylandSurface::close() {
|
||||||
|
|
||||||
|
// Recheck the supported props, check if we maybe have WM_DELETE_WINDOW.
|
||||||
|
recheckSupportedProps();
|
||||||
|
|
||||||
if (m_supportedProps[HYPRATOMS["WM_DELETE_WINDOW"]]) {
|
if (m_supportedProps[HYPRATOMS["WM_DELETE_WINDOW"]]) {
|
||||||
xcb_client_message_data_t msg = {};
|
xcb_client_message_data_t msg = {};
|
||||||
msg.data32[0] = HYPRATOMS["WM_DELETE_WINDOW"];
|
msg.data32[0] = HYPRATOMS["WM_DELETE_WINDOW"];
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,7 @@ class CXWaylandSurface {
|
||||||
void unmap();
|
void unmap();
|
||||||
void considerMap();
|
void considerMap();
|
||||||
void setWithdrawn(bool withdrawn);
|
void setWithdrawn(bool withdrawn);
|
||||||
|
void recheckSupportedProps();
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
CHyprSignalListener destroyResource;
|
CHyprSignalListener destroyResource;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue