Commit 1cf7350b authored by Olivier Teulière's avatar Olivier Teulière

* skins2: new skins2-taskbar configuration option, to allow removing VLC from...

 * skins2: new skins2-taskbar configuration option, to allow removing VLC from the task bar on Windows (changing this option takes effect on the fly)
parent a05b23aa
...@@ -56,3 +56,19 @@ void CmdRemoveFromTray::execute() ...@@ -56,3 +56,19 @@ void CmdRemoveFromTray::execute()
pOsFactory->removeFromTray(); pOsFactory->removeFromTray();
} }
void CmdAddInTaskBar::execute()
{
// Get the instance of OSFactory
OSFactory *pOsFactory = OSFactory::instance( getIntf() );
pOsFactory->addInTaskBar();
}
void CmdRemoveFromTaskBar::execute()
{
// Get the instance of OSFactory
OSFactory *pOsFactory = OSFactory::instance( getIntf() );
pOsFactory->removeFromTaskBar();
}
...@@ -27,10 +27,11 @@ ...@@ -27,10 +27,11 @@
#include "cmd_generic.hpp" #include "cmd_generic.hpp"
/// Command to minimize VLC
DEFINE_COMMAND(Minimize, "minimize" ) DEFINE_COMMAND(Minimize, "minimize" )
DEFINE_COMMAND(Restore, "restore" ) DEFINE_COMMAND(Restore, "restore" )
DEFINE_COMMAND(AddInTray, "add in tray" ) DEFINE_COMMAND(AddInTray, "add in tray" )
DEFINE_COMMAND(RemoveFromTray, "remove from tray" ) DEFINE_COMMAND(RemoveFromTray, "remove from tray" )
DEFINE_COMMAND(AddInTaskBar, "add in taskbar" )
DEFINE_COMMAND(RemoveFromTaskBar, "remove from taskbar" )
#endif #endif
...@@ -89,6 +89,16 @@ void MacOSXFactory::removeFromTray() ...@@ -89,6 +89,16 @@ void MacOSXFactory::removeFromTray()
// TODO // TODO
} }
void MacOSXFactory::addInTaskBar()
{
// TODO
}
void MacOSXFactory::removeFromTaskBar()
{
// TODO
}
OSTimer *MacOSXFactory::createOSTimer( const Callback &rCallback ) OSTimer *MacOSXFactory::createOSTimer( const Callback &rCallback )
{ {
return new MacOSXTimer( getIntf(), rCallback ); return new MacOSXTimer( getIntf(), rCallback );
......
...@@ -61,6 +61,12 @@ class MacOSXFactory: public OSFactory ...@@ -61,6 +61,12 @@ class MacOSXFactory: public OSFactory
/// Remove the icon from the system tray /// Remove the icon from the system tray
virtual void removeFromTray(); virtual void removeFromTray();
/// Show the task in the task bar
virtual void addInTaskBar();
/// Remove the task from the task bar
virtual void removeFromTaskBar();
/// Instantiate an OSWindow object /// Instantiate an OSWindow object
virtual OSWindow *createOSWindow( GenericWindow &rWindow, virtual OSWindow *createOSWindow( GenericWindow &rWindow,
bool dragDrop, bool playOnDrop, bool dragDrop, bool playOnDrop,
......
...@@ -90,6 +90,12 @@ class OSFactory: public SkinObject ...@@ -90,6 +90,12 @@ class OSFactory: public SkinObject
/// Remove the icon from the system tray /// Remove the icon from the system tray
virtual void removeFromTray() = 0; virtual void removeFromTray() = 0;
/// Show the task in the task bar
virtual void addInTaskBar() = 0;
/// Remove the task from the task bar
virtual void removeFromTaskBar() = 0;
/// Instantiate an OSTimer with the given command /// Instantiate an OSTimer with the given command
virtual OSTimer *createOSTimer( CmdGeneric &rCmd ) = 0; virtual OSTimer *createOSTimer( CmdGeneric &rCmd ) = 0;
......
...@@ -65,6 +65,9 @@ static int DemuxControl( demux_t *, int, va_list ); ...@@ -65,6 +65,9 @@ static int DemuxControl( demux_t *, int, va_list );
static int onSystrayChange( vlc_object_t *pObj, const char *pVariable, static int onSystrayChange( vlc_object_t *pObj, const char *pVariable,
vlc_value_t oldVal, vlc_value_t newVal, vlc_value_t oldVal, vlc_value_t newVal,
void *pParam ); void *pParam );
static int onTaskBarChange( vlc_object_t *pObj, const char *pVariable,
vlc_value_t oldVal, vlc_value_t newVal,
void *pParam );
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
...@@ -378,6 +381,35 @@ static int onSystrayChange( vlc_object_t *pObj, const char *pVariable, ...@@ -378,6 +381,35 @@ static int onSystrayChange( vlc_object_t *pObj, const char *pVariable,
} }
/// 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 )
{
intf_thread_t *pIntf =
(intf_thread_t*)vlc_object_find( pObj, VLC_OBJECT_INTF, FIND_ANYWHERE );
if( pIntf == NULL )
{
return VLC_EGENERIC;
}
AsyncQueue *pQueue = AsyncQueue::instance( pIntf );
if( newVal.b_bool )
{
CmdAddInTaskBar *pCmd = new CmdAddInTaskBar( pIntf );
pQueue->push( CmdGenericPtr( pCmd ) );
}
else
{
CmdRemoveFromTaskBar *pCmd = new CmdRemoveFromTaskBar( pIntf );
pQueue->push( CmdGenericPtr( pCmd ) );
}
vlc_object_release( pIntf );
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Module descriptor // Module descriptor
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
...@@ -388,6 +420,8 @@ static int onSystrayChange( vlc_object_t *pObj, const char *pVariable, ...@@ -388,6 +420,8 @@ static int onSystrayChange( vlc_object_t *pObj, const char *pVariable,
"This option is updated automatically, do not touch it." ) "This option is updated automatically, do not touch it." )
#define SKINS2_SYSTRAY N_("Systray icon") #define SKINS2_SYSTRAY N_("Systray icon")
#define SKINS2_SYSTRAY_LONG N_("Show a systray icon for VLC") #define SKINS2_SYSTRAY_LONG N_("Show a systray icon for VLC")
#define SKINS2_TASKBAR N_("Show VLC on the taskbar")
#define SKINS2_TASKBAR_LONG N_("Show VLC on the taskbar")
#define SKINS2_TRANSPARENCY N_("Enable transparency effects") #define SKINS2_TRANSPARENCY N_("Enable transparency effects")
#define SKINS2_TRANSPARENCY_LONG N_("You can disable all transparency effects"\ #define SKINS2_TRANSPARENCY_LONG N_("You can disable all transparency effects"\
" if you want. This is mainly useful when moving windows does not behave" \ " if you want. This is mainly useful when moving windows does not behave" \
...@@ -405,6 +439,8 @@ vlc_module_begin(); ...@@ -405,6 +439,8 @@ vlc_module_begin();
#ifdef WIN32 #ifdef WIN32
add_bool( "skins2-systray", VLC_FALSE, onSystrayChange, SKINS2_SYSTRAY, add_bool( "skins2-systray", VLC_FALSE, onSystrayChange, SKINS2_SYSTRAY,
SKINS2_SYSTRAY_LONG, VLC_FALSE ); 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, add_bool( "skins2-transparency", VLC_FALSE, NULL, SKINS2_TRANSPARENCY,
SKINS2_TRANSPARENCY_LONG, VLC_FALSE ); SKINS2_TRANSPARENCY_LONG, VLC_FALSE );
#endif #endif
......
...@@ -150,7 +150,7 @@ bool Win32Factory::init() ...@@ -150,7 +150,7 @@ bool Win32Factory::init()
} }
// Create Window // Create Window
m_hParentWindow = CreateWindowEx( WS_EX_APPWINDOW, _T("SkinWindowClass"), m_hParentWindow = CreateWindowEx( WS_EX_TOOLWINDOW, _T("SkinWindowClass"),
_T("VLC media player"), WS_SYSMENU|WS_POPUP, _T("VLC media player"), WS_SYSMENU|WS_POPUP,
-200, -200, 0, 0, 0, 0, m_hInst, 0 ); -200, -200, 0, 0, 0, 0, m_hInst, 0 );
if( m_hParentWindow == NULL ) if( m_hParentWindow == NULL )
...@@ -162,6 +162,14 @@ bool Win32Factory::init() ...@@ -162,6 +162,14 @@ bool Win32Factory::init()
// Store with it a pointer to the interface thread // Store with it a pointer to the interface thread
SetWindowLongPtr( m_hParentWindow, GWLP_USERDATA, (LONG_PTR)getIntf() ); SetWindowLongPtr( m_hParentWindow, GWLP_USERDATA, (LONG_PTR)getIntf() );
// We do it this way otherwise CreateWindowEx will fail
// if WS_EX_LAYERED is not supported
SetWindowLongPtr( m_hParentWindow, GWL_EXSTYLE,
GetWindowLong( m_hParentWindow, GWL_EXSTYLE ) |
WS_EX_LAYERED );
ShowWindow( m_hParentWindow, SW_SHOW );
// Initialize the systray icon // Initialize the systray icon
m_trayIcon.cbSize = sizeof( NOTIFYICONDATA ); m_trayIcon.cbSize = sizeof( NOTIFYICONDATA );
m_trayIcon.hWnd = m_hParentWindow; m_trayIcon.hWnd = m_hParentWindow;
...@@ -177,13 +185,11 @@ bool Win32Factory::init() ...@@ -177,13 +185,11 @@ bool Win32Factory::init()
addInTray(); addInTray();
} }
// We do it this way otherwise CreateWindowEx will fail // Show the task in the task bar if needed
// if WS_EX_LAYERED is not supported if( config_GetInt( getIntf(), "skins2-taskbar" ) )
SetWindowLongPtr( m_hParentWindow, GWL_EXSTYLE, {
GetWindowLong( m_hParentWindow, GWL_EXSTYLE ) | addInTaskBar();
WS_EX_LAYERED ); }
ShowWindow( m_hParentWindow, SW_SHOW );
// Initialize the OLE library (for drag & drop) // Initialize the OLE library (for drag & drop)
OleInitialize( NULL ); OleInitialize( NULL );
...@@ -296,6 +302,22 @@ void Win32Factory::removeFromTray() ...@@ -296,6 +302,22 @@ void Win32Factory::removeFromTray()
Shell_NotifyIcon( NIM_DELETE, &m_trayIcon ); Shell_NotifyIcon( NIM_DELETE, &m_trayIcon );
} }
void Win32Factory::addInTaskBar()
{
ShowWindow( m_hParentWindow, SW_HIDE );
SetWindowLongPtr( m_hParentWindow, GWL_EXSTYLE,
WS_EX_LAYERED|WS_EX_APPWINDOW );
ShowWindow( m_hParentWindow, SW_SHOW );
}
void Win32Factory::removeFromTaskBar()
{
ShowWindow( m_hParentWindow, SW_HIDE );
SetWindowLongPtr( m_hParentWindow, GWL_EXSTYLE,
WS_EX_LAYERED|WS_EX_TOOLWINDOW );
ShowWindow( m_hParentWindow, SW_SHOW );
}
OSTimer *Win32Factory::createOSTimer( CmdGeneric &rCmd ) OSTimer *Win32Factory::createOSTimer( CmdGeneric &rCmd )
{ {
return new Win32Timer( getIntf(), rCmd, m_hParentWindow ); return new Win32Timer( getIntf(), rCmd, m_hParentWindow );
......
...@@ -66,6 +66,12 @@ class Win32Factory: public OSFactory ...@@ -66,6 +66,12 @@ class Win32Factory: public OSFactory
/// Remove the icon from the system tray /// Remove the icon from the system tray
virtual void removeFromTray(); virtual void removeFromTray();
/// Show the task in the task bar
virtual void addInTaskBar();
/// Remove the task from the task bar
virtual void removeFromTaskBar();
/// Instantiate an OSTimer with the given command /// Instantiate an OSTimer with the given command
virtual OSTimer *createOSTimer( CmdGeneric &rCmd ); virtual OSTimer *createOSTimer( CmdGeneric &rCmd );
......
...@@ -118,6 +118,16 @@ void X11Factory::removeFromTray() ...@@ -118,6 +118,16 @@ void X11Factory::removeFromTray()
// TODO // TODO
} }
void X11Factory::addInTaskBar()
{
// TODO
}
void X11Factory::removeFromTaskBar()
{
// TODO
}
OSTimer *X11Factory::createOSTimer( CmdGeneric &rCmd ) OSTimer *X11Factory::createOSTimer( CmdGeneric &rCmd )
{ {
return new X11Timer( getIntf(), rCmd ); return new X11Timer( getIntf(), rCmd );
......
...@@ -74,6 +74,12 @@ class X11Factory: public OSFactory ...@@ -74,6 +74,12 @@ class X11Factory: public OSFactory
/// Remove the icon from the system tray /// Remove the icon from the system tray
virtual void removeFromTray(); virtual void removeFromTray();
/// Show the task in the task bar
virtual void addInTaskBar();
/// Remove the task from the task bar
virtual void removeFromTaskBar();
/// Instantiate an OSWindow object /// Instantiate an OSWindow object
virtual OSWindow *createOSWindow( GenericWindow &rWindow, virtual OSWindow *createOSWindow( GenericWindow &rWindow,
bool dragDrop, bool playOnDrop, bool dragDrop, bool playOnDrop,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment