From cadd70c809232c9a6601fb8baab665a7ab10045d Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Tue, 2 Dec 2014 14:52:35 -0500 Subject: [PATCH] glx: Add hack for GLX-1.2-style naked windows to GetDrawableAttributes Some people like to call this on bare Window XIDs and expect reasonable results. I sure wish they wouldn't, but since they do, if we're given a window without any glx decoration just fill in as much as we can. This means you won't actually get an answer for GLX_FBCONFIG_ID and friends, but there's not much to be done about that, and it matches what NVIDIA's driver seems to do. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=54080 Reviewed-by: Eric Anholt Signed-off-by: Adam Jackson --- glx/glxcmds.c | 48 +++++++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/glx/glxcmds.c b/glx/glxcmds.c index 4de86439e..f5f2babb8 100644 --- a/glx/glxcmds.c +++ b/glx/glxcmds.c @@ -1916,38 +1916,48 @@ DoGetDrawableAttributes(__GLXclientState * cl, XID drawId) { ClientPtr client = cl->client; xGLXGetDrawableAttributesReply reply; - __GLXdrawable *pGlxDraw; + __GLXdrawable *pGlxDraw = NULL; + DrawablePtr pDraw; CARD32 attributes[14]; int num = 0, error; if (!validGlxDrawable(client, drawId, GLX_DRAWABLE_ANY, - DixGetAttrAccess, &pGlxDraw, &error)) - return error; + DixGetAttrAccess, &pGlxDraw, &error)) { + /* hack for GLX 1.2 naked windows */ + int err = dixLookupWindow((WindowPtr *)&pDraw, drawId, client, + DixGetAttrAccess); + if (err != Success) + return error; + } + if (pGlxDraw) + pDraw = pGlxDraw->pDraw; - attributes[2*num] = GLX_TEXTURE_TARGET_EXT; - attributes[2*num+1] = pGlxDraw->target == GL_TEXTURE_2D ? - GLX_TEXTURE_2D_EXT : - GLX_TEXTURE_RECTANGLE_EXT; - num++; attributes[2*num] = GLX_Y_INVERTED_EXT; attributes[2*num+1] = GL_FALSE; num++; - attributes[2*num] = GLX_EVENT_MASK; - attributes[2*num+1] = pGlxDraw->eventMask; - num++; attributes[2*num] = GLX_WIDTH; - attributes[2*num+1] = pGlxDraw->pDraw->width; + attributes[2*num+1] = pDraw->width; num++; attributes[2*num] = GLX_HEIGHT; - attributes[2*num+1] = pGlxDraw->pDraw->height; + attributes[2*num+1] = pDraw->height; num++; - attributes[2*num] = GLX_FBCONFIG_ID; - attributes[2*num+1] = pGlxDraw->config->fbconfigID; - num++; - if (pGlxDraw->type == GLX_DRAWABLE_PBUFFER) { - attributes[2*num] = GLX_PRESERVED_CONTENTS; - attributes[2*num+1] = GL_TRUE; + if (pGlxDraw) { + attributes[2*num] = GLX_TEXTURE_TARGET_EXT; + attributes[2*num+1] = pGlxDraw->target == GL_TEXTURE_2D ? + GLX_TEXTURE_2D_EXT : + GLX_TEXTURE_RECTANGLE_EXT; num++; + attributes[2*num] = GLX_EVENT_MASK; + attributes[2*num+1] = pGlxDraw->eventMask; + num++; + attributes[2*num] = GLX_FBCONFIG_ID; + attributes[2*num+1] = pGlxDraw->config->fbconfigID; + num++; + if (pGlxDraw->type == GLX_DRAWABLE_PBUFFER) { + attributes[2*num] = GLX_PRESERVED_CONTENTS; + attributes[2*num+1] = GL_TRUE; + num++; + } } reply = (xGLXGetDrawableAttributesReply) {