--- glx/glxdrawable.h.orig 2011-06-11 19:55:47.000000000 +0300 +++ glx/glxdrawable.h 2011-07-30 14:52:16.730791751 +0300 @@ -53,6 +53,7 @@ struct __GLXdrawable { DrawablePtr pDraw; XID drawId; + XID otherId; /* for glx1.3 we need to track the original Drawable as well */ /* ** Either GLX_DRAWABLE_PIXMAP, GLX_DRAWABLE_WINDOW or --- glx/glxcmds.c.orig 2011-06-11 19:55:47.000000000 +0300 +++ glx/glxcmds.c 2011-07-30 14:51:33.374788616 +0300 @@ -1095,6 +1095,7 @@ __glXDrawableInit(__GLXdrawable *drawabl drawable->pDraw = pDraw; drawable->type = type; drawable->drawId = drawId; + drawable->otherId = 0; drawable->config = config; drawable->eventMask = 0; @@ -1131,10 +1132,13 @@ DoCreateGLXDrawable(ClientPtr client, __ * Windows aren't refcounted, so track both the X and the GLX window * so we get called regardless of destruction order. */ - if (drawableId != glxDrawableId && type == GLX_DRAWABLE_WINDOW && - !AddResource(pDraw->id, __glXDrawableRes, pGlxDraw)) { - pGlxDraw->destroy (pGlxDraw); - return BadAlloc; + if (drawableId != glxDrawableId && + (type == GLX_DRAWABLE_WINDOW || type == GLX_DRAWABLE_PIXMAP)) { + if (!AddResource(drawableId, __glXDrawableRes, pGlxDraw)) { + pGlxDraw->destroy (pGlxDraw); + return BadAlloc; + } + pGlxDraw->otherId = drawableId; } return Success; --- glx/glxext.c.orig 2011-06-11 19:55:47.000000000 +0300 +++ glx/glxext.c 2011-07-30 14:51:03.306788511 +0300 @@ -124,14 +124,16 @@ static Bool DrawableGone(__GLXdrawable * { __GLXcontext *c, *next; - if (glxPriv->type == GLX_DRAWABLE_WINDOW) { + if (glxPriv->type == GLX_DRAWABLE_WINDOW || glxPriv->type == GLX_DRAWABLE_PIXMAP) { /* If this was created by glXCreateWindow, free the matching resource */ - if (glxPriv->drawId != glxPriv->pDraw->id) { - if (xid == glxPriv->drawId) - FreeResourceByType(glxPriv->pDraw->id, __glXDrawableRes, TRUE); - else - FreeResourceByType(glxPriv->drawId, __glXDrawableRes, TRUE); - } + if (glxPriv->otherId) { + XID other = glxPriv->otherId; + glxPriv->otherId = 0; + if (xid == other) + FreeResourceByType(glxPriv->drawId, __glXDrawableRes, TRUE); + else + FreeResourceByType(other, __glXDrawableRes, TRUE); + } /* otherwise this window was implicitly created by MakeCurrent */ }