[vlc-devel] [PATCH] Rely on Qt with determining if XCB or Wayland should be used

Martin Briza mbriza at redhat.com
Tue Jun 6 12:03:09 CEST 2017


Related to https://trac.videolan.org/vlc/ticket/18383 .

This makes the Qt frontend work right in GNOME Shell where the users had no chance to switch back to the XCB backend and had a completely broken player.

As a bonus, it's now possible to use QT_QPA_PLATFORM to set which backend you want to use to run VLC.

Yes, it will crash if Qt tries to run on XCB or Wayland while it's not present but this can be fixed by having a custom message handler for qFatal messages (which contains an abort() call by default)
---
 modules/gui/qt/qt.cpp | 40 ++--------------------------------------
 1 file changed, 2 insertions(+), 38 deletions(-)

diff --git a/modules/gui/qt/qt.cpp b/modules/gui/qt/qt.cpp
index 2ad68eb..db6c4c1 100644
--- a/modules/gui/qt/qt.cpp
+++ b/modules/gui/qt/qt.cpp
@@ -365,13 +365,7 @@ static void Abort( void *obj )
 #if defined (QT5_HAS_X11)
 # include <vlc_xlib.h>
 
-static void *ThreadXCB( void *data )
-{
-    char platform_name[] = "xcb";
-    return ThreadPlatform( data, platform_name );
-}
-
-static bool HasX11( vlc_object_t *obj )
+static bool TestX11( vlc_object_t *obj )
 {
     if( !vlc_xlib_init( obj ) )
         return false;
@@ -385,44 +379,14 @@ static bool HasX11( vlc_object_t *obj )
 }
 #endif
 
-#ifdef QT5_HAS_WAYLAND
-# include <wayland-client.h>
-
-static void *ThreadWayland( void *data )
-{
-    char platform_name[] = "wayland";
-    return ThreadPlatform( data, platform_name );
-}
-
-static bool HasWayland( void )
-{
-    struct wl_display *dpy = wl_display_connect( NULL );
-    if( dpy == NULL )
-        return false;
-
-    wl_display_disconnect( dpy );
-    return true;
-}
-#endif
-
 /* Open Interface */
 static int Open( vlc_object_t *p_this, bool isDialogProvider )
 {
     intf_thread_t *p_intf = (intf_thread_t *)p_this;
     void *(*thread)(void *) = Thread;
 
-#ifdef QT5_HAS_WAYLAND
-    if( HasWayland() )
-        thread = ThreadWayland;
-    else
-#endif
 #ifdef QT5_HAS_X11
-    if( HasX11( p_this ) )
-        thread = ThreadXCB;
-    else
-#endif
-#if defined (QT5_HAS_X11) || defined (QT5_HAS_WAYLAND)
-        return VLC_EGENERIC;
+    TestX11( p_this );
 #endif
 
     QMutexLocker locker (&lock);
-- 
2.13.0



More information about the vlc-devel mailing list