systray: Use different X connection for XGetImage (fixes crash on ATI cards)

This commit is contained in:
o9000 2015-06-12 21:28:58 +02:00
parent b35cdb70df
commit f28983e5a7

View file

@ -647,17 +647,26 @@ void net_message(XClientMessageEvent *e)
} }
} }
Display *display = NULL;
XImage *tintXGetImage(Window win) 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; unsigned int border_width;
int xpos, ypos; int xpos, ypos;
unsigned int width, height, depth; unsigned int width, height, depth;
Window root; 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"); fprintf(stderr, "Couldn't get geometry of window!\n");
return NULL; 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) void systray_render_icon_composited(void* t)
@ -694,6 +703,8 @@ void systray_render_icon_composited(void* t)
if (ximage->width != traywin->width || if (ximage->width != traywin->width ||
ximage->height != traywin->height) { ximage->height != traywin->height) {
XFree(ximage); XFree(ximage);
XCloseDisplay(display);
display = NULL;
XMoveResizeWindow(server.dsp, traywin->win, 0, 0, traywin->width, traywin->height); XMoveResizeWindow(server.dsp, traywin->win, 0, 0, traywin->width, traywin->height);
return; return;
} }
@ -712,6 +723,8 @@ void systray_render_icon_composited(void* t)
} }
} }
XFree(ximage); XFree(ximage);
XCloseDisplay(display);
display = NULL;
} }
if (traywin->empty != empty) { if (traywin->empty != empty) {
traywin->empty = empty; traywin->empty = empty;