#include <assert.h>
static Bool
-XCreateGCs(struct drisw_drawable * pdp,
- Display * dpy, XID drawable, int visualid)
+driswCreateGCs(struct drisw_drawable * pdp,
+ Display * dpy, XID drawable, int visualid)
{
- XGCValues gcvalues;
long visMask;
XVisualInfo visTemp;
int num_visuals;
- /* create GC's */
pdp->gc = XCreateGC(dpy, drawable, 0, NULL);
- pdp->swapgc = XCreateGC(dpy, drawable, 0, NULL);
-
- gcvalues.function = GXcopy;
- gcvalues.graphics_exposures = False;
- XChangeGC(dpy, pdp->gc, GCFunction, &gcvalues);
- XChangeGC(dpy, pdp->swapgc, GCFunction, &gcvalues);
- XChangeGC(dpy, pdp->swapgc, GCGraphicsExposures, &gcvalues);
/* visual */
visTemp.visualid = visualid;
(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;
}
free(pdp->visinfo);
XFreeGC(dpy, pdp->gc);
- XFreeGC(dpy, pdp->swapgc);
}
/**
Display *dpy = pdraw->psc->dpy;
Drawable drawable;
XImage *ximage;
- GC gc;
+ GC gc = pdp->gc;
if (!pdp->ximage || shmid != pdp->shminfo.shmid) {
if (!XCreateDrawable(pdp, shmid, dpy))
return;
}
- switch (op) {
- case __DRI_SWRAST_IMAGE_OP_DRAW:
- gc = pdp->gc;
- break;
- case __DRI_SWRAST_IMAGE_OP_SWAP:
- gc = pdp->swapgc;
- break;
- default:
- return;
- }
-
drawable = pdraw->xDrawable;
ximage = pdp->ximage;
ximage->bytes_per_line = stride ? stride : bytes_per_line(w * ximage->bits_per_pixel, 32);
&api, &reset, &release, error))
return NULL;
+ if (!dri2_check_no_error(flags, shareList, major_ver, error))
+ return NULL;
+
/* Check the renderType value */
if (!validate_renderType_against_config(config_base, renderType)) {
return NULL;
* GLX_CONTEXT_*_BIT values.
*/
ctx_attribs[num_ctx_attribs++] = flags;
+
+ if (flags & __DRI_CTX_FLAG_NO_ERROR)
+ pcp->base.noError = GL_TRUE;
}
pcp->base.renderType = renderType;
pdp->base.drawable = drawable;
pdp->base.psc = &psc->base;
- ret = XCreateGCs(pdp, psc->base.dpy, xDrawable, modes->visualID);
+ ret = driswCreateGCs(pdp, psc->base.dpy, xDrawable, modes->visualID);
if (!ret) {
free(pdp);
return NULL;
static int
check_xshm(Display *dpy)
{
+ int (*old_handler)(Display *, XErrorEvent *);
+
int ignore;
+ XShmSegmentInfo info = { 0, };
- return XQueryExtension(dpy, "MIT-SHM", &xshm_opcode, &ignore, &ignore);
+ 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;
+
+ xshm_error = 0;
+ return True;
}
static struct glx_screen *