systray: Use different X connection for XGetImage (fixes crash on ATI cards)
o9000 o9000
1 files changed,
15 insertions(+),
2 deletions(-)
jump to
M
src/systray/systraybar.c
→
src/systray/systraybar.c
@@ -647,17 +647,26 @@ break;
} } +Display *display = NULL; XImage *tintXGetImage(Window win) { + char *display_name = XDisplayName(NULL); + if (!display_name) + return NULL; + if (!display) + display = XOpenDisplay(display_name); + if (!display) + return NULL; + unsigned int border_width; int xpos, ypos; unsigned int width, height, depth; Window root; - if (!XGetGeometry(server.dsp, win, &root, &xpos, &ypos, &width, &height, &border_width, &depth)) { + if (!XGetGeometry(display, win, &root, &xpos, &ypos, &width, &height, &border_width, &depth)) { fprintf(stderr, "Couldn't get geometry of window!\n"); return NULL; } - return XGetImage(server.dsp, win, 0, 0, width, height, AllPlanes, XYPixmap); + return XGetImage(display, win, 0, 0, width, height, AllPlanes, XYPixmap); } void systray_render_icon_composited(void* t)@@ -694,6 +703,8 @@ if (ximage) {
if (ximage->width != traywin->width || ximage->height != traywin->height) { XFree(ximage); + XCloseDisplay(display); + display = NULL; XMoveResizeWindow(server.dsp, traywin->win, 0, 0, traywin->width, traywin->height); return; }@@ -712,6 +723,8 @@ }
} } XFree(ximage); + XCloseDisplay(display); + display = NULL; } if (traywin->empty != empty) { traywin->empty = empty;