[vlc-devel] commit: Qt4: Fix windows FSC issue. (Jean-Baptiste Kempf )

git version control git at videolan.org
Sun Sep 21 04:01:37 CEST 2008


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Sat Sep 20 14:53:44 2008 -0700| [5bea8b37184568c5bb5effa5b540be6532fcac34] | committer: Jean-Baptiste Kempf 

Qt4: Fix windows FSC issue.

PFff :D
(cherry picked from commit 65c2a9bf053f82e4a84192f530f042209a449cca)
(cherry picked from commit 834bd87073e19b49dca9d1ea608541e5885fb3cf)
(cherry picked from commit 6a02accb4ca190a3e2b2690f2130ac6a09d78a32)

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

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5bea8b37184568c5bb5effa5b540be6532fcac34
---

 modules/gui/qt4/components/interface_widgets.cpp |   94 ++++++++++++++++------
 modules/gui/qt4/components/interface_widgets.hpp |    5 +-
 2 files changed, 74 insertions(+), 25 deletions(-)

diff --git a/modules/gui/qt4/components/interface_widgets.cpp b/modules/gui/qt4/components/interface_widgets.cpp
index c1de421..1b01687 100644
--- a/modules/gui/qt4/components/interface_widgets.cpp
+++ b/modules/gui/qt4/components/interface_widgets.cpp
@@ -1008,6 +1008,9 @@ FullscreenControllerWidget::FullscreenControllerWidget( intf_thread_t *_p_i,
           b_slow_hide_begin(false), i_slow_hide_timeout(1),
           b_fullscreen( false ), i_hide_timeout( 1 ), p_vout(NULL)
 {
+    i_mouse_last_move_x = -1;
+    i_mouse_last_move_y = -1;
+
     setWindowFlags( Qt::ToolTip );
 
     setFrameShape( QFrame::StyledPanel );
@@ -1080,7 +1083,6 @@ void FullscreenControllerWidget::showFSC()
 {
     adjustSize();
 #ifdef WIN32TRICK
-    msg_Dbg( p_intf, "showFSC() was called" );
     // after quiting and going to fs, we need to call show()
     if( isHidden() )
         show();
@@ -1107,7 +1109,6 @@ void FullscreenControllerWidget::showFSC()
 void FullscreenControllerWidget::hideFSC()
 {
 #ifdef WIN32TRICK
-    msg_Dbg( p_intf, "hideFSC() was called" );
     b_fscHidden = true;
     setWindowOpacity( 0.0 );    // simulate hidding
 #else
@@ -1153,7 +1154,6 @@ void FullscreenControllerWidget::slowHideFSC()
     else
     {
 #ifdef WIN32TRICK
-        msg_Dbg( p_intf, "slowHideFSC() was called" );
          if ( windowOpacity() > 0.0 && !b_fscHidden )
 #else
          if ( windowOpacity() > 0.0 )
@@ -1178,10 +1178,6 @@ void FullscreenControllerWidget::customEvent( QEvent *event )
 {
     bool b_fs;
 
-#ifndef NDEBUG
-    msg_Dbg( p_intf, "New FSC event: %i", event->type() );
-#endif
-
     switch( event->type() )
     {
         case FullscreenControlToggle_Type:
@@ -1206,7 +1202,11 @@ void FullscreenControllerWidget::customEvent( QEvent *event )
             b_fs = b_fullscreen;
             vlc_mutex_unlock( &lock );
 
-            if( b_fs )  // FIXME I am not sure about that one
+#ifdef WIN32TRICK
+            if( b_fs && b_fscHidden )  // FIXME I am not sure about that one
+#else
+            if( b_fs && !isVisible() )  // FIXME I am not sure about that one
+#endif
                 showFSC();
             break;
         case FullscreenControlHide_Type:
@@ -1288,14 +1288,16 @@ void FullscreenControllerWidget::keyPressEvent( QKeyEvent *event )
 }
 
 /* */
-static int FullscreenControllerWidgetFullscreenChanged( vlc_object_t *vlc_object, const char *variable,
-                                                        vlc_value_t old_val, vlc_value_t new_val,
-                                                        void *data )
+static int FullscreenControllerWidgetFullscreenChanged( vlc_object_t *vlc_object,
+                const char *variable, vlc_value_t old_val,
+                vlc_value_t new_val,  void *data )
 {
     vout_thread_t *p_vout = (vout_thread_t *) vlc_object;
+    msg_Dbg( p_vout, "Qt4: Fullscreen state changed" );
     FullscreenControllerWidget *p_fs = (FullscreenControllerWidget *)data;
 
-    p_fs->fullscreenChanged( p_vout, new_val.b_bool, var_GetInteger( p_vout, "mouse-hide-timeout" ) );
+    p_fs->fullscreenChanged( p_vout, new_val.b_bool,
+            var_GetInteger( p_vout, "mouse-hide-timeout" ) );
 
     return VLC_SUCCESS;
 }
@@ -1306,13 +1308,43 @@ static int FullscreenControllerWidgetMouseMoved( vlc_object_t *vlc_object, const
 {
     FullscreenControllerWidget *p_fs = (FullscreenControllerWidget *)data;
 
-    /* Show event */
-    IMEvent *eShow = new IMEvent( FullscreenControlShow_Type, 0 );
-    QApplication::postEvent( p_fs, static_cast<QEvent *>(eShow) );
+    int i_mousex, i_mousey;
+    bool b_toShow = false;
 
-    /* Plan hide event */
-    IMEvent *eHide = new IMEvent( FullscreenControlPlanHide_Type, 0 );
-    QApplication::postEvent( p_fs, static_cast<QEvent *>(eHide) );
+    /* Get the value from the Vout - Trust the vout more than Qt */
+    i_mousex = var_GetInteger( p_fs->p_vout, "mouse-x" );
+    i_mousey = var_GetInteger( p_fs->p_vout, "mouse-y" );
+
+    /* First time */
+    if( p_fs->i_mouse_last_move_x == -1 || p_fs->i_mouse_last_move_y == -1 )
+    {
+        p_fs->i_mouse_last_move_x = i_mousex;
+        p_fs->i_mouse_last_move_y = i_mousey;
+        b_toShow = true;
+    }
+    /* All other times */
+    else
+    {
+        /* Trigger only if move > 3 px dans une direction */
+        if( abs( p_fs->i_mouse_last_move_x - i_mousex ) > 2 ||
+            abs( p_fs->i_mouse_last_move_y - i_mousey ) > 2 )
+        {
+            b_toShow = true;
+            p_fs->i_mouse_last_move_x = i_mousex;
+            p_fs->i_mouse_last_move_y = i_mousey;
+        }
+    }
+
+    if( b_toShow )
+    {
+        /* Show event */
+        IMEvent *eShow = new IMEvent( FullscreenControlShow_Type, 0 );
+        QApplication::postEvent( p_fs, static_cast<QEvent *>(eShow) );
+
+        /* Plan hide event */
+        IMEvent *eHide = new IMEvent( FullscreenControlPlanHide_Type, 0 );
+        QApplication::postEvent( p_fs, static_cast<QEvent *>(eHide) );
+    }
 
     return VLC_SUCCESS;
 }
@@ -1327,9 +1359,14 @@ void FullscreenControllerWidget::attachVout( vout_thread_t *p_nvout )
 
     p_vout = p_nvout;
 
+    msg_Dbg( p_vout, "Qt FS: Attaching Vout" );
     vlc_mutex_lock( &lock );
-    var_AddCallback( p_vout, "fullscreen", FullscreenControllerWidgetFullscreenChanged, this ); /* I miss a add and fire */
-    fullscreenChanged( p_vout, var_GetBool( p_vout, "fullscreen" ), var_GetInteger( p_vout, "mouse-hide-timeout" ) );
+
+    var_AddCallback( p_vout, "fullscreen",
+            FullscreenControllerWidgetFullscreenChanged, this );
+            /* I miss a add and fire */
+    fullscreenChanged( p_vout, var_GetBool( p_vout, "fullscreen" ),
+                       var_GetInteger( p_vout, "mouse-hide-timeout" ) );
     vlc_mutex_unlock( &lock );
 }
 /**
@@ -1339,7 +1376,9 @@ void FullscreenControllerWidget::detachVout()
 {
     if( p_vout )
     {
-        var_DelCallback( p_vout, "fullscreen", FullscreenControllerWidgetFullscreenChanged, this );
+        msg_Dbg( p_vout, "Qt FS: Detaching Vout" );
+        var_DelCallback( p_vout, "fullscreen",
+                FullscreenControllerWidgetFullscreenChanged, this );
         vlc_mutex_lock( &lock );
         fullscreenChanged( p_vout, false, 0 );
         vlc_mutex_unlock( &lock );
@@ -1350,20 +1389,27 @@ void FullscreenControllerWidget::detachVout()
 /**
  * Register and unregister callback for mouse moving
  */
-void FullscreenControllerWidget::fullscreenChanged( vout_thread_t *p_vout, bool b_fs, int i_timeout )
+void FullscreenControllerWidget::fullscreenChanged( vout_thread_t *p_vout,
+        bool b_fs, int i_timeout )
 {
+    msg_Dbg( p_vout, "Qt: Entering Fullscreen" );
+
     vlc_mutex_lock( &lock );
+    /* Entering fullscreen, register callback */
     if( b_fs && !b_fullscreen )
     {
         b_fullscreen = true;
         i_hide_timeout = i_timeout;
-        var_AddCallback( p_vout, "mouse-moved", FullscreenControllerWidgetMouseMoved, this );
+        var_AddCallback( p_vout, "mouse-moved",
+                FullscreenControllerWidgetMouseMoved, this );
     }
+    /* Quitting fullscreen, unregistering callback */
     else if( !b_fs && b_fullscreen )
     {
         b_fullscreen = false;
         i_hide_timeout = i_timeout;
-        var_DelCallback( p_vout, "mouse-moved", FullscreenControllerWidgetMouseMoved, this );
+        var_DelCallback( p_vout, "mouse-moved",
+                FullscreenControllerWidgetMouseMoved, this );
 
         /* Force fs hidding */
         IMEvent *eHide = new IMEvent( FullscreenControlHide_Type, 0 );
diff --git a/modules/gui/qt4/components/interface_widgets.hpp b/modules/gui/qt4/components/interface_widgets.hpp
index b4fd1f7..1415e4d 100644
--- a/modules/gui/qt4/components/interface_widgets.hpp
+++ b/modules/gui/qt4/components/interface_widgets.hpp
@@ -252,6 +252,10 @@ public:
     void attachVout( vout_thread_t *p_vout );
     void detachVout();
     void fullscreenChanged( vout_thread_t *, bool b_fs, int i_timeout );
+    vout_thread_t *p_vout;
+
+    int i_mouse_last_move_x;
+    int i_mouse_last_move_y;
 
 protected:
     friend class MainInterface;
@@ -291,7 +295,6 @@ private:
 
     virtual void customEvent( QEvent *event );
 
-    vout_thread_t *p_vout;
 
     /* Shared variable between FSC and VLC (protected by a lock) */
     vlc_mutex_t lock;




More information about the vlc-devel mailing list