[vlc-devel] [PATCH 3/3] qt: fix setScreen might crash on wayland when entering fullscreen

Pierre Lamot pierre at videolabs.io
Thu Dec 14 13:39:56 CET 2017


---
 modules/gui/qt/components/controller.cpp | 10 ++++++++++
 modules/gui/qt/main_interface.cpp        | 15 +++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/modules/gui/qt/components/controller.cpp b/modules/gui/qt/components/controller.cpp
index 428aa216a1..08c8523ab5 100644
--- a/modules/gui/qt/components/controller.cpp
+++ b/modules/gui/qt/components/controller.cpp
@@ -863,6 +863,11 @@ FullscreenControllerWidget::~FullscreenControllerWidget()
 
 void FullscreenControllerWidget::restoreFSC()
 {
+#ifdef QT5_HAS_WAYLAND
+   static bool b_hasWayland = QGuiApplication::platformName()
+           .startsWith(QLatin1String("wayland"), Qt::CaseInsensitive);
+#endif
+
     if( !isWideFSC )
     {
         /* Restore half-bar and re-centre if needed */
@@ -873,7 +878,12 @@ void FullscreenControllerWidget::restoreFSC()
             return;
 
         QRect currentRes = QApplication::desktop()->screenGeometry( targetScreen() );
+#ifdef QT5_HAS_WAYLAND
+        if ( !b_hasWayland )
+            windowHandle()->setScreen(QGuiApplication::screens()[targetScreen()]);
+#else
         windowHandle()->setScreen(QGuiApplication::screens()[targetScreen()]);
+#endif
 
         if( currentRes == screenRes &&
             QApplication::desktop()->screen()->geometry().contains( previousPosition, true ) )
diff --git a/modules/gui/qt/main_interface.cpp b/modules/gui/qt/main_interface.cpp
index 8763d21fc2..73d9973439 100644
--- a/modules/gui/qt/main_interface.cpp
+++ b/modules/gui/qt/main_interface.cpp
@@ -854,6 +854,11 @@ void MainInterface::videoSizeChanged( int w, int h )
 
 void MainInterface::setVideoFullScreen( bool fs )
 {
+#ifdef QT5_HAS_WAYLAND
+   static bool b_hasWayland = QGuiApplication::platformName()
+           .startsWith(QLatin1String("wayland"), Qt::CaseInsensitive);
+#endif
+
     b_videoFullScreen = fs;
     if( fs )
     {
@@ -872,7 +877,12 @@ void MainInterface::setVideoFullScreen( bool fs )
 
             QRect screenres = QApplication::desktop()->screenGeometry( numscreen );
             lastWinScreen = windowHandle()->screen();
+#ifdef QT5_HAS_WAYLAND
+            if ( !b_hasWayland )
+                windowHandle()->setScreen(QGuiApplication::screens()[numscreen]);
+#else
             windowHandle()->setScreen(QGuiApplication::screens()[numscreen]);
+#endif
 
             /* To be sure window is on proper-screen in xinerama */
             if( !screenres.contains( pos() ) )
@@ -898,8 +908,13 @@ void MainInterface::setVideoFullScreen( bool fs )
     {
         setMinimalView( b_minimalView );
         setInterfaceFullScreen( b_interfaceFullScreen );
+#ifdef QT5_HAS_WAYLAND
+        if ( lastWinScreen != NULL && !b_hasWayland )
+            windowHandle()->setScreen(lastWinScreen);
+#else
         if (lastWinScreen != NULL)
             windowHandle()->setScreen(lastWinScreen);
+#endif
         if( lastWinPosition.isNull() == false )
         {
             move( lastWinPosition );
-- 
2.14.1



More information about the vlc-devel mailing list