]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins2/src/vout_manager.cpp
skins2: implement relative positioning
[vlc] / modules / gui / skins2 / src / vout_manager.cpp
index a2a9fc802fe1e18a5c7edbb0ec948dfdc4b578f9..3b8197e0f52acd7ef70fc86f9a77477ce64fb562 100644 (file)
@@ -26,6 +26,7 @@
 #endif
 
 #include <vlc_vout.h>
+#include <vlc_vout_display.h>
 
 #include "vout_manager.hpp"
 #include "window_manager.hpp"
@@ -34,6 +35,7 @@
 #include "../commands/cmd_show_window.hpp"
 #include "../commands/cmd_resize.hpp"
 #include "../commands/cmd_voutwindow.hpp"
+#include "../commands/cmd_on_top.hpp"
 
 
 
@@ -56,15 +58,28 @@ void VoutManager::destroy( intf_thread_t *pIntf )
 
 
 VoutManager::VoutManager( intf_thread_t *pIntf ): SkinObject( pIntf ),
-     m_pVoutMainWindow( NULL ), m_pCtrlVideoVec(),
+     m_pVoutMainWindow( NULL ), m_pFscWindow( NULL ), m_pCtrlVideoVec(),
      m_pCtrlVideoVecBackup(), m_SavedWndVec()
 {
     m_pVoutMainWindow = new VoutMainWindow( getIntf() );
+
+    OSFactory *pOsFactory = OSFactory::instance( getIntf() );
+    int width = pOsFactory->getScreenWidth();
+    int height = pOsFactory->getScreenHeight();
+
+    m_pVoutMainWindow->move( 0, 0 );
+    m_pVoutMainWindow->resize( width, height );
+
+    VarBool &rFullscreen = VlcProc::instance( getIntf() )->getFullscreenVar();
+    rFullscreen.addObserver( this );
 }
 
 
 VoutManager::~VoutManager( )
 {
+    VarBool &rFullscreen = VlcProc::instance( getIntf() )->getFullscreenVar();
+    rFullscreen.delObserver( this );
+
     delete m_pVoutMainWindow;
 }
 
@@ -75,12 +90,22 @@ void VoutManager::registerCtrlVideo( CtrlVideo* p_CtrlVideo )
 }
 
 
