[vlc-devel] commit: Improved fullscreen controller. (Laurent Aimar )

git version control git at videolan.org
Mon Jan 5 21:26:46 CET 2009


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Sat Dec 27 16:51:25 2008 +0100| [d13d44712b33cfb41ec1a24ec9b0a20a59c73ad1] | committer: Laurent Aimar 

Improved fullscreen controller.

It now works in non embed mode.
It follows multiple vouts (not perfect yet).

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

 modules/gui/qt4/components/controller.cpp |  144 +++++++++++++++++------------
 modules/gui/qt4/components/controller.hpp |   13 ++-
 modules/gui/qt4/main_interface.cpp        |    3 -
 3 files changed, 91 insertions(+), 69 deletions(-)

diff --git a/modules/gui/qt4/components/controller.cpp b/modules/gui/qt4/components/controller.cpp
index fd62a97..054256c 100644
--- a/modules/gui/qt4/components/controller.cpp
+++ b/modules/gui/qt4/components/controller.cpp
@@ -798,9 +798,10 @@ FullscreenControllerWidget::FullscreenControllerWidget( intf_thread_t *_p_i )
 #endif
     b_fullscreen        = false;
     i_hide_timeout      = 1;
-    p_vout              = NULL;
     i_screennumber      = -1;
 
+    vout.clear();
+
     setWindowFlags( Qt::ToolTip );
     setMinimumWidth( 600 );
 
@@ -854,12 +855,14 @@ FullscreenControllerWidget::FullscreenControllerWidget( intf_thread_t *_p_i )
 #endif
 
     vlc_mutex_init_recursive( &lock );
+
+    CONNECT( THEMIM->getIM(), voutListChanged( vout_thread_t **, int ), this, setVoutList( vout_thread_t **, int ) );
 }
 
 FullscreenControllerWidget::~FullscreenControllerWidget()
 {
     getSettings()->setValue( "FullScreen/pos", pos() );
-    detachVout();
+    setVoutList( NULL, 0 );
     vlc_mutex_destroy( &lock );
 }
 
@@ -1091,11 +1094,11 @@ static int FullscreenControllerWidgetFullscreenChanged( vlc_object_t *vlc_object
                 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;
 }
@@ -1104,92 +1107,81 @@ static int FullscreenControllerWidgetMouseMoved( vlc_object_t *vlc_object, const
                                                  vlc_value_t old_val, vlc_value_t new_val,
                                                  void *data )
 {
+    vout_thread_t *p_vout = (vout_thread_t *)vlc_object;
     FullscreenControllerWidget *p_fs = (FullscreenControllerWidget *)data;
 
-    int i_mousex, i_mousey;
-    bool b_toShow = false;
-
     /* 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" );
+    const int i_mousex = var_GetInteger( p_vout, "mouse-x" );
+    const int i_mousey = var_GetInteger( 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) );
-    }
+    p_fs->mouseChanged( p_vout, i_mousex, i_mousey );
 
     return VLC_SUCCESS;
 }
 
 /**
- * It is called when video start
+ * It is call to update the list of vout handled by the fullscreen controller
  */
-void FullscreenControllerWidget::attachVout( vout_thread_t *p_nvout )
+void FullscreenControllerWidget::setVoutList( vout_thread_t **pp_vout, int i_vout )
 {
-    assert( p_nvout && !p_vout );
+    QList<vout_thread_t*> del;
+    QList<vout_thread_t*> add;
 
-    p_vout = p_nvout;
+    QList<vout_thread_t*> set;
 
-    msg_Dbg( p_vout, "Qt FS: Attaching Vout" );
-    vlc_mutex_lock( &lock );
+    /* */
+    for( int i = 0; i < i_vout; i++ )
+        set += pp_vout[i];
 
-    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" ) );
+    /* Vout to remove */
+    vlc_mutex_lock( &lock );
+    foreach( vout_thread_t *p_vout, vout )
+    {
+        if( !set.contains( p_vout ) )
+            del += p_vout;
+    }
     vlc_mutex_unlock( &lock );
-}
 
-/**
- * It is called after turn off video.
- */
-void FullscreenControllerWidget::detachVout()
-{
-    if( p_vout )
+    foreach( vout_thread_t *p_vout, del )
     {
-        msg_Dbg( p_vout, "Qt FS: Detaching Vout" );
         var_DelCallback( p_vout, "fullscreen",
-                FullscreenControllerWidgetFullscreenChanged, this );
+                         FullscreenControllerWidgetFullscreenChanged, this );
         vlc_mutex_lock( &lock );
         fullscreenChanged( p_vout, false, 0 );
+        vout.removeAll( p_vout );
         vlc_mutex_unlock( &lock );
-        p_vout = NULL;
     }
-}
 
