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.
This commit is contained in:
Kristian Høgsberg
2010-07-19 09:37:07 -04:00
parent 4eaf591d15
commit 3750ebd540
3 changed files with 42 additions and 3 deletions
+2 -1
View File
@@ -99,9 +99,10 @@ DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire)
{
GLXBufferSwapComplete *aevent = (GLXBufferSwapComplete *)event;
xDRI2BufferSwapComplete *awire = (xDRI2BufferSwapComplete *)wire;
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, awire->drawable, NULL);
__GLXDRIdrawable *pdraw;
/* Ignore swap events if we're not looking for them */
pdraw = dri2GetGlxDrawableFromXDrawableId(dpy, awire->drawable);
if (!(pdraw->eventMask & GLX_BUFFER_SWAP_COMPLETE_INTEL_MASK))
return False;
+38 -2
View File
@@ -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;
}
+2
View File
@@ -650,6 +650,8 @@ struct __GLXdisplayPrivateRec
#endif
};
extern __GLXDRIdrawable *
dri2GetGlxDrawableFromXDrawableId(Display *dpy, XID id);
extern GLubyte *__glXFlushRenderBuffer(__GLXcontext *, GLubyte *);