Workaround an xcb-dri2 bug.
authorChia-I Wu <olvaffe@gmail.com>
Fri, 29 Oct 2010 07:20:18 +0000 (15:20 +0800)
committerKristian Høgsberg <krh@bitplanet.net>
Fri, 29 Oct 2010 16:52:28 +0000 (12:52 -0400)
xcb_dri2_connect_device_name generated by xcb-proto 1.6 is broken.  It
only works when the length of the driver name is a multiple of 4.

compositor/compositor-x11.c
configure.ac

index b7a9d0d..f55b30e 100644 (file)
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -152,9 +156,22 @@ dri2_connect(struct x11_compositor *c)
                return -1;
        }
 
+#ifdef XCB_DRI2_CONNECT_DEVICE_NAME_BROKEN
+       {
+               char *driver_name, *device_name;
+
+               driver_name = xcb_dri2_connect_driver_name (connect);
+               device_name = driver_name +
+                       ((connect->driver_name_length + 3) & ~3);
+               snprintf(path, sizeof path, "%.*s",
+                        xcb_dri2_connect_device_name_length (connect),
+                        device_name);
+       }
+#else
        snprintf(path, sizeof path, "%.*s",
                 xcb_dri2_connect_device_name_length (connect),
                 xcb_dri2_connect_device_name (connect));
+#endif
        free(connect);
 
        fd = open(path, O_RDWR);
index b510b51..f57e2bd 100644 (file)
@@ -34,6 +34,11 @@ AC_CHECK_LIB(expat, XML_ParserCreate, [EXPAT_LIBS="-lexpat"],
             [AC_MSG_ERROR([Can't find expat library. Please install expat.])])
 AC_SUBST(EXPAT_LIBS)
 
+# workaround a bug in xcb-dri2 generated by xcb-proto 1.6
+AC_CHECK_LIB(xcb-dri2, xcb_dri2_connect_alignment_pad, [],
+            [AC_DEFINE([XCB_DRI2_CONNECT_DEVICE_NAME_BROKEN], [1],
+                       [Define to 1 if xcb_dri2_connect_device_name is broken])])
+
 AC_CONFIG_FILES([wayland/wayland-server.pc
                 wayland/wayland-client.pc
                 Makefile