[vlc-devel] [PATCH] qt: postpone resize if fullscreen is enabled

Romain Vimont rom1v at videolabs.io
Fri Apr 13 18:37:19 CEST 2018


Starting a video may resize the window (if autoresize is enabled). If
the video is started fullscreen, however, the window is not resized, so
its size is unexpected once fullscreen is disabled.

The initial fullscreen mode should not prevent autoresize, so resize the
window when disabling fullscreen.
---
Notes for reviewers:
 - Use the same steps as those described in comment 3 of #20224 to
   reproduce the issue:
   <https://trac.videolan.org/vlc/ticket/20224#comment:3>.
 - When disabling fullscreen, the window has temporarily its default
   size before it is actually resized (like when starting a video on
   start with "vlc myvideo").
 - Only the resizes requested while fullscreen is enabled are postponed:
   if fullscreen is disabled and isMaximized() or b_isWindowTiled, they
   are still ignored.

 modules/gui/qt/main_interface.cpp | 13 +++++++++++--
 modules/gui/qt/main_interface.hpp |  9 ++++++++-
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/modules/gui/qt/main_interface.cpp b/modules/gui/qt/main_interface.cpp
index e3b76ee228..b5a5724f18 100644
--- a/modules/gui/qt/main_interface.cpp
+++ b/modules/gui/qt/main_interface.cpp
@@ -915,9 +915,18 @@ void MainInterface::setVideoFullScreen( bool fs )
         if( lastWinPosition.isNull() == false )
         {
             move( lastWinPosition );
-            resizeWindow( lastWinSize.width(), lastWinSize.height() );
             lastWinPosition = QPoint();
-            lastWinSize = QSize();
+            if( !pendingResize.isValid() )
+            {
+                resizeWindow( lastWinSize.width(), lastWinSize.height() );
+                lastWinSize = QSize();
+            }
+        }
+        if( pendingResize.isValid() )
+        {
+            /* apply resize requested while fullscreen was enabled */
+            resizeStack( pendingResize.width(), pendingResize.height() );
+            pendingResize = QSize(); // consume
         }
 
     }
diff --git a/modules/gui/qt/main_interface.hpp b/modules/gui/qt/main_interface.hpp
index 5f60d2f307..2fcf2d36e7 100644
--- a/modules/gui/qt/main_interface.hpp
+++ b/modules/gui/qt/main_interface.hpp
@@ -170,6 +170,8 @@ protected:
     QSize               lastWinSize;  /// To restore the same window size when leaving fullscreen
     QScreen             *lastWinScreen;
 
+    QSize               pendingResize; // to be applied when fullscreen is disabled
+
     QMap<QWidget *, QSize> stackWidgetsSizes;
 
     /* Flags */
@@ -240,7 +242,12 @@ protected slots:
 
     void resizeStack( int w, int h )
     {
-        if( !isFullScreen() && !isMaximized() && !b_isWindowTiled )
+        if( isFullScreen() )
+        {
+            /* postpone resize, will be applied once fullscreen is disabled */
+            pendingResize = QSize( w, h );
+        }
+        else if( !isMaximized() && !b_isWindowTiled )
         {
             if( b_minimalView )
                 resizeWindow( w, h ); /* Oh yes, it shouldn't
-- 
2.17.0



More information about the vlc-devel mailing list