glx: implement __glXQueryServerString using XCB
authorRALOVICH, Kristóf <tade60@freemail.hu>
Sat, 18 Oct 2008 14:53:08 +0000 (16:53 +0200)
committerBrian Paul <brian.paul@tungstengraphics.com>
Wed, 26 Nov 2008 17:00:58 +0000 (10:00 -0700)
src/glx/x11/glx_query.c
src/glx/x11/glxclient.h

index 56f34951863c66018e5918f1c5539377b0381617..ef33f7c403b71cdcfd5d83344552f7321f3513f7 100644 (file)
 
 #include "glxclient.h"
 
+#if defined(USE_XCB)
+# include <X11/Xlib-xcb.h>
+# include <xcb/xcb.h>
+# include <xcb/glx.h>
+#endif
+
 /**
  * GLX protocol structure for the ficticious "GXLGenericGetString" request.
  * 
@@ -101,3 +107,28 @@ __glXGetStringFromServer(Display * dpy, int opcode, CARD32 glxCode,
 
    return buf;
 }
+
+#ifdef USE_XCB
+char *
+__glXQueryServerString(Display* dpy,
+                       CARD32 screen,
+                       CARD32 name)
+{
+   xcb_connection_t *c = XGetXCBConnection(dpy);
+   xcb_glx_query_server_string_reply_t* reply =
+      xcb_glx_query_server_string_reply(c,
+                                        xcb_glx_query_server_string(c,
+                                                                    screen,
+                                                                    name),
+                                        NULL);
+
+   /* The spec doesn't mention this, but the Xorg server replies with
+    * a string already terminated with '\0'. */
+   uint32_t len = xcb_glx_query_server_string_string_length(reply);
+   char* buf = Xmalloc(len);
+   memcpy(buf, xcb_glx_query_server_string_string(reply), len);
+   free(reply);
+
+   return buf;
+}
+#endif /* USE_XCB */
index 02e8750c972f8f9946291550a8c0fb26c1c30dae..8f1e69154aca9b26f9ecde289e16c8f9ecab7882 100644 (file)
@@ -742,6 +742,10 @@ extern void __glXInitializeVisualConfigFromTags( __GLcontextModes *config,
 extern char * __glXGetStringFromServer( Display * dpy, int opcode,
     CARD32 glxCode, CARD32 for_whom, CARD32 name );
 
+#ifdef USE_XCB
+extern char * __glXQueryServerString(Display* dpy, CARD32 screen, CARD32 name);
+#endif
+
 extern char *__glXstrdup(const char *str);