]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins2/src/skin_main.cpp
skins2: fix forgotten initialization in copy constructor
[vlc] / modules / gui / skins2 / src / skin_main.cpp
index 9f37ebaf2dbee4f83ab08a7eab37c5f1806556ff..095bf498ea1d1701344e5593c434d2d059f6e57b 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
-#include <vlc/vlc.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_plugin.h>
 #include <vlc_input.h>
-#include <vlc_demux.h>
 #include <vlc_playlist.h>
+#include <vlc_threads.h>
+#include <vlc_vout_window.h>
+#include <vlc_vout_display.h>
 
 #include "dialogs.hpp"
 #include "os_factory.hpp"
 #include "theme_loader.hpp"
 #include "theme.hpp"
 #include "theme_repository.hpp"
+#include "vout_window.hpp"
+#include "vout_manager.hpp"
+#include "art_manager.hpp"
 #include "../parser/interpreter.hpp"
 #include "../commands/async_queue.hpp"
 #include "../commands/cmd_quit.hpp"
 #include "../commands/cmd_dialogs.hpp"
 #include "../commands/cmd_minimize.hpp"
-
-//---------------------------------------------------------------------------
-// Exported interface functions.
-//---------------------------------------------------------------------------
-#ifdef WIN32_SKINS
-extern "C" __declspec( dllexport )
-    int __VLC_SYMBOL( vlc_entry ) ( module_t *p_module );
-#endif
-
+#include "../commands/cmd_playlist.hpp"
+#include "../commands/cmd_callbacks.hpp"
+#include "../commands/cmd_show_window.hpp"
+#include "../commands/cmd_resize.hpp"
+#include "../commands/cmd_on_top.hpp"
 
 //---------------------------------------------------------------------------
 // Local prototypes
 //---------------------------------------------------------------------------
 static int  Open  ( vlc_object_t * );
 static void Close ( vlc_object_t * );
-static void Run   ( intf_thread_t * );
-
-static int DemuxOpen( vlc_object_t * );
-static int Demux( demux_t * );
-static int DemuxControl( demux_t *, int, va_list );
-
-//---------------------------------------------------------------------------
-// Prototypes for configuration callbacks
-//---------------------------------------------------------------------------
-static int onSystrayChange( vlc_object_t *pObj, const char *pVariable,
-                            vlc_value_t oldVal, vlc_value_t newVal,
-                            void *pParam );
-static int onTaskBarChange( vlc_object_t *pObj, const char *pVariable,
-                            vlc_value_t oldVal, vlc_value_t newVal,
-                            void *pParam );
+static void *Run  ( void * );
 
+static struct
+{
+    intf_thread_t *intf;
+    vlc_mutex_t mutex;
+} skin_load = { NULL, VLC_STATIC_MUTEX };
 
 //---------------------------------------------------------------------------
 // Open: initialize interface
@@ -80,27 +77,17 @@ static int Open( vlc_object_t *p_this )
     intf_thread_t *p_intf = (intf_thread_t *)p_this;
 
     // Allocate instance and initialize some members
-    p_intf->p_sys = (intf_sys_t *) malloc( sizeof( intf_sys_t ) );
+    p_intf->p_sys = (intf_sys_t *) calloc( 1, sizeof( intf_sys_t ) );
     if( p_intf->p_sys == NULL )
-    {
-        msg_Err( p_intf, "out of memory" );
-        return( VLC_ENOMEM );
-    };
-
-    p_intf->pf_run = Run;
+        return VLC_ENOMEM;
 
     // Suscribe to messages bank
-    p_intf->p_sys->p_sub = msg_Subscribe( p_intf, MSG_QUEUE_NORMAL );
+#if 0
+    p_intf->p_sys->p_sub = vlc_Subscribe( p_intf );
+#endif
 
     p_intf->p_sys->p_input = NULL;
