From f4b148df1e2d8edc96bd878a4cfde32ca6515ac8 Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Fri, 21 Feb 2025 21:26:53 +0100 Subject: anr: add xwayland support (#9456) Adds XWayland support to ANR dialogs --- src/xwayland/XSurface.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/xwayland/XSurface.cpp') diff --git a/src/xwayland/XSurface.cpp b/src/xwayland/XSurface.cpp index 91f20be5..b297c29c 100644 --- a/src/xwayland/XSurface.cpp +++ b/src/xwayland/XSurface.cpp @@ -2,6 +2,7 @@ #include "XWayland.hpp" #include "../protocols/XWaylandShell.hpp" #include "../protocols/core/Compositor.hpp" +#include "../managers/ANRManager.hpp" #ifndef NO_XWAYLAND @@ -243,6 +244,28 @@ void CXWaylandSurface::setWithdrawn(bool withdrawn_) { xcb_change_property(g_pXWayland->pWM->connection, XCB_PROP_MODE_REPLACE, xID, HYPRATOMS["WM_STATE"], HYPRATOMS["WM_STATE"], 32, props.size(), props.data()); } +void CXWaylandSurface::ping() { + bool supportsPing = std::ranges::find(protocols, HYPRATOMS["_NET_WM_PING"]) != protocols.end(); + + if (!supportsPing) { + Debug::log(TRACE, "CXWaylandSurface: XID {} does not support ping, just sending an instant reply", xID); + g_pANRManager->onResponse(self.lock()); + return; + } + + timespec now; + clock_gettime(CLOCK_MONOTONIC, &now); + + xcb_client_message_data_t msg = {}; + msg.data32[0] = HYPRATOMS["_NET_WM_PING"]; + msg.data32[1] = now.tv_sec * 1000 + now.tv_nsec / 1000000; + msg.data32[2] = xID; + + lastPingSeq = msg.data32[1]; + + g_pXWayland->pWM->sendWMMessage(self.lock(), &msg, XCB_EVENT_MASK_PROPERTY_CHANGE); +} + #else CXWaylandSurface::CXWaylandSurface(uint32_t xID_, CBox geometry_, bool OR) : xID(xID_), geometry(geometry_), overrideRedirect(OR) { @@ -297,4 +320,8 @@ void CXWaylandSurface::setWithdrawn(bool withdrawn) { ; } +void CXWaylandSurface::ping() { + ; +} + #endif -- cgit v1.2.3