]> git.sesse.net Git - vlc/commitdiff
skins2: fix video not properly tied to the right video control
authorErwan Tulou <erwan10@videolan.org>
Mon, 1 Apr 2013 20:33:23 +0000 (22:33 +0200)
committerErwan Tulou <erwan10@videolan.org>
Mon, 1 Apr 2013 21:40:36 +0000 (23:40 +0200)
Certain skins like wmp12 may fail to deal with video controls in some
corner cases. For this skin, no window was set visible and the skin
engine eventually fell back to force the first window to become visible.

This patch is expected to fix trac #8368 (need to be tested on windows)

modules/gui/skins2/controls/ctrl_video.cpp
modules/gui/skins2/controls/ctrl_video.hpp
modules/gui/skins2/src/generic_layout.hpp
modules/gui/skins2/src/vout_manager.cpp

index 2ed026bdee14a3055fe3a546d56e209c02564d91..7c9dcae8e3136e86e195f3a9f9bfccf9a8e31a89 100644 (file)
@@ -36,8 +36,8 @@ CtrlVideo::CtrlVideo( intf_thread_t *pIntf, GenericLayout &rLayout,
                       bool autoResize, const UString &rHelp,
                       VarBool *pVisible ):
     CtrlGeneric( pIntf, rHelp, pVisible ), m_rLayout( rLayout ),
-    m_bAutoResize( autoResize), m_xShift( 0 ), m_yShift( 0 ),
-    m_bIsUseable( false), m_pVoutWindow( NULL )
+    m_bAutoResize( autoResize ), m_xShift( 0 ), m_yShift( 0 ),
+    m_pVoutWindow( NULL )
 {
     VarBool &rFullscreen = VlcProc::instance( getIntf() )->getFullscreenVar();
     rFullscreen.addObserver( this );
@@ -114,13 +114,11 @@ void CtrlVideo::setLayout( GenericLayout *pLayout,
     CtrlGeneric::setLayout( pLayout, rPosition );
     m_pLayout->getActiveVar().addObserver( this );
 
-    m_bIsUseable = isVisible() && m_pLayout->getActiveVar().get();
-
     // register Video Control
     VoutManager::instance( getIntf() )->registerCtrlVideo( this );
 
     msg_Dbg( getIntf(),"New VideoControl detected(%p), useability=%s",
-                           this, m_bIsUseable ? "true" : "false" );
+                           this, isUseable() ? "true" : "false" );
 }
 
 
@@ -187,15 +185,11 @@ void CtrlVideo::onUpdate( Subject<VarBool> &rVariable, void *arg  )
                       rFullscreen.get() );
     }
 
-    m_bIsUseable = isVisible() &&
-                   m_pLayout->getActiveVar().get() &&
-                   !rFullscreen.get();
-
-    if( m_bIsUseable && !isUsed() )
+    if( isUseable() && !isUsed() )
     {
         VoutManager::instance( getIntf() )->requestVout( this );
     }
-    else if( !m_bIsUseable && isUsed() )
+    else if( !isUseable() && isUsed() )
     {
         VoutManager::instance( getIntf() )->discardVout( this );
     }
@@ -233,3 +227,18 @@ void CtrlVideo::detachVoutWindow( )
     m_pVoutWindow = NULL;
 }
 
+
+bool CtrlVideo::isUseable( ) const
+{
+    VarBool &rFullscreen = VlcProc::instance( getIntf() )->getFullscreenVar();
+
+    return isVisible() &&                 // video control is visible
+           m_pLayout->isVisible() &&      // layout is visible
+           !rFullscreen.get();            // fullscreen is off
+}
+
+
+bool CtrlVideo::isUsed( ) const
+{
+    return m_pVoutWindow ? true : false;
+}
index 1b5d37d4ec45f26212ee4db61d26f25555f477b1..03e34d940ecc2fd6e9ed3b051343b1f43ed49997 100644 (file)
@@ -80,11 +80,11 @@ public:
     // resize the video Control
     virtual void resizeControl( int width, int height );
 
-    // Is this control useable (visibility requirements)
-    virtual bool isUseable() { return m_bIsUseable; }
+    // Is this control usable (visibility requirements)
+    virtual bool isUseable() const;
 
     // Is this control used
-    virtual bool isUsed() { return m_pVoutWindow ? true : false; }
+    virtual bool isUsed() const;
 
 private:
     /// Associated layout
@@ -96,9 +96,6 @@ private:
     /// Difference between layout size and video size
     int m_xShift, m_yShift;
 
-    /// Is the video Control useable
-    bool m_bIsUseable;
-
     /// Vout window
     VoutWindow *m_pVoutWindow;
 };
index fb83d693b01070edffb9b279bb42ad1bb64040f4..745dfae935acca07a40a550c156b036fb8a88cc3 100644 (file)
@@ -115,6 +115,9 @@ public:
                m_original_height == otherLayout.m_original_height;
     }
 
+    // getter for layout visibility
+    virtual bool isVisible( ) const { return m_visible; }
+
     /**
      * Add a control in the layout at the given position, and
      * the optional given layer
index 23cb909ddc7e16ddbd453b11b41c672f61181827..301731b52a42b2264ac1fed8eeb55e1f7a6e6694 100644 (file)
@@ -171,9 +171,9 @@ void VoutManager::requestVout( CtrlVideo* pCtrlVideo )
 
 CtrlVideo* VoutManager::getBestCtrlVideo( )
 {
-    // try to find an unused useable VideoControl
-
     vector<CtrlVideo*>::const_iterator it;
+
+    // first, look up a video control that is visible and unused
     for( it = m_pCtrlVideoVec.begin(); it != m_pCtrlVideoVec.end(); ++it )
     {
         if( (*it)->isUseable() && !(*it)->isUsed() )
@@ -182,6 +182,15 @@ CtrlVideo* VoutManager::getBestCtrlVideo( )
         }
     }
 
+    // as a fallback, look up any video control that is unused
+    for( it = m_pCtrlVideoVec.begin(); it != m_pCtrlVideoVec.end(); ++it )
+    {
+        if( !(*it)->isUsed() )
+        {
+            return (*it);
+        }
+    }
+
     return NULL;
 }