frontend-tools: Fix crash on non X11 windowing systems

This commit is contained in:
WarmUpTill 2022-12-03 17:59:50 +01:00 committed by Georges Basile Stavracas Neto
parent 4216991413
commit 7d26721be5

View file

@ -46,8 +46,14 @@ static bool ewmhIsSupported()
unsigned long num = 0, bytes = 0;
unsigned char *data = NULL;
Window ewmh_window = 0;
Window root_window = 0;
int status = XGetWindowProperty(display, DefaultRootWindow(display),
root_window = DefaultRootWindow(display);
if (!root_window) {
return false;
}
int status = XGetWindowProperty(display, root_window,
netSupportingWmCheck, 0L, 1L, false,
XA_WINDOW, &actualType, &format, &num,
&bytes, &data);
@ -97,6 +103,9 @@ static std::vector<Window> getTopLevelWindows()
for (int i = 0; i < ScreenCount(disp()); ++i) {
Window rootWin = RootWindow(disp(), i);
if (!rootWin) {
continue;
}
int status = XGetWindowProperty(disp(), rootWin, netClList, 0L,
~0L, false, AnyPropertyType,
@ -119,6 +128,9 @@ static std::vector<Window> getTopLevelWindows()
static std::string GetWindowTitle(size_t i)
{
Window w = getTopLevelWindows().at(i);
if (!w) {
return "";
}
std::string windowTitle;
char *name;
@ -164,11 +176,17 @@ void GetCurrentWindowTitle(string &title)
char *name;
Window rootWin = RootWindow(disp(), 0);
if (!rootWin) {
return;
}
XGetWindowProperty(disp(), rootWin, active, 0L, ~0L, false,
AnyPropertyType, &actualType, &format, &num, &bytes,
(uint8_t **)&data);
if (!data[0]) {
return;
}
int status = XFetchName(disp(), data[0], &name);
if (status >= Success && name != nullptr) {