-    p_intf->p_sys->p_playlist = (playlist_t *)vlc_object_find( p_intf,
-        VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
-    if( p_intf->p_sys->p_playlist == NULL )
-    {
-        msg_Err( p_intf, "No playlist object found" );
-        msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
-        return VLC_EGENERIC;
-    }
+    p_intf->p_sys->p_playlist = pl_Get( p_intf );
 
     // Initialize "singleton" objects
     p_intf->p_sys->p_logger = NULL;
@@ -110,58 +97,51 @@ static int Open( vlc_object_t *p_this )
     p_intf->p_sys->p_osFactory = NULL;
     p_intf->p_sys->p_osLoop = NULL;
     p_intf->p_sys->p_varManager = NULL;
+    p_intf->p_sys->p_voutManager = NULL;
     p_intf->p_sys->p_vlcProc = NULL;
     p_intf->p_sys->p_repository = NULL;
 
     // No theme yet
     p_intf->p_sys->p_theme = NULL;
 
-    // Create a variable to be notified of skins to be loaded
-    var_Create( p_intf, "skin-to-load", VLC_VAR_STRING );
+    vlc_mutex_init( &p_intf->p_sys->init_lock );
+    vlc_cond_init( &p_intf->p_sys->init_wait );
 
-    // Initialize singletons
-    if( OSFactory::instance( p_intf ) == NULL )
-    {
-        msg_Err( p_intf, "cannot initialize OSFactory" );
-        vlc_object_release( p_intf->p_sys->p_playlist );
-        msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
-        return VLC_EGENERIC;
-    }
-    if( AsyncQueue::instance( p_intf ) == NULL )
-    {
-        msg_Err( p_intf, "cannot initialize AsyncQueue" );
-        vlc_object_release( p_intf->p_sys->p_playlist );
-        msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
-        return VLC_EGENERIC;
-    }
-    if( Interpreter::instance( p_intf ) == NULL )
-    {
-        msg_Err( p_intf, "cannot instanciate Interpreter" );
-        vlc_object_release( p_intf->p_sys->p_playlist );
-        msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
-        return VLC_EGENERIC;
-    }
-    if( VarManager::instance( p_intf ) == NULL )
+    vlc_mutex_lock( &p_intf->p_sys->init_lock );
+    p_intf->p_sys->b_error = false;
+    p_intf->p_sys->b_ready = false;
+
+    if( vlc_clone( &p_intf->p_sys->thread, Run, p_intf,
+                               VLC_THREAD_PRIORITY_LOW ) )
     {
-        msg_Err( p_intf, "cannot instanciate VarManager" );
-        vlc_object_release( p_intf->p_sys->p_playlist );
-        msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
+        vlc_mutex_unlock( &p_intf->p_sys->init_lock );
+
+        vlc_cond_destroy( &p_intf->p_sys->init_wait );
+        vlc_mutex_destroy( &p_intf->p_sys->init_lock );
+        free( p_intf->p_sys );
         return VLC_EGENERIC;
     }
-    if( VlcProc::instance( p_intf ) == NULL )
+
+    while( !p_intf->p_sys->b_ready )
+        vlc_cond_wait( &p_intf->p_sys->init_wait, &p_intf->p_sys->init_lock );
+    vlc_mutex_unlock( &p_intf->p_sys->init_lock );
+
+    if( p_intf->p_sys->b_error )
     {
-        msg_Err( p_intf, "cannot initialize VLCProc" );
-        vlc_object_release( p_intf->p_sys->p_playlist );
-        msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
+        vlc_join( p_intf->p_sys->thread, NULL );
+
+        vlc_mutex_destroy( &p_intf->p_sys->init_lock );
+        vlc_cond_destroy( &p_intf->p_sys->init_wait );
+
+        free( p_intf->p_sys );
         return VLC_EGENERIC;
     }
-    Dialogs::instance( p_intf );
-    ThemeRepository::instance( p_intf );
 
-    // We support play on start
-    p_intf->b_play = VLC_TRUE;
+    vlc_mutex_lock( &skin_load.mutex );
+    skin_load.intf = p_intf;
+    vlc_mutex_unlock( &skin_load.mutex );
 
-    return( VLC_SUCCESS );
+    return VLC_SUCCESS;
 }
 
 //---------------------------------------------------------------------------
