summaryrefslogtreecommitdiff
path: root/src/glx/dri2_glx.c
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2010-07-19 09:37:07 -0400
committerKristian Høgsberg <krh@bitplanet.net>2010-07-19 09:37:38 -0400
commit3750ebd540510324ef5ada769537ae05309adadb (patch)
tree7c132086ed4e029a9f552ad100db6248f51e089b /src/glx/dri2_glx.c
parent4eaf591d1504f61e131f77f01711d27a75d02e90 (diff)
glx: Fix drawable lookup in DRI2 event handler
DRI2 events are sent to the X drawable ID used to create the DRI2 drawable, not the GLX drawable ID. So when an event comes in, we need to look up the __GLXDRIdrawable by its X drawable ID, which needs a new hash table.
Diffstat (limited to 'src/glx/dri2_glx.c')
-rw-r--r--src/glx/dri2_glx.c40
1 files changed, 38 insertions, 2 deletions
diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c
index d4747388e3..04d900c2e5 100644
--- a/src/glx/dri2_glx.c
+++ b/src/glx/dri2_glx.c
@@ -74,6 +74,8 @@ struct __GLXDRIdisplayPrivateRec
int swapAvailable;
int invalidateAvailable;
+ __glxHashTable *dri2Hash;
+
const __DRIextension *loader_extensions[4];
};
@@ -166,10 +168,16 @@ dri2CreateContext(__GLXscreenConfigs * psc,
}
static void
-dri2DestroyDrawable(__GLXDRIdrawable * pdraw)
+dri2DestroyDrawable(__GLXDRIdrawable *pdraw)
{
const __DRIcoreExtension *core = pdraw->psc->core;
+ __GLXdisplayPrivate *dpyPriv;
+ __GLXDRIdisplayPrivate *pdp;
+ dpyPriv = __glXInitialize(pdraw->psc->dpy);
+ pdp = (__GLXDRIdisplayPrivate *)dpyPriv->dri2Display;
+
+ __glxHashDelete(pdp->dri2Hash, pdraw->xDrawable);
(*core->destroyDrawable) (pdraw->driDrawable);
DRI2DestroyDrawable(pdraw->psc->dpy, pdraw->xDrawable);
Xfree(pdraw);
@@ -228,6 +236,14 @@ dri2CreateDrawable(__GLXscreenConfigs * psc,
return NULL;
}
+ if (__glxHashInsert(pdp->dri2Hash, xDrawable, pdraw)) {
+ (*psc->core->destroyDrawable) (pdraw->base.driDrawable);
+ DRI2DestroyDrawable(psc->dpy, xDrawable);
+ Xfree(pdraw);
+ return None;
+ }
+
+
#ifdef X_DRI2SwapInterval
/*
* Make sure server has the same swap interval we do for the new
@@ -555,7 +571,8 @@ static const __DRIuseInvalidateExtension dri2UseInvalidate = {
_X_HIDDEN void
dri2InvalidateBuffers(Display *dpy, XID drawable)
{
- __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL);
+ __GLXDRIdrawable *pdraw =
+ dri2GetGlxDrawableFromXDrawableId(dpy, drawable);
#if __DRI2_FLUSH_VERSION >= 3
if (pdraw && pdraw->psc->f)
@@ -751,6 +768,19 @@ dri2DestroyDisplay(__GLXDRIdisplay * dpy)
Xfree(dpy);
}
+_X_HIDDEN __GLXDRIdrawable *
+dri2GetGlxDrawableFromXDrawableId(Display *dpy, XID id)
+{
+ __GLXdisplayPrivate *d = __glXInitialize(dpy);
+ __GLXDRIdisplayPrivate *pdp = (__GLXDRIdisplayPrivate *) d->dri2Display;
+ __GLXDRIdrawable *pdraw;
+
+ if (__glxHashLookup(pdp->dri2Hash, id, (void *) &pdraw) == 0)
+ return pdraw;
+
+ return NULL;
+}
+
/*
* Allocate, initialize and return a __DRIdisplayPrivate object.
* This is called from __glXInitialize() when we are given a new
@@ -794,6 +824,12 @@ dri2CreateDisplay(Display * dpy)
#endif
pdp->loader_extensions[i++] = NULL;
+ pdp->dri2Hash = __glxHashCreate();
+ if (pdp->dri2Hash == NULL) {
+ Xfree(pdp);
+ return NULL;
+ }
+
return &pdp->base;
}