xwm: read atom name from xcb (#7546)

expand the debug trace logging by actually reading the atom name from
xcb if not found in HYPRATOMS, will also print the proper atom for xcb
internal ones and not just the HYPRATOMS ones.
This commit is contained in:
Tom Englund 2024-09-01 12:04:28 +02:00 committed by GitHub
parent a6315b0af4
commit 4af9410dc2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 25 additions and 10 deletions

View file

@ -158,19 +158,33 @@ static bool lookupParentExists(SP<CXWaylandSurface> XSURF, SP<CXWaylandSurface>
return false; return false;
} }
void CXWM::readProp(SP<CXWaylandSurface> XSURF, uint32_t atom, xcb_get_property_reply_t* reply) { std::string CXWM::getAtomName(uint32_t atom) {
std::string propName;
if (Debug::trace) {
propName = std::format("{}?", atom);
for (auto const& ha : HYPRATOMS) { for (auto const& ha : HYPRATOMS) {
if (ha.second != atom) if (ha.second != atom)
continue; continue;
propName = ha.first; return ha.first;
break;
} }
// Get the name of the atom
auto const atom_name_cookie = xcb_get_atom_name(connection, atom);
auto* atom_name_reply = xcb_get_atom_name_reply(connection, atom_name_cookie, NULL);
if (!atom_name_reply)
return "Unknown";
auto const name_len = xcb_get_atom_name_name_length(atom_name_reply);
auto* name = xcb_get_atom_name_name(atom_name_reply);
free(atom_name_reply);
return {name, name_len};
} }
void CXWM::readProp(SP<CXWaylandSurface> XSURF, uint32_t atom, xcb_get_property_reply_t* reply) {
std::string propName;
if (Debug::trace)
propName = getAtomName(atom);
if (atom == XCB_ATOM_WM_CLASS) { if (atom == XCB_ATOM_WM_CLASS) {
size_t len = xcb_get_property_value_length(reply); size_t len = xcb_get_property_value_length(reply);
char* string = (char*)xcb_get_property_value(reply); char* string = (char*)xcb_get_property_value(reply);

View file

@ -119,6 +119,7 @@ class CXWM {
std::string mimeFromAtom(xcb_atom_t atom); std::string mimeFromAtom(xcb_atom_t atom);
void setClipboardToWayland(SXSelection& sel); void setClipboardToWayland(SXSelection& sel);
void getTransferData(SXSelection& sel); void getTransferData(SXSelection& sel);
std::string getAtomName(uint32_t atom);
void readProp(SP<CXWaylandSurface> XSURF, uint32_t atom, xcb_get_property_reply_t* reply); void readProp(SP<CXWaylandSurface> XSURF, uint32_t atom, xcb_get_property_reply_t* reply);
// //