+    /* Vout to track */
+    vlc_mutex_lock( &lock );
+    foreach( vout_thread_t *p_vout, set )
+    {
+        if( !vout.contains( p_vout ) )
+            add += p_vout;
+    }
+    vlc_mutex_unlock( &lock );
+
+    foreach( vout_thread_t *p_vout, add )
+    {
+        vlc_object_hold( (vlc_object_t*)p_vout );
+
+        vlc_mutex_lock( &lock );
+        vout.append( p_vout );
+        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 );
+    }
+}
 /**
  * Register and unregister callback for mouse moving
  */
 void FullscreenControllerWidget::fullscreenChanged( vout_thread_t *p_vout,
         bool b_fs, int i_timeout )
 {
+    /* FIXME - multiple vout (ie multiple mouse position ?) and thread safety if multiple vout ? */
     msg_Dbg( p_vout, "Qt: Entering Fullscreen" );
 
     vlc_mutex_lock( &lock );
@@ -1215,4 +1207,34 @@ void FullscreenControllerWidget::fullscreenChanged( vout_thread_t *p_vout,
     }
     vlc_mutex_unlock( &lock );
 }
+/**
+ * Mouse change callback (show/hide the controller on mouse movement)
+ */
+void FullscreenControllerWidget::mouseChanged( vout_thread_t *p_vout, int i_mousex, int i_mousey )
+{
+    bool b_toShow;
+
+    /* FIXME - multiple vout (ie multiple mouse position ?) and thread safety if multiple vout ? */
+
+    b_toShow = false;
+    if( ( i_mouse_last_move_x == -1 || i_mouse_last_move_y == -1 ) ||
+        ( abs( i_mouse_last_move_x - i_mousex ) > 2 ||
+          abs( i_mouse_last_move_y - i_mousey ) > 2 ) )
+    {
+        i_mouse_last_move_x = i_mousex;
+        i_mouse_last_move_y = i_mousey;
+        b_toShow = true;
+    }
+
+    if( b_toShow )
+    {
+        /* Show event */
+        IMEvent *eShow = new IMEvent( FullscreenControlShow_Type, 0 );
+        QApplication::postEvent( this, static_cast<QEvent *>(eShow) );
+
+        /* Plan hide event */
+        IMEvent *eHide = new IMEvent( FullscreenControlPlanHide_Type, 0 );
+        QApplication::postEvent( this, static_cast<QEvent *>(eHide) );
+    }
+}
 
diff --git a/modules/gui/qt4/components/controller.hpp b/modules/gui/qt4/components/controller.hpp
index 61b8ede..2726de8 100644
--- a/modules/gui/qt4/components/controller.hpp
+++ b/modules/gui/qt4/components/controller.hpp
@@ -257,13 +257,11 @@ public:
     virtual ~FullscreenControllerWidget();
 
     /* Vout */
-    vout_thread_t *p_vout;
-    void attachVout( vout_thread_t *p_vout );
-    void detachVout();
     void fullscreenChanged( vout_thread_t *, bool b_fs, int i_timeout );
+    void mouseChanged( vout_thread_t *, int i_mousex, int i_mousey );
 
-    int i_mouse_last_move_x;
-    int i_mouse_last_move_y;
+public slots:
+    void setVoutList( vout_thread_t **, int );
 
 protected:
     friend class MainInterface;
@@ -298,10 +296,15 @@ private:
     bool b_fscHidden;
 #endif
 
+    /* List of vouts currently tracked */
+    QList<vout_thread_t *> vout;
+
     /* Shared variable between FSC and VLC (protected by a lock) */
     vlc_mutex_t lock;
     bool        b_fullscreen;
     int         i_hide_timeout;  /* FSC hiding timeout, same as mouse hiding timeout */
+    int i_mouse_last_move_x;
+    int i_mouse_last_move_y;
 };
 
 #endif
diff --git a/modules/gui/qt4/main_interface.cpp b/modules/gui/qt4/main_interface.cpp
index 5d96090..dc55bc5 100644
--- a/modules/gui/qt4/main_interface.cpp
+++ b/modules/gui/qt4/main_interface.cpp
@@ -609,8 +609,6 @@ void *MainInterface::requestVideo( vout_thread_t *p_nvout, int *pi_x,
         videoIsActive = true;
 
         emit askUpdate();
-
-        if( fullscreenControls ) fullscreenControls->attachVout( p_nvout );
     }
     return ret;
 }
@@ -618,7 +616,6 @@ void *MainInterface::requestVideo( vout_thread_t *p_nvout, int *pi_x,
 /* Call from the WindowClose function */
 void MainInterface::releaseVideo( void )
 {
-    if( fullscreenControls ) fullscreenControls->detachVout();
     emit askReleaseVideo( );
 }
 




More information about the vlc-devel mailing list