drisw: Fix and simplify drawable setup
[mesa.git] / src / glx / glx_pbuffer.c
index a0c1e3d98090d85390365595034f4612bd9b81aa..515099aa0d8767121fb5e7ceda383274d885a2be 100644 (file)
@@ -272,9 +272,9 @@ DestroyDRIDrawable(Display *dpy, GLXDrawable drawable, int destroy_xdrawable)
  * 10.  Given that, this routine should try to use an array on the stack to
  * capture the reply rather than always calling Xmalloc.
  */
-static int
-GetDrawableAttribute(Display * dpy, GLXDrawable drawable,
-                     int attribute, unsigned int *value)
+int
+__glXGetDrawableAttribute(Display * dpy, GLXDrawable drawable,
+                          int attribute, unsigned int *value)
 {
    struct glx_display *priv;
    xGLXGetDrawableAttributesReply reply;
@@ -328,7 +328,7 @@ GetDrawableAttribute(Display * dpy, GLXDrawable drawable,
        *   the calling thread's current context a GLXBadDrawable error is
        *   generated."
        */
-      if (pdraw == NULL || gc == NULL || gc->currentDpy != dpy ||
+      if (pdraw == NULL || gc == &dummyContext || gc->currentDpy != dpy ||
          (gc->currentDrawable != drawable &&
          gc->currentReadable != drawable)) {
          __glXSendError(dpy, GLXBadDrawable, drawable,
@@ -414,7 +414,7 @@ GetDrawableAttribute(Display * dpy, GLXDrawable drawable,
    UnlockDisplay(dpy);
    SyncHandle();
 
-   return 0;
+   return 1;
 }
 
 static void
@@ -825,7 +825,7 @@ glXQueryDrawable(Display * dpy, GLXDrawable drawable,
       }
    }
 #else
-   GetDrawableAttribute(dpy, drawable, attribute, value);
+   __glXGetDrawableAttribute(dpy, drawable, attribute, value);
 #endif
 }
 
@@ -834,11 +834,11 @@ glXQueryDrawable(Display * dpy, GLXDrawable drawable,
 /**
  * Query an attribute of a pbuffer.
  */
-_GLX_PUBLIC int
+_GLX_PUBLIC void
 glXQueryGLXPbufferSGIX(Display * dpy, GLXPbufferSGIX drawable,
                        int attribute, unsigned int *value)
 {
-   return GetDrawableAttribute(dpy, drawable, attribute, value);
+   __glXGetDrawableAttribute(dpy, drawable, attribute, value);
 }
 #endif
 
@@ -901,7 +901,7 @@ glXGetSelectedEvent(Display * dpy, GLXDrawable drawable, unsigned long *mask)
    __glXSendError(dpy, GLXBadDrawable, drawable, X_GLXGetDrawableAttributes,
                   true);
 #else
-   unsigned int value;
+   unsigned int value = 0;
 
 
    /* The non-sense with value is required because on LP64 platforms
@@ -909,7 +909,7 @@ glXGetSelectedEvent(Display * dpy, GLXDrawable drawable, unsigned long *mask)
     * we could just type-cast the pointer, but why?
     */
 
-   GetDrawableAttribute(dpy, drawable, GLX_EVENT_MASK_SGIX, &value);
+   __glXGetDrawableAttribute(dpy, drawable, GLX_EVENT_MASK_SGIX, &value);
    *mask = value;
 #endif
 }
@@ -992,7 +992,6 @@ glXDestroyWindow(Display * dpy, GLXWindow win)
 #endif
 }
 
-#ifndef GLX_USE_APPLEGL
 _GLX_PUBLIC
 GLX_ALIAS_VOID(glXDestroyGLXPbufferSGIX,
                (Display * dpy, GLXPbufferSGIX pbuf),
@@ -1008,4 +1007,3 @@ GLX_ALIAS_VOID(glXGetSelectedEventSGIX,
                (Display * dpy, GLXDrawable drawable,
                 unsigned long *mask), (dpy, drawable, mask),
                glXGetSelectedEvent)
-#endif