query extensions on the display
authorDana Jansens <danakj@orodu.net>
Tue, 4 Mar 2008 19:30:44 +0000 (14:30 -0500)
committerDana Jansens <danakj@orodu.net>
Tue, 4 Mar 2008 19:30:44 +0000 (14:30 -0500)
Makefile
display.c
display.h

index f32f5d3..a5b283f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,8 +2,8 @@ sources = $(wildcard *.c)
 objs = $(sources:.c=.o)
 headers = $(wildcard *.h)
 
-CFLAGS=$(shell pkg-config --cflags xcb-composite glib-2.0) -ggdb -W -Wall
-LIBS=$(shell pkg-config --libs xcb-composite glib-2.0)
+CFLAGS=$(shell pkg-config --cflags xcb-composite xcb-damage glib-2.0) -ggdb -W -Wall
+LIBS=$(shell pkg-config --libs xcb-composite xcb-damage glib-2.0)
 
 dcompmgr: $(objs)
        $(CC) -o $@ $^ $(LIBS) $(LDFLAGS)
index ffca5e6..1811f5b 100644 (file)
--- a/display.c
+++ b/display.c
@@ -2,9 +2,52 @@
 #include <stdlib.h>
 #include <stdio.h>
 
+#include <xcb/damage.h>
 #include <xcb/render.h>
 #include <xcb/xfixes.h>
-#include <xcb/damage.h>
+#include <xcb/composite.h>
+
+static void
+query_extensions(d_display_t *dpy)
+{
+    xcb_xfixes_query_version_cookie_t      fixes_version_cookie;
+    xcb_render_query_version_cookie_t      render_version_cookie;
+    xcb_composite_query_version_cookie_t   composite_version_cookie;
+    xcb_damage_query_version_cookie_t      damage_version_cookie;
+    xcb_render_query_pict_formats_cookie_t render_formats_cookie;
+
+    const xcb_query_extension_reply_t *rep;
+
+    xcb_prefetch_extension_data(dpy->conn, &xcb_xfixes_id);
+    xcb_prefetch_extension_data(dpy->conn, &xcb_render_id);
+    xcb_prefetch_extension_data(dpy->conn, &xcb_composite_id);
+    xcb_prefetch_extension_data(dpy->conn, &xcb_damage_id);
+
+    rep = xcb_get_extension_data(dpy->conn, &xcb_xfixes_id);
+    dpy->xfixes = rep && rep->present;
+    dpy->xfixes_error = rep && rep->first_error;
+    dpy->xfixes_event = rep && rep->first_event;
+    dpy->xfixes_opcode = rep && rep->major_opcode;
+
+    rep = xcb_get_extension_data(dpy->conn, &xcb_render_id);
+    dpy->render = rep && rep->present;
+    dpy->render_error = rep && rep->first_error;
+    dpy->render_event = rep && rep->first_event;
+    dpy->render_opcode = rep && rep->major_opcode;
+
+    rep = xcb_get_extension_data(dpy->conn, &xcb_composite_id);
+    dpy->composite = rep && rep->present;
+    dpy->composite_error = rep && rep->first_error;
+    dpy->composite_event = rep && rep->first_event;
+    dpy->composite_opcode = rep && rep->major_opcode;
+
+    rep = xcb_get_extension_data(dpy->conn, &xcb_damage_id);
+    dpy->damage = rep && rep->present;
+    dpy->damage_error = rep && rep->first_error;
+    dpy->damage_event = rep && rep->first_event;
+    dpy->damage_opcode = rep && rep->major_opcode;
+}
+
 
 d_display_t*
 display_open(const char *name)
@@ -17,6 +60,8 @@ display_open(const char *name)
         dpy = malloc(sizeof(d_display_t));
         dpy->conn = conn;
         dpy->ref = 1;
+
+        query_extensions(dpy);
     }
     return dpy;
 }
@@ -59,7 +104,7 @@ display_error(d_display_t *dpy, xcb_generic_error_t *ev)
     default: break;
     }
     if (!name)
-        switch (ev->error_code - dpy->fixes_error) {
+        switch (ev->error_code - dpy->xfixes_error) {
         case XCB_XFIXES_BAD_REGION: name = "BadRegion"; break;
         default: break;
         }
index f46ed46..282c480 100644 (file)
--- a/display.h
+++ b/display.h
@@ -3,13 +3,31 @@
 
 #include <xcb/xcb.h>
 
+#include <glib.h>
+
 typedef struct d_display {
     xcb_connection_t *conn;
     int               ref;
 
-    int fixes_error;
-    int damage_error;
-    int render_error;
+    gboolean xfixes;
+    int      xfixes_error;
+    int      xfixes_event;
+    int      xfixes_opcode;
+
+    gboolean render;
+    int      render_error;
+    int      render_event;
+    int      render_opcode;
+
+    gboolean composite;
+    int      composite_error;
+    int      composite_event;
+    int      composite_opcode;
+
+    gboolean damage;
+    int      damage_error;
+    int      damage_event;
+    int      damage_opcode;
 } d_display_t;
 
 d_display_t* display_open(const char *name);