#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
+#include <xcb/xproto.h>
+#include <xcb/shm.h>
#include <X11/Xlib.h>
+#include <X11/Xlib-xcb.h>
#include "glxclient.h"
#include <dlfcn.h>
#include "dri_common.h"
static int
check_xshm(Display *dpy)
{
- int (*old_handler)(Display *, XErrorEvent *);
-
+ xcb_connection_t *c = XGetXCBConnection(dpy);
+ xcb_void_cookie_t cookie;
+ xcb_generic_error_t *error;
+ int ret = True;
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);
-
- /* 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;
+ cookie = xcb_shm_detach_checked(c, 0);
+ if ((error = xcb_request_check(c, cookie))) {
+ /* BadRequest means we're a remote client. If we were local we'd
+ * expect BadValue since 'info' has an invalid segment name.
+ */
+ if (error->error_code == BadRequest)
+ ret = False;
+ free(error);
+ }
- xshm_error = 0;
- return True;
+ return ret;
}
static struct glx_screen *