[vlc-commits] qt: check if QDesktopWidget::screenNumber() returns a valid screen

Pierre Lamot git at videolan.org
Sun Dec 17 23:22:13 CET 2017


vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Thu Dec 14 13:39:55 2017 +0100| [117658e75806a47ed7e333818c259a6c0f71bb9f] | committer: Jean-Baptiste Kempf

qt: check if QDesktopWidget::screenNumber() returns a valid screen

screenNumber might fail on wayland.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=117658e75806a47ed7e333818c259a6c0f71bb9f
---

 modules/gui/qt/components/controller.cpp |  3 +++
 modules/gui/qt/main_interface.cpp        | 33 ++++++++++++++++++--------------
 2 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/modules/gui/qt/components/controller.cpp b/modules/gui/qt/components/controller.cpp
index c8ed2825e9..428aa216a1 100644
--- a/modules/gui/qt/components/controller.cpp
+++ b/modules/gui/qt/components/controller.cpp
@@ -869,6 +869,9 @@ void FullscreenControllerWidget::restoreFSC()
         setMinimumWidth( FSC_WIDTH );
         adjustSize();
 
+        if ( targetScreen() < 0 )
+            return;
+
         QRect currentRes = QApplication::desktop()->screenGeometry( targetScreen() );
         windowHandle()->setScreen(QGuiApplication::screens()[targetScreen()]);
 
diff --git a/modules/gui/qt/main_interface.cpp b/modules/gui/qt/main_interface.cpp
index 525d71722d..8763d21fc2 100644
--- a/modules/gui/qt/main_interface.cpp
+++ b/modules/gui/qt/main_interface.cpp
@@ -866,23 +866,28 @@ void MainInterface::setVideoFullScreen( bool fs )
             numscreen = QApplication::desktop()->screenNumber( p_intf->p_sys->p_mi );
 
         fullscreenControls->setTargetScreen( numscreen );
-        QRect screenres = QApplication::desktop()->screenGeometry( numscreen );
-        lastWinScreen = windowHandle()->screen();
-        windowHandle()->setScreen(QGuiApplication::screens()[numscreen]);
 
-        /* To be sure window is on proper-screen in xinerama */
-        if( !screenres.contains( pos() ) )
+        if ( numscreen >= 0 )
         {
-            lastWinPosition = pos();
-            lastWinSize = size();
-            msg_Dbg( p_intf, "Moving video to correct position");
-            move( QPoint( screenres.x(), screenres.y() ) );
-        }
 
-        /* */
-        if( playlistWidget != NULL && playlistWidget->artContainer->currentWidget() == videoWidget )
-        {
-            showTab( videoWidget );
+            QRect screenres = QApplication::desktop()->screenGeometry( numscreen );
+            lastWinScreen = windowHandle()->screen();
+            windowHandle()->setScreen(QGuiApplication::screens()[numscreen]);
+
+            /* To be sure window is on proper-screen in xinerama */
+            if( !screenres.contains( pos() ) )
+            {
+                lastWinPosition = pos();
+                lastWinSize = size();
+                msg_Dbg( p_intf, "Moving video to correct position");
+                move( QPoint( screenres.x(), screenres.y() ) );
+            }
+
+            /* */
+            if( playlistWidget != NULL && playlistWidget->artContainer->currentWidget() == videoWidget )
+            {
+                showTab( videoWidget );
+            }
         }
 
         /* */



More information about the vlc-commits mailing list