parent
6aba583c3e
commit
d67515d575
@ -52,6 +52,8 @@ namespace modules {
|
|||||||
|
|
||||||
if (!(title = ewmh_util::get_visible_name(ewmh, m_window)).empty()) {
|
if (!(title = ewmh_util::get_visible_name(ewmh, m_window)).empty()) {
|
||||||
return title;
|
return title;
|
||||||
|
} else if (!(title = ewmh_util::get_wm_name(ewmh, m_window)).empty()) {
|
||||||
|
return title;
|
||||||
} else if (!(title = icccm_util::get_wm_name(m_connection, m_window)).empty()) {
|
} else if (!(title = icccm_util::get_wm_name(m_connection, m_window)).empty()) {
|
||||||
return title;
|
return title;
|
||||||
} else {
|
} else {
|
||||||
|
@ -19,6 +19,7 @@ namespace ewmh_util {
|
|||||||
|
|
||||||
bool supports(xcb_ewmh_connection_t* ewmh, xcb_atom_t atom, int screen = 0);
|
bool supports(xcb_ewmh_connection_t* ewmh, xcb_atom_t atom, int screen = 0);
|
||||||
|
|
||||||
|
string get_wm_name(xcb_ewmh_connection_t* conn, xcb_window_t win);
|
||||||
string get_visible_name(xcb_ewmh_connection_t* conn, xcb_window_t win);
|
string get_visible_name(xcb_ewmh_connection_t* conn, xcb_window_t win);
|
||||||
string get_icon_name(xcb_ewmh_connection_t* conn, xcb_window_t win);
|
string get_icon_name(xcb_ewmh_connection_t* conn, xcb_window_t win);
|
||||||
string get_reply_string(xcb_ewmh_get_utf8_strings_reply_t* reply);
|
string get_reply_string(xcb_ewmh_get_utf8_strings_reply_t* reply);
|
||||||
|
@ -48,30 +48,37 @@ namespace ewmh_util {
|
|||||||
return supports;
|
return supports;
|
||||||
}
|
}
|
||||||
|
|
||||||
string get_visible_name(xcb_ewmh_connection_t* conn, xcb_window_t win) {
|
string get_wm_name(xcb_ewmh_connection_t* conn, xcb_window_t win) {
|
||||||
xcb_ewmh_get_utf8_strings_reply_t utf8_reply;
|
xcb_ewmh_get_utf8_strings_reply_t utf8_reply;
|
||||||
if (!xcb_ewmh_get_wm_visible_name_reply(conn, xcb_ewmh_get_wm_visible_name(conn, win), &utf8_reply, nullptr)) {
|
if (xcb_ewmh_get_wm_name_reply(conn, xcb_ewmh_get_wm_name(conn, win), &utf8_reply, nullptr)) {
|
||||||
|
return get_reply_string(&utf8_reply);
|
||||||
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string get_visible_name(xcb_ewmh_connection_t* conn, xcb_window_t win) {
|
||||||
|
xcb_ewmh_get_utf8_strings_reply_t utf8_reply;
|
||||||
|
if (xcb_ewmh_get_wm_visible_name_reply(conn, xcb_ewmh_get_wm_visible_name(conn, win), &utf8_reply, nullptr)) {
|
||||||
return get_reply_string(&utf8_reply);
|
return get_reply_string(&utf8_reply);
|
||||||
}
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
string get_icon_name(xcb_ewmh_connection_t* conn, xcb_window_t win) {
|
string get_icon_name(xcb_ewmh_connection_t* conn, xcb_window_t win) {
|
||||||
xcb_ewmh_get_utf8_strings_reply_t utf8_reply;
|
xcb_ewmh_get_utf8_strings_reply_t utf8_reply;
|
||||||
if (!xcb_ewmh_get_wm_icon_name_reply(conn, xcb_ewmh_get_wm_icon_name(conn, win), &utf8_reply, nullptr)) {
|
if (xcb_ewmh_get_wm_icon_name_reply(conn, xcb_ewmh_get_wm_icon_name(conn, win), &utf8_reply, nullptr)) {
|
||||||
return "";
|
|
||||||
}
|
|
||||||
return get_reply_string(&utf8_reply);
|
return get_reply_string(&utf8_reply);
|
||||||
}
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
string get_reply_string(xcb_ewmh_get_utf8_strings_reply_t* reply) {
|
string get_reply_string(xcb_ewmh_get_utf8_strings_reply_t* reply) {
|
||||||
if (reply == nullptr || !reply->strings_len) {
|
if (reply == nullptr) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
char buffer[BUFSIZ]{'\0'};
|
string str(reply->strings, reply->strings_len);
|
||||||
strncpy(buffer, reply->strings, reply->strings_len);
|
|
||||||
xcb_ewmh_get_utf8_strings_reply_wipe(reply);
|
xcb_ewmh_get_utf8_strings_reply_wipe(reply);
|
||||||
return buffer;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t get_current_desktop(xcb_ewmh_connection_t* conn, int screen) {
|
uint32_t get_current_desktop(xcb_ewmh_connection_t* conn, int screen) {
|
||||||
|
@ -5,20 +5,19 @@ POLYBAR_NS
|
|||||||
namespace icccm_util {
|
namespace icccm_util {
|
||||||
string get_wm_name(xcb_connection_t* conn, xcb_window_t win) {
|
string get_wm_name(xcb_connection_t* conn, xcb_window_t win) {
|
||||||
xcb_icccm_get_text_property_reply_t reply;
|
xcb_icccm_get_text_property_reply_t reply;
|
||||||
if (!xcb_icccm_get_wm_name_reply(conn, xcb_icccm_get_wm_name(conn, win), &reply, nullptr)) {
|
if (xcb_icccm_get_wm_name_reply(conn, xcb_icccm_get_wm_name(conn, win), &reply, nullptr)) {
|
||||||
return "";
|
|
||||||
}
|
|
||||||
return get_reply_string(&reply);
|
return get_reply_string(&reply);
|
||||||
}
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
string get_reply_string(xcb_icccm_get_text_property_reply_t* reply) {
|
string get_reply_string(xcb_icccm_get_text_property_reply_t* reply) {
|
||||||
if (reply->name == nullptr || !reply->name_len) {
|
if (reply->name == nullptr) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
char buffer[BUFSIZ]{'\0'};
|
string str(reply->name, reply->name_len);
|
||||||
strncpy(buffer, reply->name, reply->name_len);
|
|
||||||
xcb_icccm_get_text_property_reply_wipe(reply);
|
xcb_icccm_get_text_property_reply_wipe(reply);
|
||||||
return buffer;
|
return str;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user