Commit 785b0f18 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

qt: add Wayland run-time detection

This is for the GUI only. It does _NOT_ include video embedded
windowing.
parent 84796d32
...@@ -24,6 +24,10 @@ if HAVE_QT5_X11 ...@@ -24,6 +24,10 @@ if HAVE_QT5_X11
libqt_plugin_la_CXXFLAGS += $(QT5_X11_CFLAGS) -DQT5_HAS_X11 libqt_plugin_la_CXXFLAGS += $(QT5_X11_CFLAGS) -DQT5_HAS_X11
libqt_plugin_la_LIBADD += $(QT5_X11_LIBS) libqt_plugin_la_LIBADD += $(QT5_X11_LIBS)
endif endif
if HAVE_WAYLAND
libqt_plugin_la_CXXFLAGS += $(WAYLAND_CLIENT_CFLAGS) -DQT5_HAS_WAYLAND
libqt_plugin_la_LIBADD += $(WAYLAND_CLIENT_LIBS)
endif
if HAVE_WIN32 if HAVE_WIN32
libqt_plugin_la_LIBADD += $(LIBCOM) -lcomctl32 -luuid libqt_plugin_la_LIBADD += $(LIBCOM) -lcomctl32 -luuid
else else
......
...@@ -44,10 +44,6 @@ ...@@ -44,10 +44,6 @@
#include "util/qvlcapp.hpp" /* QVLCApplication definition */ #include "util/qvlcapp.hpp" /* QVLCApplication definition */
#include "components/playlist/playlist_model.hpp" /* for ~PLModel() */ #include "components/playlist/playlist_model.hpp" /* for ~PLModel() */
#if defined (QT5_HAS_X11) || defined (Q_WS_X11)
#include <vlc_xlib.h>
#endif
#include <vlc_plugin.h> #include <vlc_plugin.h>
#include <vlc_vout_window.h> #include <vlc_vout_window.h>
...@@ -75,7 +71,6 @@ static int Open ( vlc_object_t *, bool ); ...@@ -75,7 +71,6 @@ static int Open ( vlc_object_t *, bool );
static void Close ( vlc_object_t * ); static void Close ( vlc_object_t * );
static int WindowOpen ( vout_window_t *, const vout_window_cfg_t * ); static int WindowOpen ( vout_window_t *, const vout_window_cfg_t * );
static void WindowClose ( vout_window_t * ); static void WindowClose ( vout_window_t * );
static void *Thread ( void * );
static void ShowDialog ( intf_thread_t *, int, int, intf_dialog_args_t * ); static void ShowDialog ( intf_thread_t *, int, int, intf_dialog_args_t * );
/***************************************************************************** /*****************************************************************************
...@@ -333,6 +328,13 @@ static bool active = false; ...@@ -333,6 +328,13 @@ static bool active = false;
* Module callbacks * Module callbacks
*****************************************************************************/ *****************************************************************************/
static void *ThreadPlatform( void *, char * );
static void *Thread( void *data )
{
return ThreadPlatform( data, NULL );
}
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
/* Used to abort the app.exec() on OSX after libvlc_Quit is called */ /* Used to abort the app.exec() on OSX after libvlc_Quit is called */
#include "../../../lib/libvlc_internal.h" /* libvlc_SetExitHandler */ #include "../../../lib/libvlc_internal.h" /* libvlc_SetExitHandler */
...@@ -342,6 +344,49 @@ static void Abort( void *obj ) ...@@ -342,6 +344,49 @@ static void Abort( void *obj )
} }
#endif #endif
#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 )
{
if( !vlc_xlib_init( obj ) )
return false;
Display *dpy = XOpenDisplay( NULL );
if( dpy == NULL )
return false;
XCloseDisplay( dpy );
return true;
}
#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
static void RegisterIntf( intf_thread_t *p_this ) static void RegisterIntf( intf_thread_t *p_this )
{ {
playlist_t *pl = p_this->p_sys->p_playlist; playlist_t *pl = p_this->p_sys->p_playlist;
...@@ -355,18 +400,24 @@ static void RegisterIntf( intf_thread_t *p_this ) ...@@ -355,18 +400,24 @@ static void RegisterIntf( intf_thread_t *p_this )
static int Open( vlc_object_t *p_this, bool isDialogProvider ) static int Open( vlc_object_t *p_this, bool isDialogProvider )
{ {
intf_thread_t *p_intf = (intf_thread_t *)p_this; intf_thread_t *p_intf = (intf_thread_t *)p_this;
void *(*thread)(void *) = Thread;
#if defined (QT5_HAS_X11) || defined (Q_WS_X11) #ifdef QT5_HAS_WAYLAND
if( !vlc_xlib_init( p_this ) ) 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; return VLC_EGENERIC;
#endif
Display *p_display = XOpenDisplay( NULL ); #ifdef Q_WS_X11
if( !p_display ) if( !HasX11( p_this ) )
{
msg_Err( p_intf, "Could not connect to X server" );
return VLC_EGENERIC; return VLC_EGENERIC;
}
XCloseDisplay( p_display );
#endif #endif
QMutexLocker locker (&lock); QMutexLocker locker (&lock);
...@@ -393,9 +444,9 @@ static int Open( vlc_object_t *p_this, bool isDialogProvider ) ...@@ -393,9 +444,9 @@ static int Open( vlc_object_t *p_this, bool isDialogProvider )
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
/* Run mainloop on the main thread as Cocoa requires */ /* Run mainloop on the main thread as Cocoa requires */
libvlc_SetExitHandler( p_intf->obj.libvlc, Abort, p_intf ); libvlc_SetExitHandler( p_intf->obj.libvlc, Abort, p_intf );
Thread( (void *)p_intf ); thread( (void *)p_intf );
#else #else
if( vlc_clone( &p_sys->thread, Thread, p_intf, VLC_THREAD_PRIORITY_LOW ) ) if( vlc_clone( &p_sys->thread, thread, p_intf, VLC_THREAD_PRIORITY_LOW ) )
{ {
delete p_sys; delete p_sys;
return VLC_ENOMEM; return VLC_ENOMEM;
...@@ -458,23 +509,22 @@ static void Close( vlc_object_t *p_this ) ...@@ -458,23 +509,22 @@ static void Close( vlc_object_t *p_this )
busy = false; busy = false;
} }
static void *Thread( void *obj ) static void *ThreadPlatform( void *obj, char *platform_name )
{ {
intf_thread_t *p_intf = (intf_thread_t *)obj; intf_thread_t *p_intf = (intf_thread_t *)obj;
intf_sys_t *p_sys = p_intf->p_sys; intf_sys_t *p_sys = p_intf->p_sys;
char vlc_name[] = "vlc"; /* for WM_CLASS */ char vlc_name[] = "vlc"; /* for WM_CLASS */
#ifdef QT5_HAS_X11
char platform_parm[] = "-platform"; char platform_parm[] = "-platform";
char platform_value[] = "xcb"; char *argv[4];
#endif int argc = 0;
char *argv[] = {
vlc_name, argv[argc++] = vlc_name;
#ifdef QT5_HAS_X11 if( platform_name != NULL )
platform_parm, platform_value, {
#endif argv[argc++] = platform_parm;
NULL, argv[argc++] = platform_name;
}; }
int argc = sizeof(argv) / sizeof(argv[0]) - 1; argv[argc] = NULL;
Q_INIT_RESOURCE( vlc ); Q_INIT_RESOURCE( vlc );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment