Fixed WM crashes on wonky windows opening

This commit is contained in:
vaxerski 2021-11-27 19:44:58 +01:00
parent 6224ffb078
commit 5a0a8fb0d1
2 changed files with 10 additions and 1 deletions

View file

@ -135,7 +135,6 @@ void IPCRecieveMessageB(const std::string path) {
std::sort(g_pWindowManager->statusBar->openWorkspaces.begin(), g_pWindowManager->statusBar->openWorkspaces.end());
} else if (PROPNAME == "lastwindowname") {
g_pWindowManager->statusBar->setLastWindowName(PROPVALUE);
Debug::log(LOG, "update window name to " + PROPVALUE);
}
}
} catch(...) {

View file

@ -7,6 +7,10 @@
std::pair<std::string, std::string> getClassName(int64_t window) {
PROP(class_cookie, XCB_ATOM_WM_CLASS, 128);
if (!class_cookiereply) {
return std::make_pair<>("Error", "Error");
}
const size_t PROPLEN = xcb_get_property_value_length(class_cookiereply);
char* NEWCLASS = (char*)xcb_get_property_value(class_cookiereply);
const size_t CLASSNAMEINDEX = strnlen(NEWCLASS, PROPLEN) + 1;
@ -27,6 +31,9 @@ std::pair<std::string, std::string> getClassName(int64_t window) {
std::string getRoleName(int64_t window) {
PROP(role_cookie, HYPRATOMS["WM_WINDOW_ROLE"], 128);
if (!role_cookiereply)
return "Error";
std::string returns = "";
if (role_cookiereply == NULL || xcb_get_property_value_length(role_cookiereply)) {
@ -48,6 +55,9 @@ std::string getRoleName(int64_t window) {
std::string getWindowName(uint64_t window) {
PROP(name_cookie, HYPRATOMS["_NET_WM_NAME"], 128);
if (!name_cookiereply)
return "Error";
const int len = xcb_get_property_value_length(name_cookiereply);
char* name = strndup((const char*)xcb_get_property_value(name_cookiereply), len);
std::string stringname(name);