aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTom Englund <[email protected]>2024-09-01 12:04:28 +0200
committerGitHub <[email protected]>2024-09-01 12:04:28 +0200
commit4af9410dc2d0e241276a0797d3f3d276310d956e (patch)
tree3c8c90d7383b0ca9ffca02925398fa46a033ad5a
parenta6315b0af4e417cf396649d9c5792d3c5420b713 (diff)
downloadHyprland-4af9410dc2d0e241276a0797d3f3d276310d956e.tar.gz
Hyprland-4af9410dc2d0e241276a0797d3f3d276310d956e.zip
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.
-rw-r--r--src/xwayland/XWM.cpp34
-rw-r--r--src/xwayland/XWM.hpp1
2 files changed, 25 insertions, 10 deletions
diff --git a/src/xwayland/XWM.cpp b/src/xwayland/XWM.cpp
index b5762762..cb4d8f4d 100644
--- a/src/xwayland/XWM.cpp
+++ b/src/xwayland/XWM.cpp
@@ -158,19 +158,33 @@ static bool lookupParentExists(SP<CXWaylandSurface> XSURF, SP<CXWaylandSurface>
return false;
}
-void CXWM::readProp(SP<CXWaylandSurface> XSURF, uint32_t atom, xcb_get_property_reply_t* reply) {
- std::string propName;
- if (Debug::trace) {
- propName = std::format("{}?", atom);
- for (auto const& ha : HYPRATOMS) {
- if (ha.second != atom)
- continue;
+std::string CXWM::getAtomName(uint32_t atom) {
+ for (auto const& ha : HYPRATOMS) {
+ if (ha.second != atom)
+ continue;
- propName = ha.first;
- break;
- }
+ return ha.first;
}
+ // 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) {
size_t len = xcb_get_property_value_length(reply);
char* string = (char*)xcb_get_property_value(reply);
diff --git a/src/xwayland/XWM.hpp b/src/xwayland/XWM.hpp
index 7d6b63ed..59695720 100644
--- a/src/xwayland/XWM.hpp
+++ b/src/xwayland/XWM.hpp
@@ -119,6 +119,7 @@ class CXWM {
std::string mimeFromAtom(xcb_atom_t atom);
void setClipboardToWayland(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);
//