+#ifdef GLX_USE_APPLEGL
+ Window root;
+ int x, y;
+ unsigned int width, height, bd, depth;
+
+ if (apple_glx_pixmap_query(drawable, attribute, value))
+ return; /*done */
+
+ if (apple_glx_pbuffer_query(drawable, attribute, value))
+ return; /*done */
+
+ /*
+ * The OpenGL spec states that we should report GLXBadDrawable if
+ * the drawable is invalid, however doing so would require that we
+ * use XSetErrorHandler(), which is known to not be thread safe.
+ * If we use a round-trip call to validate the drawable, there could
+ * be a race, so instead we just opt in favor of letting the
+ * XGetGeometry request fail with a GetGeometry request X error
+ * rather than GLXBadDrawable, in what is hoped to be a rare
+ * case of an invalid drawable. In practice most and possibly all
+ * X11 apps using GLX shouldn't notice a difference.
+ */
+ if (XGetGeometry
+ (dpy, drawable, &root, &x, &y, &width, &height, &bd, &depth)) {
+ switch (attribute) {
+ case GLX_WIDTH:
+ *value = width;
+ break;
+
+ case GLX_HEIGHT:
+ *value = height;
+ break;
+ }
+ }
+#else
+ __glXGetDrawableAttribute(dpy, drawable, attribute, value);
+#endif