[vlc-devel] [PATCH 3/3] qt: fix setScreen might crash on wayland when entering fullscreen
Hugo Beauzée-Luyssen
hugo at beauzee.fr
Thu Dec 14 14:14:23 CET 2017
On Thu, Dec 14, 2017, at 01:45 PM, Rémi Denis-Courmont wrote:
> Le 14 décembre 2017 14:39:56 GMT+02:00, Pierre Lamot
> <pierre at videolabs.io> a écrit :
> >---
> > 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
> >
> >_______________________________________________
> >vlc-devel mailing list
> >To unsubscribe or modify your subscription options:
> >https://mailman.videolan.org/listinfo/vlc-devel
>
> Is it safe to initialize a static with non-constant expression, which is
> not even defined at load time?
> --
> Remi Denis-Courmont
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
If you mean "thread-safe", then yes starting from C++11
--
Hugo Beauzée-Luyssen
hugo at beauzee.fr
More information about the vlc-devel
mailing list