Commit 660cc33f authored by ipkiss's avatar ipkiss
Browse files

* 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 )
#define SKINS2_LAST N_("Skin to use")
#define SKINS2_LAST_LONG N_("Path to the skin to use.")
#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 used. " \
"This option is updated automatically by the skins module." )
#define SKINS2_CONFIG_LONG N_("Windows configuration of the last skin used. " \
"This option is updated automatically, do not touch it." )
#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_LONG N_("You can disable all transparency effects"\
" if you want. This is mainly useful when moving windows does not behave" \
......@@ -362,6 +362,8 @@ vlc_module_begin();
VLC_TRUE );
change_autosave();
#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,
SKINS2_TRANSPARENCY_LONG, VLC_FALSE );
#endif
......
......@@ -32,6 +32,11 @@
#include "win32_popup.hpp"
#include "win32_loop.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 )
......@@ -73,6 +78,23 @@ LRESULT CALLBACK Win32Proc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
// ( (Event *)wParam )->SendEvent();
// 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
......@@ -135,14 +157,30 @@ bool Win32Factory::init()
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
// if WS_EX_LAYERED is not supported
SetWindowLongPtr( m_hParentWindow, GWL_EXSTYLE,
GetWindowLong( m_hParentWindow, GWL_EXSTYLE ) |
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 );
// Initialize the OLE library (for drag & drop)
......@@ -203,6 +241,9 @@ Win32Factory::~Win32Factory()
// Uninitialize the OLE library
OleUninitialize();
// Remove the systray icon
Shell_NotifyIcon( NIM_DELETE, &m_trayIcon );
if( m_hParentWindow ) DestroyWindow( m_hParentWindow );
// Unload msimg32.dll and user32.dll
......@@ -264,7 +305,7 @@ OSPopup *Win32Factory::createOSPopup()
// In fact, the clean way would be to have in Builder::addPopup() a call
// to pPopup->associateToWindow() (to be written)... but the problem is
// 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() )
{
msg_Err( getIntf(), "no window has been created before the popup!" );
......
......@@ -30,6 +30,7 @@
#endif
#include <windows.h>
#include <shellapi.h>
#include "../src/os_factory.hpp"
#include <map>
......@@ -113,6 +114,8 @@ class Win32Factory: public OSFactory
HINSTANCE m_hInst;
/// Handle of the parent window
HWND m_hParentWindow;
/// Structure for the system tray
NOTIFYICONDATA m_trayIcon;
/// Handle on msimg32.dll (for TransparentBlt)
HINSTANCE m_hMsimg32;
/// 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