[vlc-devel] [PATCH 2/2] Qt: Wayland vout window provider

Jean-Baptiste Kempf jb at videolan.org
Sat Feb 4 10:59:12 CET 2017


No big objection from me,  but that is a bit duplicating win32 code from
main_interface_win32.cpp

Best,

On Fri, 3 Feb 2017, at 18:13, RĂ©mi Denis-Courmont wrote:
> Note that this depends on Qt5 private headers.
> ---
>  configure.ac                                    |  2 ++
>  modules/gui/qt/Makefile.am                      |  4 +++-
>  modules/gui/qt/components/interface_widgets.cpp | 22
>  ++++++++++++++++++++++
>  modules/gui/qt/qt.cpp                           |  2 ++
>  4 files changed, 29 insertions(+), 1 deletion(-)
> 
> diff --git a/configure.ac b/configure.ac
> index 3a30a87f37..f1f604e88e 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -3761,6 +3761,7 @@ AS_IF([test "${enable_qt}" != "no"], [
>        ])
>        QT_PATH="$(eval $PKG_CONFIG --variable=exec_prefix Qt5Core)"
>        QT_HOST_PATH="$(eval $PKG_CONFIG --variable=host_bins Qt5Core)"
> +      QT_VERSION="$(eval $PKG_CONFIG --modversion Qt5Gui)"
>        AC_PATH_PROGS(MOC, [moc-qt5 moc], moc, ["${QT_HOST_PATH}"
>        "${QT_PATH}/bin"])
>        AC_PATH_PROGS(RCC, [rcc-qt5 rcc], rcc, ["${QT_HOST_PATH}"
>        "${QT_PATH}/bin"])
>        AC_PATH_PROGS(UIC, [uic-qt5 uic], uic, ["${QT_HOST_PATH}"
>        "${QT_PATH}/bin"])
> @@ -3783,6 +3784,7 @@ AS_IF([test "${enable_qt}" != "no"], [
>    VLC_ADD_PLUGIN([qt])
>    ALIASES="${ALIASES} qvlc"
>  ])
> +AC_SUBST(QT_VERSION)
>  AM_CONDITIONAL(ENABLE_QT, [test "$enable_qt" != "no"])
>  AM_CONDITIONAL([HAVE_QT5_X11], [test "${have_qt5_x11}" = "yes"])
>  
> diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am
> index dfe9c387a5..4e166d2561 100644
> --- a/modules/gui/qt/Makefile.am
> +++ b/modules/gui/qt/Makefile.am
> @@ -26,7 +26,9 @@ libqt_plugin_la_CXXFLAGS += $(QT5_X11_CFLAGS)
> -DQT5_HAS_X11
>  libqt_plugin_la_LIBADD += $(QT5_X11_LIBS) $(X_LIBS) $(X_PRE_LIB) -lX11
>  endif
>  if HAVE_WAYLAND
> -libqt_plugin_la_CXXFLAGS += $(WAYLAND_CLIENT_CFLAGS) -DQT5_HAS_WAYLAND
> +libqt_plugin_la_CPPFLAGS += -DQT5_HAS_WAYLAND \
> +      
> -DQPNI_HEADER=\<$(QT_VERSION)/QtGui/qpa/qplatformnativeinterface.h\>
> +libqt_plugin_la_CXXFLAGS += $(WAYLAND_CLIENT_CFLAGS)
>  libqt_plugin_la_LIBADD += $(WAYLAND_CLIENT_LIBS)
>  endif
>  if HAVE_WIN32
> diff --git a/modules/gui/qt/components/interface_widgets.cpp
> b/modules/gui/qt/components/interface_widgets.cpp
> index 5226addb72..6a5853b1b3 100644
> --- a/modules/gui/qt/components/interface_widgets.cpp
> +++ b/modules/gui/qt/components/interface_widgets.cpp
> @@ -54,6 +54,10 @@
>  # include <X11/Xlib.h>
>  # include <QX11Info>
>  #endif
> +#ifdef QT5_HAS_WAYLAND
> +# include QPNI_HEADER
> +# include <QWindow>
> +#endif
>  
>  #include <math.h>
>  #include <assert.h>
> @@ -148,6 +152,24 @@ bool VideoWidget::request( struct vout_window_t
> *p_wnd )
>          case VOUT_WINDOW_TYPE_NSOBJECT:
>              p_wnd->handle.nsobject = (void *)stable->winId();
>              break;
> +#ifdef QT5_HAS_WAYLAND
> +        case VOUT_WINDOW_TYPE_WAYLAND:
> +        {
> +            QWindow *window = stable->windowHandle();
> +            assert(window != NULL);
> +            window->create();
> +
> +            QPlatformNativeInterface *qni =
> qApp->platformNativeInterface();
> +            assert(qni != NULL);
> +
> +            p_wnd->handle.wl = reinterpret_cast<wl_surface*>(
> +               
> qni->nativeResourceForWindow(QByteArrayLiteral("surface"),
> +                                             window));
> +            p_wnd->display.wl = reinterpret_cast<wl_display*>(
> +               
> qni->nativeResourceForIntegration(QByteArrayLiteral("wl_display")));
> +            break;
> +        }
> +#endif
>          default:
>              vlc_assert_unreachable();
>      }
> diff --git a/modules/gui/qt/qt.cpp b/modules/gui/qt/qt.cpp
> index b86b7e507f..4e0bbc8615 100644
> --- a/modules/gui/qt/qt.cpp
> +++ b/modules/gui/qt/qt.cpp
> @@ -605,6 +605,8 @@ static void *ThreadPlatform( void *obj, char
> *platform_name )
>          QString platform = app.platformName();
>          if( platform == qfu("xcb") )
>              p_sys->voutWindowType = VOUT_WINDOW_TYPE_XID;
> +        else if( platform == qfu("wayland") )
> +            p_sys->voutWindowType = VOUT_WINDOW_TYPE_WAYLAND;
>          else if( platform == qfu("windows") )
>              p_sys->voutWindowType = VOUT_WINDOW_TYPE_HWND;
>          else if( platform == qfu("cocoa" ) )
> -- 
> 2.11.0
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


-- 
Jean-Baptiste Kempf -  President
+33 672 704 734


More information about the vlc-devel mailing list