[vlc-devel] [PATCH] Qt: fix the qt-fullscreen-screennumber option

Adrien Maglo magsoft at videolan.org
Tue Nov 21 14:02:37 CET 2017


numScreens() is deprecated.
To set the window fullscreen on the defined monitor, a call to setScreen()
is needed.
---
 modules/gui/qt/components/controller.cpp | 4 +++-
 modules/gui/qt/main_interface.cpp        | 9 ++++++++-
 modules/gui/qt/main_interface.hpp        | 2 ++
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/modules/gui/qt/components/controller.cpp b/modules/gui/qt/components/controller.cpp
index 98c2754e2f..588dfaeecc 100644
--- a/modules/gui/qt/components/controller.cpp
+++ b/modules/gui/qt/components/controller.cpp
@@ -50,6 +50,7 @@
 #include <QSignalMapper>
 #include <QTimer>
 #include <QApplication>
+#include <QWindow>
 #include <QScreen>
 
 //#define DEBUG_LAYOUT 1
@@ -869,6 +870,7 @@ void FullscreenControllerWidget::restoreFSC()
         adjustSize();
 
         QRect currentRes = QApplication::desktop()->screenGeometry( targetScreen() );
+        windowHandle()->setScreen(QGuiApplication::screens()[targetScreen()]);
 
         if( currentRes == screenRes &&
             QApplication::desktop()->screen()->geometry().contains( previousPosition, true ) )
@@ -984,7 +986,7 @@ void FullscreenControllerWidget::toggleFullwidth()
 
 int FullscreenControllerWidget::targetScreen()
 {
-    if( i_screennumber < 0 || i_screennumber > QApplication::desktop()->numScreens() )
+    if( i_screennumber < 0 || i_screennumber > QApplication::desktop()->screenCount() )
         return QApplication::desktop()->screenNumber( p_intf->p_sys->p_mi );
     return i_screennumber;
 }
diff --git a/modules/gui/qt/main_interface.cpp b/modules/gui/qt/main_interface.cpp
index fc49683777..1d521fe242 100644
--- a/modules/gui/qt/main_interface.cpp
+++ b/modules/gui/qt/main_interface.cpp
@@ -54,11 +54,13 @@
 #include <QDate>
 #include <QMimeData>
 
+#include <QWindow>
 #include <QMenu>
 #include <QMenuBar>
 #include <QStatusBar>
 #include <QLabel>
 #include <QStackedWidget>
+#include <QScreen>
 #ifdef _WIN32
 #include <QFileInfo>
 #endif
@@ -96,6 +98,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     videoWidget          = NULL;
     playlistWidget       = NULL;
     stackCentralOldWidget= NULL;
+    lastWinScreen        = NULL;
     sysTray              = NULL;
     fullscreenControls   = NULL;
     cryptedLabel         = NULL;
@@ -857,10 +860,12 @@ void MainInterface::setVideoFullScreen( bool fs )
          * than current number of screens, take screennumber where current interface
          * is
          */
-        if( numscreen == -1 || numscreen > QApplication::desktop()->numScreens() )
+        if( numscreen == -1 || numscreen > QApplication::desktop()->screenCount() )
             numscreen = QApplication::desktop()->screenNumber( p_intf->p_sys->p_mi );
 
         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() ) )
@@ -885,6 +890,8 @@ void MainInterface::setVideoFullScreen( bool fs )
     {
         setMinimalView( b_minimalView );
         setInterfaceFullScreen( b_interfaceFullScreen );
+        if (lastWinScreen != NULL)
+            windowHandle()->setScreen(lastWinScreen);
         if( lastWinPosition.isNull() == false )
         {
             move( lastWinPosition );
diff --git a/modules/gui/qt/main_interface.hpp b/modules/gui/qt/main_interface.hpp
index fe8a4b61f0..8977bd4007 100644
--- a/modules/gui/qt/main_interface.hpp
+++ b/modules/gui/qt/main_interface.hpp
@@ -51,6 +51,7 @@ class FullscreenControllerWidget;
 class QVBoxLayout;
 class QMenu;
 class QSize;
+class QScreen;
 class QTimer;
 class StandardPLPanel;
 struct vout_window_t;
@@ -166,6 +167,7 @@ protected:
     QWidget             *stackCentralOldWidget;
     QPoint              lastWinPosition;
     QSize               lastWinSize;  /// To restore the same window size when leaving fullscreen
+    QScreen             *lastWinScreen;
 
     QMap<QWidget *, QSize> stackWidgetsSizes;
 
-- 
2.14.1



More information about the vlc-devel mailing list