[vlc-commits] GLX: use separate XCB and Xlib connections (close #5698)

Rémi Denis-Courmont git at videolan.org
Mon Feb 6 20:34:15 CET 2012


vlc/vlc-1.1 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Feb  6 20:50:10 2012 +0200| [80eaa82b5a1f7d76c2d3751681f09f73489da444] | committer: Rémi Denis-Courmont

GLX: use separate XCB and Xlib connections (close #5698)

Some GLX drivers, such as newer versions of the Intel drivers,
depend on X11 events coming from Xlib. So VLC cannot steal them from
the underlying XCB connection.

I have no time and will to duplicate the XCB code found in the GLX
plugin for windowing and events handling using Xlib. So lets make a
separate X connection with XCB. This is inefficient, but it works.

On the plus side, this patch removes the dependency on libx11-xcb.
So it is now possible to compile and use GLX with an Xtrans-based
Xlib (though libxcb must be present).
(cherry picked from commit 63a73525adc604aad1282f5479660ee953cc6704)

Conflicts:

	configure.ac

> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.1.git/?a=commit;h=80eaa82b5a1f7d76c2d3751681f09f73489da444
---

 configure.ac                    |    1 -
 modules/video_output/Modules.am |    4 ++--
 modules/video_output/xcb/glx.c  |   18 ++++++++++++------
 3 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/configure.ac b/configure.ac
index b8a2c19..6e92258 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3365,7 +3365,6 @@ AC_ARG_ENABLE(glx,
   enable_glx="$enable_xcb"
 ])
 AS_IF([test "${enable_glx}" != "no"], [
-  PKG_CHECK_MODULES(XLIB_XCB, [x11-xcb])
   PKG_CHECK_MODULES(GL, [gl],, [
     AC_CHECK_HEADER([GL/gl.h], [
       GL_CFLAGS=""
diff --git a/modules/video_output/Modules.am b/modules/video_output/Modules.am
index 9034b71..98690b5 100644
--- a/modules/video_output/Modules.am
+++ b/modules/video_output/Modules.am
@@ -47,9 +47,9 @@ libxcb_glx_plugin_la_SOURCES = \
 	xcb/glx.c \
 	xcb/events.c
 libxcb_glx_plugin_la_CFLAGS = $(AM_CFLAGS) \
-	$(XLIB_XCB_CFLAGS) $(GL_CFLAGS)
+	$(XCB_CFLAGS) $(GL_CFLAGS)
 libxcb_glx_plugin_la_LIBADD = $(AM_LIBADD) \
-	$(XLIB_XCB_LIBS) $(GL_LIBS)
+	$(XCB_LIBS) $(GL_LIBS) $(X_LIBS) $(X_PRE_LIBS) -lX11
 libxcb_glx_plugin_la_DEPENDENCIES =
 
 libxcb_window_plugin_la_SOURCES = xcb/window.c xcb/keys.c xcb/keysym.h xcb/xcb_keysym.h
diff --git a/modules/video_output/xcb/glx.c b/modules/video_output/xcb/glx.c
index ed13341..16c3cc0 100644
--- a/modules/video_output/xcb/glx.c
+++ b/modules/video_output/xcb/glx.c
@@ -29,7 +29,6 @@
 #include <assert.h>
 
 #include <xcb/xcb.h>
-#include <X11/Xlib-xcb.h>
 #include <GL/glx.h>
 
 #include <vlc_common.h>
@@ -231,23 +230,29 @@ static int Open (vlc_object_t *obj)
     }
 
     /* Connect to X server */
+    xcb_connection_t *conn = xcb_connect (sys->embed->display.x11, NULL);
+    if (unlikely(xcb_connection_has_error (conn)))
+    {
+        vout_display_DeleteWindow (vd, sys->embed);
+        free (sys);
+        return VLC_EGENERIC;
+    }
+
     Display *dpy = XOpenDisplay (sys->embed->display.x11);
     if (dpy == NULL)
     {
+        xcb_disconnect (conn);
         vout_display_DeleteWindow (vd, sys->embed);
         free (sys);
         return VLC_EGENERIC;
     }
     sys->display = dpy;
+    sys->conn = conn;
     sys->ctx = NULL;
-    XSetEventQueueOwner (dpy, XCBOwnsEventQueue);
 
     if (!CheckGLX (vd, dpy, &sys->v1_3))
         goto error;
 
-    xcb_connection_t *conn = XGetXCBConnection (dpy);
-    assert (conn != NULL);
-    sys->conn = conn;
     RegisterMouseEvents (obj, conn, sys->embed->handle.xid);
 
     /* Find window parameters */
@@ -428,13 +433,14 @@ static void Close (vlc_object_t *obj)
         if (sys->v1_3)
             glXDestroyWindow (dpy, sys->glwin);
     }
+    XCloseDisplay (dpy);
 
     /* show the default cursor */
     xcb_change_window_attributes (sys->conn, sys->embed->handle.xid,
                                XCB_CW_CURSOR, &(uint32_t) { XCB_CURSOR_NONE });
     xcb_flush (sys->conn);
+    xcb_disconnect (sys->conn);
 
-    XCloseDisplay (dpy);
     vout_display_DeleteWindow (vd, sys->embed);
     free (sys);
 }



More information about the vlc-commits mailing list