@@ -171,23 +151,21 @@ static void Close( vlc_object_t *p_this )
 {
     intf_thread_t *p_intf = (intf_thread_t *)p_this;
 
-    // Destroy "singleton" objects
-    OSFactory::instance( p_intf )->destroyOSLoop();
-    ThemeRepository::destroy( p_intf );
-    Dialogs::destroy( p_intf );
-    Interpreter::destroy( p_intf );
-    AsyncQueue::destroy( p_intf );
-    VarManager::destroy( p_intf );
-    VlcProc::destroy( p_intf );
-    OSFactory::destroy( p_intf );
+    msg_Dbg( p_intf, "closing skins2 module" );
 
-    if( p_intf->p_sys->p_playlist )
-    {
-        vlc_object_release( p_intf->p_sys->p_playlist );
-    }
+    vlc_mutex_lock( &skin_load.mutex );
+    skin_load.intf = NULL;
+    vlc_mutex_unlock( &skin_load.mutex);
+
+    vlc_join( p_intf->p_sys->thread, NULL );
+
+    vlc_mutex_destroy( &p_intf->p_sys->init_lock );
+    vlc_cond_destroy( &p_intf->p_sys->init_wait );
 
     // Unsubscribe from messages bank
-    msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
+#if 0
+    vlc_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
+#endif
 
     // Destroy structure
     free( p_intf->p_sys );
@@ -197,231 +175,287 @@ static void Close( vlc_object_t *p_this )
 //---------------------------------------------------------------------------
 // Run: main loop
 //---------------------------------------------------------------------------
-static void Run( intf_thread_t *p_intf )
+static void *Run( void * p_obj )
 {
-    // Load a theme
-    ThemeLoader *pLoader = new ThemeLoader( p_intf );
-    char *skin_last = config_GetPsz( p_intf, "skins2-last" );
+    int canc = vlc_savecancel();
 
-    if( !skin_last || !*skin_last || !pLoader->load( skin_last ) )
-    {
-        // Get the resource path and try to load the default skin
-        OSFactory *pOSFactory = OSFactory::instance( p_intf );
-        const list<string> &resPath = pOSFactory->getResourcePath();
-        const string &sep = pOSFactory->getDirSeparator();
+    intf_thread_t *p_intf = (intf_thread_t *)p_obj;
 
-        list<string>::const_iterator it;
-        for( it = resPath.begin(); it != resPath.end(); it++ )
-        {
-            string path = (*it) + sep + "default.vlt";
-            if( pLoader->load( path ) )
-            {
-                // Theme loaded successfully
-                break;
-            }
-        }
-        if( it == resPath.end() )
-        {
-            // Last chance: the user can select a new theme file
-            if( Dialogs::instance( p_intf ) )
-            {
-                CmdDlgChangeSkin *pCmd = new CmdDlgChangeSkin( p_intf );
-                AsyncQueue *pQueue = AsyncQueue::instance( p_intf );
-                pQueue->push( CmdGenericPtr( pCmd ) );
-            }
-            else
-            {
-                // No dialogs provider, just quit...
-                CmdQuit *pCmd = new CmdQuit( p_intf );
-                AsyncQueue *pQueue = AsyncQueue::instance( p_intf );
-                pQueue->push( CmdGenericPtr( pCmd ) );
-                msg_Err( p_intf,
-                         "cannot show the \"open skin\" dialog: exiting...");
-            }
-        }
-    }
-    delete pLoader;
+    bool b_error = false;
+    char *skin_last = NULL;
+    ThemeLoader *pLoader = NULL;
+    OSLoop *loop = NULL;
+
+    vlc_mutex_lock( &p_intf->p_sys->init_lock );
 
-    if( skin_last )
+    // Initialize singletons
+    if( OSFactory::instance( p_intf ) == NULL )
+    {
+        msg_Err( p_intf, "cannot initialize OSFactory" );
+        b_error = true;
+        goto end;
+    }
+    if( AsyncQueue::instance( p_intf ) == NULL )
+    {
+        msg_Err( p_intf, "cannot initialize AsyncQueue" );
+        b_error = true;
+        goto end;
+    }
+    if( Interpreter::instance( p_intf ) == NULL )
+    {
+        msg_Err( p_intf, "cannot instantiate Interpreter" );
+        b_error = true;
+        goto end;
+    }
+    if( VarManager::instance( p_intf ) == NULL )
+    {
+        msg_Err( p_intf, "cannot instantiate VarManager" );
+        b_error = true;
+        goto end;
+    }
+    if( VlcProc::instance( p_intf ) == NULL )
+    {
+        msg_Err( p_intf, "cannot initialize VLCProc" );
+        b_error = true;
+        goto end;
+    }
+    if( VoutManager::instance( p_intf ) == NULL )
+    {
+        msg_Err( p_intf, "cannot instantiate VoutManager" );
+        b_error = true;
+        goto end;
+    }
+    if( ArtManager::instance( p_intf ) == NULL )
     {
-        free( skin_last );
+        msg_Err( p_intf, "cannot instantiate ArtManager" );
+        b_error = true;
+        goto end;
+    }
+    if( ThemeRepository::instance( p_intf ) == NULL )
+    {
+        msg_Err( p_intf, "cannot instantiate ThemeRepository" );
+        b_error = true;
+        goto end;
+    }
+    if( Dialogs::instance( p_intf ) == NULL )
+    {
+        msg_Err( p_intf, "cannot instantiate qt4 dialogs provider" );
+        b_error = true;
+        goto end;
     }
 
-    // Get the instance of OSLoop
-    OSLoop *loop = OSFactory::instance( p_intf )->getOSLoop();
+    // Load a theme
+    skin_last = config_GetPsz( p_intf, "skins2-last" );
+    pLoader = new ThemeLoader( p_intf );
 
-    // Check if we need to start playing
-    if( p_intf->b_play )
+    if( !skin_last || !pLoader->load( skin_last ) )
     {
-        playlist_t *p_playlist =
-            (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
-                                           FIND_ANYWHERE );
-        if( p_playlist )
-        {
-            playlist_Control( p_playlist, PLAYLIST_AUTOPLAY, VLC_FALSE );
-            vlc_object_release( p_playlist );
-        }
+        // No skins (not even the default one). let's quit
+        CmdQuit *pCmd = new CmdQuit( p_intf );
+        AsyncQueue *pQueue = AsyncQueue::instance( p_intf );
+        pQueue->push( CmdGenericPtr( pCmd ) );
+        msg_Err( p_intf, "no skins found : exiting");
     }
 
+    delete pLoader;
+    free( skin_last );
+
+    // Get the instance of OSLoop
+    loop = OSFactory::instance( p_intf )->getOSLoop();
+
+    // Signal the main thread this thread is now ready
+    p_intf->p_sys->b_error = false;
+    p_intf->p_sys->b_ready = true;
+    vlc_cond_signal( &p_intf->p_sys->init_wait );
+    vlc_mutex_unlock( &p_intf->p_sys->init_lock );
+
     // Enter the main event loop
     loop->run();
 
-    // Delete the theme and save the configuration of the windows
+    // Destroy OSLoop
+    OSFactory::instance( p_intf )->destroyOSLoop();
+
+    // save and delete the theme
     if( p_intf->p_sys->p_theme )
     {
         p_intf->p_sys->p_theme->saveConfig();
+
         delete p_intf->p_sys->p_theme;
         p_intf->p_sys->p_theme = NULL;
-    }
-}
 
-
-//---------------------------------------------------------------------------
-// DemuxOpen: initialize demux
-//---------------------------------------------------------------------------
-static int DemuxOpen( vlc_object_t *p_this )
-{
-    demux_t *p_demux = (demux_t*)p_this;
-    intf_thread_t *p_intf;
-    char *ext;
-
-    // Needed callbacks
-    p_demux->pf_demux   = Demux;
-    p_demux->pf_control = DemuxControl;
-
-    // Test that we have a valid .vlt or .wsz file, based on the extension
-    // TODO: an actual check of the contents would be better...
-    if( ( ext = strchr( p_demux->psz_path, '.' ) ) == NULL ||
-        ( strcasecmp( ext, ".vlt" ) && strcasecmp( ext, ".wsz" ) ) )
-    {
-        return VLC_EGENERIC;
+        msg_Dbg( p_intf, "current theme deleted" );
     }
 
-    p_intf = (intf_thread_t *)vlc_object_find( p_this, VLC_OBJECT_INTF,
-                                               FIND_ANYWHERE );
-    if( p_intf != NULL )
-    {
-        // Do nothing is skins2 is not the main interface
-        if( var_Type( p_intf, "skin-to-load" ) == VLC_VAR_STRING )
-        {
-            playlist_t *p_playlist =
-                (playlist_t *) vlc_object_find( p_this, VLC_OBJECT_PLAYLIST,
-                                                FIND_ANYWHERE );
-            if( p_playlist != NULL )
-            {
-                // Make sure the item is deleted afterwards
-                /// \bug does not always work
-                p_playlist->status.p_item->i_flags |= PLAYLIST_REMOVE_FLAG;
-                vlc_object_release( p_playlist );
-            }
+    // save config file
+    config_SaveConfigFile( p_intf );
 
-            vlc_value_t val;
-            val.psz_string = p_demux->psz_path;
-            var_Set( p_intf, "skin-to-load", val );
-        }
-        else
-        {
-            msg_Warn( p_this,
-                      "skin could not be loaded (not using skins2 intf)" );
-        }
+end:
+    // Destroy "singleton" objects
+    Dialogs::destroy( p_intf );
+    ThemeRepository::destroy( p_intf );
+    ArtManager::destroy( p_intf );
+    VoutManager::destroy( p_intf );
+    VlcProc::destroy( p_intf );
+    VarManager::destroy( p_intf );
+    Interpreter::destroy( p_intf );
+    AsyncQueue::destroy( p_intf );
+    OSFactory::destroy( p_intf );
 
-        vlc_object_release( p_intf );
+    if( b_error )
+    {
+        p_intf->p_sys->b_error = true;
+        p_intf->p_sys->b_ready = true;
+        vlc_cond_signal( &p_intf->p_sys->init_wait );
+        vlc_mutex_unlock( &p_intf->p_sys->init_lock );
     }
 
-    return VLC_SUCCESS;
+    vlc_restorecancel(canc);
+    return NULL;
 }
 
+static int  WindowOpen( vout_window_t *, const vout_window_cfg_t * );
+static void WindowClose( vout_window_t * );
+static int  WindowControl( vout_window_t *, int, va_list );
 
-//---------------------------------------------------------------------------
-// Demux: return EOF
-//---------------------------------------------------------------------------
-static int Demux( demux_t *p_demux )
+struct vout_window_sys_t
 {
-    return 0;
-}
-
+    intf_thread_t*     pIntf;
+    vout_window_cfg_t  cfg;
+};
 
-//---------------------------------------------------------------------------
-// DemuxControl
-//---------------------------------------------------------------------------
-static int DemuxControl( demux_t *p_demux, int i_query, va_list args )
+static void WindowOpenLocal( intf_thread_t* pIntf, vlc_object_t *pObj )
 {
-    return demux2_vaControlHelper( p_demux->s, 0, 0, 0, 1, i_query, args );
+    vout_window_t* pWnd = (vout_window_t*)pObj;
+    int width = (int)pWnd->sys->cfg.width;
+    int height = (int)pWnd->sys->cfg.height;
+    VoutManager::instance( pIntf )->acceptWnd( pWnd, width, height );
 }
 
+static void WindowCloseLocal( intf_thread_t* pIntf, vlc_object_t *pObj )
+{
+    vout_window_t* pWnd = (vout_window_t*)pObj;
+    VoutManager::instance( pIntf )->releaseWnd( pWnd );
+}
 
-//---------------------------------------------------------------------------
-// Callbacks
-//---------------------------------------------------------------------------
-
-/// Callback for the systray configuration option
-static int onSystrayChange( vlc_object_t *pObj, const char *pVariable,
-                            vlc_value_t oldVal, vlc_value_t newVal,
-                            void *pParam )
+static int WindowOpen( vout_window_t *pWnd, const vout_window_cfg_t *cfg )
 {
-    intf_thread_t *pIntf =
-        (intf_thread_t*)vlc_object_find( pObj, VLC_OBJECT_INTF, FIND_ANYWHERE );
+    vout_window_sys_t* sys;
+
+    vlc_mutex_lock( &skin_load.mutex );
+    intf_thread_t *pIntf = skin_load.intf;
+    if( pIntf )
+        vlc_object_hold( pIntf );
+    vlc_mutex_unlock( &skin_load.mutex );
 
     if( pIntf == NULL )
+        return VLC_EGENERIC;
+
+    if( !vlc_object_alive( pIntf ) ||
+        !var_InheritBool( pIntf, "skinned-video") ||
+        cfg->is_standalone )
     {
+        vlc_object_release( pIntf );
         return VLC_EGENERIC;
     }
 
-    // Check that we found the correct interface (same check as for the demux)
-    if( var_Type( pIntf, "skin-to-load" ) == VLC_VAR_STRING )
+    sys = (vout_window_sys_t*)calloc( 1, sizeof( *sys ) );
+    if( !sys )
     {
-        AsyncQueue *pQueue = AsyncQueue::instance( pIntf );
-        if( newVal.b_bool )
-        {
-            CmdAddInTray *pCmd = new CmdAddInTray( pIntf );
-            pQueue->push( CmdGenericPtr( pCmd ) );
-        }
-        else
-        {
-            CmdRemoveFromTray *pCmd = new CmdRemoveFromTray( pIntf );
-            pQueue->push( CmdGenericPtr( pCmd ) );
-        }
+        vlc_object_release( pIntf );
+        return VLC_ENOMEM;
+    }
+
+    pWnd->sys = sys;
+    pWnd->sys->cfg = *cfg;
+    pWnd->sys->pIntf = pIntf;
+    pWnd->control = WindowControl;
+
+    // force execution in the skins2 thread context
+    CmdExecuteBlock* cmd = new CmdExecuteBlock( pIntf, VLC_OBJECT( pWnd ),
+                                                WindowOpenLocal );
+    CmdExecuteBlock::executeWait( CmdGenericPtr( cmd ) );
+
+#ifdef X11_SKINS
+    if( !pWnd->handle.xid )
+#else
+    if( !pWnd->handle.hwnd )
+#endif
+    {
+        free( sys );
+        vlc_object_release( pIntf );
+        return VLC_EGENERIC;
     }
 
-    vlc_object_release( pIntf );
     return VLC_SUCCESS;
 }
 
+static void WindowClose( vout_window_t *pWnd )
+{
+    vout_window_sys_t* sys = pWnd->sys;
+    intf_thread_t *pIntf = sys->pIntf;
+
+    // force execution in the skins2 thread context
+    CmdExecuteBlock* cmd = new CmdExecuteBlock( pIntf, VLC_OBJECT( pWnd ),
+                                                WindowCloseLocal );
+    CmdExecuteBlock::executeWait( CmdGenericPtr( cmd ) );
 
-/// Callback for the systray configuration option
-static int onTaskBarChange( vlc_object_t *pObj, const char *pVariable,
-                            vlc_value_t oldVal, vlc_value_t newVal,
-                            void *pParam )
+    vlc_object_release( sys->pIntf );
+    free( sys );
+}
+
+static int WindowControl( vout_window_t *pWnd, int query, va_list args )
 {
-    intf_thread_t *pIntf =
-        (intf_thread_t*)vlc_object_find( pObj, VLC_OBJECT_INTF, FIND_ANYWHERE );
+    vout_window_sys_t* sys = pWnd->sys;
+    intf_thread_t *pIntf = sys->pIntf;
+    AsyncQueue *pQueue = AsyncQueue::instance( pIntf );
 
-    if( pIntf == NULL )
+    switch( query )
     {
-        return VLC_EGENERIC;
-    }
+        case VOUT_WINDOW_SET_SIZE:
+        {
+            unsigned int i_width  = va_arg( args, unsigned int );
+            unsigned int i_height = va_arg( args, unsigned int );
 
-    // Check that we found the correct interface (same check as for the demux)
-    if( var_Type( pIntf, "skin-to-load" ) == VLC_VAR_STRING )
-    {
-        AsyncQueue *pQueue = AsyncQueue::instance( pIntf );
-        if( newVal.b_bool )
+            if( i_width && i_height )
+            {
+                // Post a vout resize command
+                CmdResizeVout *pCmd =
+                    new CmdResizeVout( pIntf, pWnd,
+                                       (int)i_width, (int)i_height );
+                pQueue->push( CmdGenericPtr( pCmd ) );
+            }
+            return VLC_EGENERIC;
+        }
+
+        case VOUT_WINDOW_SET_FULLSCREEN:
         {
-            CmdAddInTaskBar *pCmd = new CmdAddInTaskBar( pIntf );
+            bool b_fullscreen = va_arg( args, int );
+
+            // Post a set fullscreen command
+            CmdSetFullscreen* pCmd =
+                new CmdSetFullscreen( pIntf, pWnd, b_fullscreen );
             pQueue->push( CmdGenericPtr( pCmd ) );
+            return VLC_SUCCESS;
         }
-        else
+
+        case VOUT_WINDOW_SET_STATE:
         {
-            CmdRemoveFromTaskBar *pCmd = new CmdRemoveFromTaskBar( pIntf );
+            unsigned i_arg = va_arg( args, unsigned );
+            unsigned on_top = i_arg & VOUT_WINDOW_STATE_ABOVE;
+
+            // Post a SetOnTop command
+            CmdSetOnTop* pCmd =
+                new CmdSetOnTop( pIntf, on_top );
             pQueue->push( CmdGenericPtr( pCmd ) );
+            return VLC_SUCCESS;
         }
-    }
 
-    vlc_object_release( pIntf );
-    return VLC_SUCCESS;
+        default:
+            msg_Dbg( pIntf, "control query not supported" );
+            return VLC_EGENERIC;
+    }
 }
 
