Skip to content

Commit

Permalink
x_display_fix.h: fix X11 segment fault when enum_windows called
Browse files Browse the repository at this point in the history
Provided by @march1993 fixes #212
  • Loading branch information
march1993 authored and fduncanh committed Sep 7, 2023
1 parent 49cd001 commit 7b16c02
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions renderers/x_display_fix.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ Window enum_windows(const char * str, Display * display, Window window, int dept
int i;
XTextProperty text;
XGetWMName(display, window, &text);
char* name;
char* name = NULL;
XFetchName(display, window, &name);
if (name != 0 && strcmp(str, name) == 0) {
return window;
}
Window _root, parent;
Window* children;
Window* children = NULL;
unsigned int n;
XQueryTree(display, window, &_root, &parent, &children, &n);
if (children != NULL) {
Expand All @@ -68,9 +68,16 @@ Window enum_windows(const char * str, Display * display, Window window, int dept
return (Window) NULL;
}

int X11_error_catcher( Display *disp, XErrorEvent *xe ) {
// do nothing
return 0;
}

void get_x_window(X11_Window_t * X11, const char * name) {
Window root = XDefaultRootWindow(X11->display);
Window root = XDefaultRootWindow(X11->display);
XSetErrorHandler(X11_error_catcher);
X11->window = enum_windows(name, X11->display, root, 0);
XSetErrorHandler(NULL);
#ifdef ZOOM_WINDOW_NAME_FIX
if (X11->window) {
Atom _NET_WM_NAME = XInternAtom(X11->display, "_NET_WM_NAME", 0);
Expand Down

0 comments on commit 7b16c02

Please sign in to comment.