2016-11-18 22:03:18 -05:00
|
|
|
#include "x11/icccm.hpp"
|
|
|
|
|
2016-11-19 00:22:44 -05:00
|
|
|
POLYBAR_NS
|
2016-11-18 22:03:18 -05:00
|
|
|
|
|
|
|
namespace icccm_util {
|
|
|
|
string get_wm_name(xcb_connection_t* conn, xcb_window_t win) {
|
|
|
|
xcb_icccm_get_text_property_reply_t reply;
|
2016-11-30 07:38:40 -05:00
|
|
|
if (xcb_icccm_get_wm_name_reply(conn, xcb_icccm_get_wm_name(conn, win), &reply, nullptr)) {
|
|
|
|
return get_reply_string(&reply);
|
2016-11-25 07:55:15 -05:00
|
|
|
}
|
2016-11-30 07:38:40 -05:00
|
|
|
return "";
|
2016-11-18 22:03:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
string get_reply_string(xcb_icccm_get_text_property_reply_t* reply) {
|
2016-11-30 07:38:40 -05:00
|
|
|
if (reply->name == nullptr) {
|
2016-11-18 22:03:18 -05:00
|
|
|
return "";
|
2016-11-25 07:55:15 -05:00
|
|
|
}
|
2016-11-30 07:38:40 -05:00
|
|
|
string str(reply->name, reply->name_len);
|
2016-11-18 22:03:18 -05:00
|
|
|
xcb_icccm_get_text_property_reply_wipe(reply);
|
2016-11-30 07:38:40 -05:00
|
|
|
return str;
|
2016-11-18 22:03:18 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-19 00:22:44 -05:00
|
|
|
POLYBAR_NS_END
|