-
 //---------------------------------------------------------------------------
 // Module descriptor
 //---------------------------------------------------------------------------
@@ -440,37 +474,44 @@ static int onTaskBarChange( vlc_object_t *pObj, const char *pVariable,
     " correctly.")
 #define SKINS2_PLAYLIST N_("Use a skinned playlist")
 #define SKINS2_PLAYLIST_LONG N_("Use a skinned playlist")
-
-vlc_module_begin();
-    set_category( CAT_INTERFACE );
-    set_subcategory( SUBCAT_INTERFACE_MAIN );
-    add_file( "skins2-last", "", NULL, SKINS2_LAST, SKINS2_LAST_LONG,
-              VLC_TRUE );
-        change_autosave();
-    add_string( "skins2-config", "", NULL, SKINS2_CONFIG, SKINS2_CONFIG_LONG,
-                VLC_TRUE );
-        change_autosave();
-        change_internal();
+#define SKINS2_VIDEO N_("Display video in a skinned window if any")
+#define SKINS2_VIDEO_LONG N_( \
+    "When set to 'no', this parameter is intended to give old skins a chance" \
+    " to play back video even though no video tag is implemented")
+
+vlc_module_begin ()
+    set_category( CAT_INTERFACE )
+    set_subcategory( SUBCAT_INTERFACE_MAIN )
+    add_loadfile( "skins2-last", "", SKINS2_LAST, SKINS2_LAST_LONG,
+                  true )
+    add_string( "skins2-config", "", SKINS2_CONFIG, SKINS2_CONFIG_LONG,
+                true )
+        change_private ()
 #ifdef WIN32
