]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins2/win32/win32_factory.cpp
Add --data-path option. Access the src share directory now works from build tree.
[vlc] / modules / gui / skins2 / win32 / win32_factory.cpp
index b94227b0bf4ce2d1b3283b2e42d673a9b69744ce..e7bbf66952b11dc9873c403ed1b44ac65653e829 100644 (file)
 #include "win32_loop.hpp"
 #include "../src/theme.hpp"
 #include "../src/window_manager.hpp"
+#include "../src/generic_window.hpp"
 #include "../commands/cmd_dialogs.hpp"
 #include "../commands/cmd_minimize.hpp"
 
 // Custom message for the notifications of the system tray
-#define MY_WSTRAYACTION (WM_APP + 1)
+#define MY_WM_TRAYACTION (WM_APP + 1)
 
 
 LRESULT CALLBACK Win32Proc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
@@ -73,14 +74,11 @@ LRESULT CALLBACK Win32Proc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
             }
             else
             {
-                msg_Err( p_intf, "WM_SYSCOMMAND %i", wParam );
+                msg_Dbg( p_intf, "WM_SYSCOMMAND %i", wParam );
             }
-//            if( (Event *)wParam != NULL )
-//                ( (Event *)wParam )->SendEvent();
-//            return 0;
         }
         // Handle systray notifications
-        else if( uMsg == MY_WSTRAYACTION )
+        else if( uMsg == MY_WM_TRAYACTION )
         {
             if( (UINT)lParam == WM_LBUTTONDOWN )
             {
@@ -150,7 +148,7 @@ bool Win32Factory::init()
     }
 
     // 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,
         -200, -200, 0, 0, 0, 0, m_hInst, 0 );
     if( m_hParentWindow == NULL )
@@ -162,12 +160,20 @@ bool Win32Factory::init()
     // Store with it a pointer to the interface thread
     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
     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.uCallbackMessage = MY_WM_TRAYACTION;
     m_trayIcon.hIcon = LoadIcon( m_hInst, _T("VLC_ICON") );
     strcpy( m_trayIcon.szTip, "VLC media player" );
 
@@ -177,13 +183,11 @@ bool Win32Factory::init()
         addInTray();
     }
 
-    // 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 );
+    // Show the task in the task bar if needed
+    if( config_GetInt( getIntf(), "skins2-taskbar" ) )
+    {
+        addInTaskBar();
+    }
 
     // Initialize the OLE library (for drag & drop)
     OleInitialize( NULL );
@@ -222,16 +226,15 @@ bool Win32Factory::init()
     }
 
     // Initialize the resource path
-    m_resourcePath.push_back( (string)getIntf()->p_vlc->psz_homedir +
-                               "\\" + CONFIG_DIR + "\\skins" );
-    m_resourcePath.push_back( (string)getIntf()->p_libvlc->psz_vlcpath +
-                              "\\skins" );
-    m_resourcePath.push_back( (string)getIntf()->p_libvlc->psz_vlcpath +
-                              "\\skins2" );
-    m_resourcePath.push_back( (string)getIntf()->p_libvlc->psz_vlcpath +
-                              "\\share\\skins" );
-    m_resourcePath.push_back( (string)getIntf()->p_libvlc->psz_vlcpath +
-                              "\\share\\skins2" );
+    char *datadir = config_GetUserDir( VLC_DATA_DIR );
+    m_resourcePath.push_back( (string)datadir + "\\skins" );
+    free( datadir );
+    datadir = config_GetDataDir( getIntf() );
+    m_resourcePath.push_back( (string)datadir + "\\skins" );
+    m_resourcePath.push_back( (string)datadir + "\\skins2" );
+    m_resourcePath.push_back( (string)datadir + "\\share\\skins" );
+    m_resourcePath.push_back( (string)datadir + "\\share\\skins2" );
+    free( datadir );
 
     // All went well
     return true;
@@ -296,6 +299,22 @@ void Win32Factory::removeFromTray()
     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 )
 {
     return new Win32Timer( getIntf(), rCmd, m_hParentWindow );
@@ -303,7 +322,8 @@ OSTimer *Win32Factory::createOSTimer( CmdGeneric &rCmd )
 
 
 OSWindow *Win32Factory::createOSWindow( GenericWindow &rWindow, bool dragDrop,
-                                        bool playOnDrop, OSWindow *pParent )
+                                        bool playOnDrop, OSWindow *pParent,
+                                        GenericWindow::WindowType_t type )
 {
     return new Win32Window( getIntf(), rWindow, m_hInst, m_hParentWindow,
                             dragDrop, playOnDrop, (Win32Window*)pParent );
@@ -346,13 +366,12 @@ int Win32Factory::getScreenHeight() const
 }
 
 
-Rect Win32Factory::getWorkArea() const
+SkinsRect Win32Factory::getWorkArea() const
 {
     RECT r;
     SystemParametersInfo( SPI_GETWORKAREA, 0, &r, 0 );
     // Fill a Rect object
-    Rect rect( r.left, r.top, r.right, r.bottom );
-    return rect;
+    return  SkinsRect( r.left, r.top, r.right, r.bottom );
 }
 
 
@@ -370,24 +389,12 @@ void Win32Factory::changeCursor( CursorType_t type ) const
     LPCTSTR id;
     switch( type )
     {
-        case kDefaultArrow:
-            id = IDC_ARROW;
-            break;
-        case kResizeNWSE:
-            id = IDC_SIZENWSE;
-            break;
-        case kResizeNS:
-            id = IDC_SIZENS;
-            break;
-        case kResizeWE:
-            id = IDC_SIZEWE;
-            break;
-        case kResizeNESW:
-            id = IDC_SIZENESW;
-            break;
-        default:
-            id = IDC_ARROW;
-            break;
+    default:
+    case kDefaultArrow: id = IDC_ARROW;    break;
+    case kResizeNWSE:   id = IDC_SIZENWSE; break;
+    case kResizeNS:     id = IDC_SIZENS;   break;
+    case kResizeWE:     id = IDC_SIZEWE;   break;
+    case kResizeNESW:   id = IDC_SIZENESW; break;
     }
 
     HCURSOR hCurs = LoadCursor( NULL, id );