Commit 660cc33f authored by Olivier Teulière's avatar Olivier Teulière

* skins2: new skins2-systray option on Windows to activate an icon in the system tray

parent 0603924b
...@@ -343,10 +343,10 @@ static int DemuxControl( demux_t *p_demux, int i_query, va_list args ) ...@@ -343,10 +343,10 @@ static int DemuxControl( demux_t *p_demux, int i_query, va_list args )
#define SKINS2_LAST N_("Skin to use") #define SKINS2_LAST N_("Skin to use")
#define SKINS2_LAST_LONG N_("Path to the skin to use.") #define SKINS2_LAST_LONG N_("Path to the skin to use.")
#define SKINS2_CONFIG N_("Config of last used skin") #define SKINS2_CONFIG N_("Config of last used skin")
/// \bug [String] missing "skin". Remove "by the skins module". Add "do not touch" #define SKINS2_CONFIG_LONG N_("Windows configuration of the last skin used. " \
#define SKINS2_CONFIG_LONG N_("Windows configuration of the last used. " \ "This option is updated automatically, do not touch it." )
"This option is updated automatically by the skins module." ) #define SKINS2_SYSTRAY N_("Systray icon")
#define SKINS2_SYSTRAY_LONG N_("Show a systray icon for VLC")
#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" \
...@@ -362,6 +362,8 @@ vlc_module_begin(); ...@@ -362,6 +362,8 @@ vlc_module_begin();
VLC_TRUE ); VLC_TRUE );
change_autosave(); change_autosave();
#ifdef WIN32 #ifdef WIN32
add_bool( "skins2-systray", VLC_FALSE, NULL, SKINS2_SYSTRAY,
SKINS2_SYSTRAY_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
......
...@@ -32,6 +32,11 @@ ...@@ -32,6 +32,11 @@
#include "win32_popup.hpp" #include "win32_popup.hpp"
#include "win32_loop.hpp" #include "win32_loop.hpp"
#include "../src/theme.hpp" #include "../src/theme.hpp"
#include "../src/window_manager.hpp"
#include "commands/cmd_dialogs.hpp"
// Custom message for the notifications of the system tray
#define MY_WSTRAYACTION (WM_APP + 1)
LRESULT CALLBACK Win32Proc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) LRESULT CALLBACK Win32Proc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
...@@ -73,6 +78,23 @@ LRESULT CALLBACK Win32Proc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) ...@@ -73,6 +78,23 @@ LRESULT CALLBACK Win32Proc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
// ( (Event *)wParam )->SendEvent(); // ( (Event *)wParam )->SendEvent();
// return 0; // return 0;
} }
// Handle systray notifications
else if( uMsg == MY_WSTRAYACTION )
{
if( (UINT)lParam == WM_LBUTTONDOWN )
{
p_intf->p_sys->p_theme->getWindowManager().raiseAll();
}
else if( (UINT)lParam == WM_RBUTTONDOWN )
{
CmdDlgShowPopupMenu aCmdPopup( p_intf );
aCmdPopup.execute();
}
else if( (UINT)lParam == WM_LBUTTONDBLCLK )
{
ShowWindow( hwnd, SW_RESTORE );
}
}
} }
// If hwnd does not match any window or message not processed // If hwnd does not match any window or message not processed
...@@ -135,14 +157,30 @@ bool Win32Factory::init() ...@@ -135,14 +157,30 @@ bool Win32Factory::init()
return false; return false;
} }
// Store with it a pointer to the interface thread
SetWindowLongPtr( m_hParentWindow, GWLP_USERDATA, (LONG_PTR)getIntf() );
// Initialize the systray icon
m_trayIcon.cbSize = sizeof( NOTIFYICONDATA );
m_trayIcon.hWnd = m_hParentWindow;
m_trayIcon.uID = 42;
m_trayIcon.uFlags = NIF_ICON|NIF_TIP|NIF_MESSAGE;
m_trayIcon.uCallbackMessage = MY_WSTRAYACTION;
m_trayIcon.hIcon = LoadIcon( m_hInst, _T("VLC_ICON") );
strcpy( m_trayIcon.szTip, "VLC media player" );
// Show the systray icon if needed
if( config_GetInt( getIntf(), "skins2-systray" ) )
{
Shell_NotifyIcon( NIM_ADD, &m_trayIcon );
}
// We do it this way otherwise CreateWindowEx will fail // We do it this way otherwise CreateWindowEx will fail
// if WS_EX_LAYERED is not supported // if WS_EX_LAYERED is not supported
SetWindowLongPtr( m_hParentWindow, GWL_EXSTYLE, SetWindowLongPtr( m_hParentWindow, GWL_EXSTYLE,
GetWindowLong( m_hParentWindow, GWL_EXSTYLE ) | GetWindowLong( m_hParentWindow, GWL_EXSTYLE ) |
WS_EX_LAYERED ); WS_EX_LAYERED );
// Store with it a pointer to the interface thread
SetWindowLongPtr( m_hParentWindow, GWLP_USERDATA, (LONG_PTR)getIntf() );
ShowWindow( m_hParentWindow, SW_SHOW ); ShowWindow( m_hParentWindow, SW_SHOW );
// Initialize the OLE library (for drag & drop) // Initialize the OLE library (for drag & drop)
...@@ -203,6 +241,9 @@ Win32Factory::~Win32Factory() ...@@ -203,6 +241,9 @@ Win32Factory::~Win32Factory()
// Uninitialize the OLE library // Uninitialize the OLE library
OleUninitialize(); OleUninitialize();
// Remove the systray icon
Shell_NotifyIcon( NIM_DELETE, &m_trayIcon );
if( m_hParentWindow ) DestroyWindow( m_hParentWindow ); if( m_hParentWindow ) DestroyWindow( m_hParentWindow );
// Unload msimg32.dll and user32.dll // Unload msimg32.dll and user32.dll
...@@ -264,7 +305,7 @@ OSPopup *Win32Factory::createOSPopup() ...@@ -264,7 +305,7 @@ OSPopup *Win32Factory::createOSPopup()
// In fact, the clean way would be to have in Builder::addPopup() a call // In fact, the clean way would be to have in Builder::addPopup() a call
// to pPopup->associateToWindow() (to be written)... but the problem is // to pPopup->associateToWindow() (to be written)... but the problem is
// that there is no way to access the OS-dependent window handle from a // that there is no way to access the OS-dependent window handle from a
// GenericWindow (we cannot eevn access the OSWindow). // GenericWindow (we cannot even access the OSWindow).
if( m_windowMap.begin() == m_windowMap.end() ) if( m_windowMap.begin() == m_windowMap.end() )
{ {
msg_Err( getIntf(), "no window has been created before the popup!" ); msg_Err( getIntf(), "no window has been created before the popup!" );
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#endif #endif
#include <windows.h> #include <windows.h>
#include <shellapi.h>
#include "../src/os_factory.hpp" #include "../src/os_factory.hpp"
#include <map> #include <map>
...@@ -113,6 +114,8 @@ class Win32Factory: public OSFactory ...@@ -113,6 +114,8 @@ class Win32Factory: public OSFactory
HINSTANCE m_hInst; HINSTANCE m_hInst;
/// Handle of the parent window /// Handle of the parent window
HWND m_hParentWindow; HWND m_hParentWindow;
/// Structure for the system tray
NOTIFYICONDATA m_trayIcon;
/// Handle on msimg32.dll (for TransparentBlt) /// Handle on msimg32.dll (for TransparentBlt)
HINSTANCE m_hMsimg32; HINSTANCE m_hMsimg32;
/// Handle on user32.dll (for SetLayeredWindowAttributes) /// Handle on user32.dll (for SetLayeredWindowAttributes)
......
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