anr: add xwayland support (#9456)

Adds XWayland support to ANR dialogs
This commit is contained in:
Vaxry 2025-02-21 21:26:53 +01:00 committed by GitHub
parent 0e24f9c0d5
commit f4b148df1e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 184 additions and 58 deletions

View file

@ -15,6 +15,7 @@
#include "../protocols/core/Seat.hpp"
#include "../managers/eventLoop/EventLoopManager.hpp"
#include "../managers/SeatManager.hpp"
#include "../managers/ANRManager.hpp"
#include "../protocols/XWaylandShell.hpp"
#include "../protocols/core/Compositor.hpp"
using namespace Hyprutils::OS;
@ -283,6 +284,16 @@ void CXWM::readProp(SP<CXWaylandSurface> XSURF, uint32_t atom, xcb_get_property_
XSURF->sizeHints->max_height = -1;
}
}
} else if (atom == HYPRATOMS["WM_PROTOCOLS"]) {
if (reply->type == XCB_ATOM_ATOM) {
auto atoms = (xcb_atom_t*)xcb_get_property_value(reply);
std::vector<uint32_t> vec;
vec.reserve(reply->value_len);
for (size_t i = 0; i < reply->value_len; ++i) {
vec.emplace_back(atoms[i]);
}
XSURF->protocols = vec;
}
} else {
Debug::log(TRACE, "[xwm] Unhandled prop {} -> {}", atom, propName);
return;
@ -315,16 +326,14 @@ void CXWM::handleClientMessage(xcb_client_message_event_t* e) {
if (!XSURF)
return;
std::string propName = "?";
for (auto const& ha : HYPRATOMS) {
if (ha.second != e->type)
continue;
std::string propName = getAtomName(e->type);
propName = ha.first;
break;
}
if (e->type == HYPRATOMS["WL_SURFACE_ID"]) {
if (e->type == HYPRATOMS["WM_PROTOCOLS"]) {
if (e->data.data32[1] == XSURF->lastPingSeq && e->data.data32[0] == HYPRATOMS["_NET_WM_PING"]) {
g_pANRManager->onResponse(XSURF);
return;
}
} else if (e->type == HYPRATOMS["WL_SURFACE_ID"]) {
if (XSURF->surface) {
Debug::log(WARN, "[xwm] Re-assignment of WL_SURFACE_ID");
dissociate(XSURF);
@ -1056,9 +1065,10 @@ void CXWM::onNewResource(SP<CXWaylandSurfaceResource> resource) {
}
void CXWM::readWindowData(SP<CXWaylandSurface> surf) {
const std::array<xcb_atom_t, 8> interestingProps = {
const std::array<xcb_atom_t, 9> interestingProps = {
XCB_ATOM_WM_CLASS, XCB_ATOM_WM_NAME, XCB_ATOM_WM_TRANSIENT_FOR, HYPRATOMS["WM_HINTS"],
HYPRATOMS["_NET_WM_STATE"], HYPRATOMS["_NET_WM_NAME"], HYPRATOMS["_NET_WM_WINDOW_TYPE"], HYPRATOMS["WM_NORMAL_HINTS"],
HYPRATOMS["WM_PROTOCOLS"],
};
for (size_t i = 0; i < interestingProps.size(); i++) {