(void) dpy;
assert(xshm_opcode != -1);
- if (event->request_code != xshm_opcode ||
- event->minor_code != X_ShmAttach)
+ if (event->request_code != xshm_opcode)
return 0;
- xshm_error = 1;
+ xshm_error = event->error_code;
return 0;
}
static int
check_xshm(Display *dpy)
{
+ int (*old_handler)(Display *, XErrorEvent *);
+
int ignore;
+ XShmSegmentInfo info = { 0, };
+
+ if (!XQueryExtension(dpy, "MIT-SHM", &xshm_opcode, &ignore, &ignore))
+ return False;
+
+ old_handler = XSetErrorHandler(handle_xerror);
+ XShmDetach(dpy, &info);
+ XSync(dpy, False);
+ (void) XSetErrorHandler(old_handler);
- return XQueryExtension(dpy, "MIT-SHM", &xshm_opcode, &ignore, &ignore);
+ /* BadRequest means we're a remote client. If we were local we'd
+ * expect BadValue since 'info' has an invalid segment name.
+ */
+ if (xshm_error == BadRequest)
+ return False;
+
+ xshm_error = 0;
+ return True;
}
static struct glx_screen *