[PATCH 2/2] glx: Add hack for GLX-1.2-style naked windows to GetDrawableAttributes

Adam Jackson ajax at redhat.com
Tue Dec 2 12:01:44 PST 2014


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
Signed-off-by: Adam Jackson <ajax at redhat.com>
---
 glx/glxcmds.c | 48 +++++++++++++++++++++++++++++-------------------
 1 file changed, 29 insertions(+), 19 deletions(-)

diff --git a/glx/glxcmds.c b/glx/glxcmds.c
index 2240a5b..dbfb1ae 100644
--- a/glx/glxcmds.c
+++ b/glx/glxcmds.c
@@ -1914,38 +1914,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;
-    num++;
-    attributes[2*num] = GLX_FBCONFIG_ID;
-    attributes[2*num+1] = pGlxDraw->config->fbconfigID;
+    attributes[2*num+1] = pDraw->height;
     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) {
-- 
1.9.3



More information about the xorg-devel mailing list