+void VoutManager::registerFSC( TopWindow* p_Win )
+{
+    m_pFscWindow = p_Win;
+
+    int x = p_Win->getLeft();
+    int y = p_Win->getTop();
+    p_Win->setParent( m_pVoutMainWindow, x , y, 0, 0 );
+}
+
+
 void VoutManager::saveVoutConfig( )
 {
     // Save width/height to be consistent across themes
     // and detach Video Controls
     vector<SavedWnd>::iterator it;
-    for( it = m_SavedWndVec.begin(); it != m_SavedWndVec.end(); it++ )
+    for( it = m_SavedWndVec.begin(); it != m_SavedWndVec.end(); ++it )
     {
         if( (*it).pCtrlVideo )
         {
@@ -110,7 +135,7 @@ void VoutManager::restoreVoutConfig( bool b_success )
 
     // reattach vout(s) to Video Controls
     vector<SavedWnd>::iterator it;
-    for( it = m_SavedWndVec.begin(); it != m_SavedWndVec.end(); it++ )
+    for( it = m_SavedWndVec.begin(); it != m_SavedWndVec.end(); ++it )
     {
         CtrlVideo* pCtrlVideo = getBestCtrlVideo();
         if( pCtrlVideo )
@@ -125,7 +150,7 @@ void VoutManager::restoreVoutConfig( bool b_success )
 void VoutManager::discardVout( CtrlVideo* pCtrlVideo )
 {
     vector<SavedWnd>::iterator it;
-    for( it = m_SavedWndVec.begin(); it != m_SavedWndVec.end(); it++ )
+    for( it = m_SavedWndVec.begin(); it != m_SavedWndVec.end(); ++it )
     {
         if( (*it).pCtrlVideo == pCtrlVideo )
         {
@@ -143,7 +168,7 @@ void VoutManager::discardVout( CtrlVideo* pCtrlVideo )
 void VoutManager::requestVout( CtrlVideo* pCtrlVideo )
 {
     vector<SavedWnd>::iterator it;
-    for( it = m_SavedWndVec.begin(); it != m_SavedWndVec.end(); it++ )
+    for( it = m_SavedWndVec.begin(); it != m_SavedWndVec.end(); ++it )
     {
         if( (*it).pCtrlVideo == NULL )
         {
@@ -161,7 +186,7 @@ CtrlVideo* VoutManager::getBestCtrlVideo( )
     // try to find an unused useable VideoControl
 
     vector<CtrlVideo*>::const_iterator it;
-    for( it = m_pCtrlVideoVec.begin(); it != m_pCtrlVideoVec.end(); it++ )
+    for( it = m_pCtrlVideoVec.begin(); it != m_pCtrlVideoVec.end(); ++it )
     {
         if( (*it)->isUseable() && !(*it)->isUsed() )
         {
@@ -192,6 +217,10 @@ void* VoutManager::acceptWnd( vout_window_t* pWnd )
         // directly attach vout thread to it
         pCtrlVideo->attachVoutWindow( pVoutWindow );
     }
+    else
+    {
+        pVoutWindow->setCtrlVideo( NULL );
+    }
 
     // save vout characteristics
     m_SavedWndVec.push_back( SavedWnd( pWnd, pVoutWindow, pCtrlVideo ) );
@@ -207,11 +236,11 @@ void VoutManager::releaseWnd( vout_window_t *pWnd )
 {
     // remove vout thread from savedVec
     vector<SavedWnd>::iterator it;
-    for( it = m_SavedWndVec.begin(); it != m_SavedWndVec.end(); it++ )
+    for( it = m_SavedWndVec.begin(); it != m_SavedWndVec.end(); ++it )
     {
         if( (*it).pWnd == pWnd )
         {
-            msg_Dbg( getIntf(), "vout released vout=0x%p, VideoCtrl=0x%p",
+            msg_Dbg( getIntf(), "vout released vout=%p, VideoCtrl=%p",
                              pWnd, (*it).pCtrlVideo );
 
             // if a video control was being used, detach from it
@@ -226,6 +255,9 @@ void VoutManager::releaseWnd( vout_window_t *pWnd )
             break;
         }
     }
+
+    // force fullscreen to false so that user regains control
+    VlcProc::instance( getIntf() )->setFullscreenVar( false );
 }
 
 
@@ -235,7 +267,7 @@ void VoutManager::setSizeWnd( vout_window_t *pWnd, int width, int height )
                   width, height );
 
    vector<SavedWnd>::iterator it;
-   for( it = m_SavedWndVec.begin(); it != m_SavedWndVec.end(); it++ )
+   for( it = m_SavedWndVec.begin(); it != m_SavedWndVec.end(); ++it )
    {
        if( (*it).pWnd == pWnd )
        {
@@ -254,24 +286,29 @@ void VoutManager::setSizeWnd( vout_window_t *pWnd, int width, int height )
    }
 }
 
+
 void VoutManager::setFullscreenWnd( vout_window_t *pWnd, bool b_fullscreen )
 {
-   msg_Dbg( pWnd, "setFullscreen (%d) received from vout thread",
-                   b_fullscreen ? 1 : 0 );
+    msg_Dbg( pWnd, "setFullscreen (%i) received from vout thread",
+                   b_fullscreen );
 
-   vector<SavedWnd>::iterator it;
-   for( it = m_SavedWndVec.begin(); it != m_SavedWndVec.end(); it++ )
-   {
-       if( (*it).pWnd == pWnd )
-       {
-           VoutWindow* pVoutWindow = (*it).pVoutWindow;
+    VlcProc::instance( getIntf() )->setFullscreenVar( b_fullscreen );
+}
 
-           pVoutWindow->setFullscreen( b_fullscreen );
-           break;
-       }
+
+void VoutManager::onUpdate( Subject<VarBool> &rVariable, void *arg  )
+{
+    VarBool &rFullscreen = VlcProc::instance( getIntf() )->getFullscreenVar();
+    if( &rVariable == &rFullscreen )
+    {
+        if( rFullscreen.get() )
+            m_pVoutMainWindow->show();
+        else
+            m_pVoutMainWindow->hide();
     }
 }
 
+
 // Functions called by window provider
 // ///////////////////////////////////
 
@@ -342,7 +379,7 @@ int VoutManager::controlWindow( struct vout_window_t *pWnd,
                    AsyncQueue::instance( pThis->getIntf() );
                 pQueue->push( CmdGenericPtr( pCmd ) );
             }
-            return VLC_SUCCESS;
+            return VLC_EGENERIC;
         }
 
         case VOUT_WINDOW_SET_FULLSCREEN:
@@ -359,6 +396,22 @@ int VoutManager::controlWindow( struct vout_window_t *pWnd,
             return VLC_SUCCESS;
         }
 
+        case VOUT_WINDOW_SET_STATE:
+        {
+            unsigned i_arg = va_arg( args, unsigned );
+            unsigned on_top = i_arg & VOUT_WINDOW_STATE_ABOVE;
+
+            // Post a SetOnTop command
+            CmdSetOnTop* pCmd =
+                new CmdSetOnTop( pThis->getIntf(), on_top );
+
+            AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
+            pQueue->push( CmdGenericPtr( pCmd ) );
+
+            return VLC_SUCCESS;
+        }
+
+
         default:
             msg_Dbg( pWnd, "control query not supported" );
             return VLC_EGENERIC;