[vlc-commits] Qt: fix multi-screens weirdness caused by the dockable FSC

Ludovic Fauvet git at videolan.org
Thu Dec 15 23:57:23 CET 2011


vlc/vlc-1.2 | branch: master | Ludovic Fauvet <etix at videolan.org> | Thu Dec 15 13:51:37 2011 +0100| [2ea642aca6255691a81dc83688bcba2ac2cd35aa] | committer: Jean-Baptiste Kempf

Qt: fix multi-screens weirdness caused by the dockable FSC

Close #5668

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
(cherry picked from commit 37fef4bd0e709251353f807de9a6901678c5183f)

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

> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.2.git/?a=commit;h=2ea642aca6255691a81dc83688bcba2ac2cd35aa
---

 modules/gui/qt4/components/controller.cpp |   47 +++++++++++++++++++----------
 modules/gui/qt4/components/controller.hpp |    6 ++++
 2 files changed, 37 insertions(+), 16 deletions(-)

diff --git a/modules/gui/qt4/components/controller.cpp b/modules/gui/qt4/components/controller.cpp
index 766b5ee..38c1ebe 100644
--- a/modules/gui/qt4/components/controller.cpp
+++ b/modules/gui/qt4/components/controller.cpp
@@ -723,8 +723,8 @@ FullscreenControllerWidget::FullscreenControllerWidget( intf_thread_t *_p_i, QWi
     vout.clear();
 
     setWindowFlags( Qt::ToolTip );
-    setMinimumWidth( 800 );
-    setMinimumHeight( 72 );
+    setMinimumWidth( FSC_WIDTH );
+    setMinimumHeight( FSC_HEIGHT );
     isWideFSC = false;
 
     setFrameShape( QFrame::StyledPanel );
@@ -771,14 +771,12 @@ FullscreenControllerWidget::FullscreenControllerWidget( intf_thread_t *_p_i, QWi
     if( rect == rect1 && rect.contains( pos1, true ) )
     {
         move( pos1 );
-        i_screennumber = number;
         screenRes = QApplication::desktop()->screenGeometry(number);
     }
     else
     {
         centerFSC( number );
     }
-
 }
 
 FullscreenControllerWidget::~FullscreenControllerWidget()
@@ -800,8 +798,6 @@ void FullscreenControllerWidget::centerFSC( int number )
     QPoint pos = QPoint( screenRes.x() + (screenRes.width() / 2) - (sizeHint().width() / 2),
             screenRes.y() + screenRes.height() - sizeHint().height());
     move( pos );
-
-    i_screennumber = number;
 }
 
 /**
@@ -809,17 +805,25 @@ void FullscreenControllerWidget::centerFSC( int number )
  */
 void FullscreenControllerWidget::showFSC()
 {
-    adjustSize();
-
     int number = QApplication::desktop()->screenNumber( p_intf->p_sys->p_mi );
 
     if( number != i_screennumber ||
         screenRes != QApplication::desktop()->screenGeometry(number) )
     {
-        centerFSC( number );
-        msg_Dbg( p_intf, "Recentering the Fullscreen Controller" );
+        i_screennumber = number;
+        if( !isWideFSC )
+        {
+            centerFSC( number );
+            msg_Dbg( p_intf, "Recentering the Fullscreen Controller" );
+        }
+        else
+        {
+            updateFullwidthGeometry( number );
+        }
     }
 
+    adjustSize();
+
 #if HAVE_TRANSPARENCY
     setWindowOpacity( f_opacity );
 #endif
@@ -882,19 +886,30 @@ void FullscreenControllerWidget::slowHideFSC()
 #endif
 }
 
+void FullscreenControllerWidget::updateFullwidthGeometry( int number )
+{
+    QRect screenGeometry = QApplication::desktop()->screenGeometry( i_screennumber );
+    setMinimumWidth( screenGeometry.width() );
+    setGeometry( screenGeometry.x(), screenGeometry.y() + screenGeometry.height() - FSC_HEIGHT, screenGeometry.width(), FSC_HEIGHT );
+}
+
 void FullscreenControllerWidget::toggleFullwidth() {
-    int fswidth = QApplication::desktop()->screenGeometry( var_InheritInteger( p_intf, "qt-fullscreen-screennumber" ) ).width();
-    int fsheight = QApplication::desktop()->screenGeometry( var_InheritInteger( p_intf, "qt-fullscreen-screennumber" ) ).height();
     if( !isWideFSC ) {
         /* Dock at the bottom of the screen */
-        setMinimumWidth( fswidth );
-        setGeometry(0, fsheight-72, fswidth, 72);
+        updateFullwidthGeometry( i_screennumber );
     } else {
         /* Restore half-bar and re-centre */
-        setMinimumWidth( 600 );
-        setGeometry(fswidth/2 - 300, fsheight-72, 600, 72);
+        setMinimumWidth( FSC_WIDTH );
+        centerFSC( i_screennumber );
     }
 
+    adjustSize();
+
+#ifdef Q_WS_X11
+    // Update the mask to reflect the geometry change
+    setMask( QRegion( 0, 0, width(), height() ) );
+#endif
+
     /* Toggle isWideFSC switch */
     isWideFSC = !isWideFSC;
 }
diff --git a/modules/gui/qt4/components/controller.hpp b/modules/gui/qt4/components/controller.hpp
index 1b796b7..168e8d5 100644
--- a/modules/gui/qt4/components/controller.hpp
+++ b/modules/gui/qt4/components/controller.hpp
@@ -241,6 +241,11 @@ signals:
 /* Default value of opacity for FS controller */
 #define DEFAULT_OPACITY 0.70
 
+/* Used to restore the minimum width after a full-width switch */
+#define FSC_WIDTH 800
+
+#define FSC_HEIGHT 72
+
 /***********************************
  * Fullscreen controller
  ***********************************/
@@ -255,6 +260,7 @@ public:
     void fullscreenChanged( vout_thread_t *, bool b_fs, int i_timeout );
     void mouseChanged( vout_thread_t *, int i_mousex, int i_mousey );
     void toggleFullwidth();
+    void updateFullwidthGeometry( int number );
 
 signals:
     void keyPressed( QKeyEvent * );



More information about the vlc-commits mailing list