-    add_bool( "skins2-systray", VLC_FALSE, onSystrayChange, SKINS2_SYSTRAY,
-              SKINS2_SYSTRAY_LONG, VLC_FALSE );
-    add_bool( "skins2-taskbar", VLC_TRUE, onTaskBarChange, SKINS2_TASKBAR,
-              SKINS2_TASKBAR_LONG, VLC_FALSE );
-    add_bool( "skins2-transparency", VLC_FALSE, NULL, SKINS2_TRANSPARENCY,
-              SKINS2_TRANSPARENCY_LONG, VLC_FALSE );
+    add_bool( "skins2-systray", true, SKINS2_SYSTRAY,
+              SKINS2_SYSTRAY_LONG, false );
+    add_bool( "skins2-taskbar", true, SKINS2_TASKBAR,
+              SKINS2_TASKBAR_LONG, false );
 #endif
+    add_bool( "skins2-transparency", false, SKINS2_TRANSPARENCY,
+              SKINS2_TRANSPARENCY_LONG, false );
+
+    add_bool( "skinned-playlist", true, SKINS2_PLAYLIST,
+              SKINS2_PLAYLIST_LONG, false );
+    add_bool( "skinned-video", true, SKINS2_VIDEO,
+              SKINS2_VIDEO_LONG, false );
+    set_shortname( N_("Skins"))
+    set_description( N_("Skinnable Interface") )
+    set_capability( "interface", 30 )
+    set_callbacks( Open, Close )
+    add_shortcut( "skins" )
+
+    add_submodule ()
+#ifdef WIN32
+        set_capability( "vout window hwnd", 51 )
+#else
+        set_capability( "vout window xid", 51 )
+#endif
+        set_callbacks( WindowOpen, WindowClose )
 
-    add_bool( "skinned-playlist", VLC_TRUE, NULL, SKINS2_PLAYLIST,
-              SKINS2_PLAYLIST_LONG, VLC_FALSE );
-    set_shortname( _("Skins"));
-    set_description( _("Skinnable Interface") );
-    set_capability( "interface", 30 );
-    set_callbacks( Open, Close );
-    add_shortcut( "skins" );
-
-    add_submodule();
-        set_description( _("Skins loader demux") );
-        set_capability( "demux2", 5 );
-        set_callbacks( DemuxOpen, NULL );
-
-vlc_module_end();
+vlc_module_end ()