Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xwm: read atom name from xcb #7546

Merged
merged 1 commit into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 24 additions & 10 deletions src/xwayland/XWM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
vaxerski marked this conversation as resolved.
Show resolved Hide resolved
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);
Expand Down
1 change: 1 addition & 0 deletions src/xwayland/XWM.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

//
Expand Down
Loading