[vlc-devel] [PATCH 2/3] qt: check if QDesktopWidget::screenNumber() returns a valid screen
Pierre Lamot
pierre at videolabs.io
Thu Dec 14 13:39:55 CET 2017
screenNumber might fail on wayland.
---
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 );
+ }
}
/* */
--
2.14.1
More information about the vlc-devel
mailing list