LRESULT CALLBACK Win32Factory::Win32Proc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { // Get pointer to thread info: should only work with the parent window intf_thread_t *p_intf = (intf_thread_t *)GetWindowLongPtr( hwnd, GWLP_USERDATA ); // If doesn't exist, treat windows message normally if( p_intf == NULL || p_intf->p_sys->p_osFactory == NULL ) { return DefWindowProc( hwnd, uMsg, wParam, lParam ); } Win32Factory *pFactory = (Win32Factory*)Win32Factory::instance( p_intf ); GenericWindow *pWin = pFactory->m_windowMap[hwnd]; if( hwnd == pFactory->getParentWindow() ) { if( uMsg == WM_SYSCOMMAND ) { // If closing parent window if( (wParam & 0xFFF0) == SC_CLOSE ) { libvlc_Quit( vlc_object_instance(p_intf) ); return 0; } else if( (wParam & 0xFFF0) == SC_MINIMIZE ) { pFactory->minimize(); return 0; } else if( (wParam & 0xFFF0) == SC_RESTORE ) { pFactory->restore(); return 0; } else { msg_Dbg( p_intf, "WM_SYSCOMMAND %i", (wParam & 0xFFF0) ); } } // Handle systray notifications else if( uMsg == MY_WM_TRAYACTION ) { if( (UINT)lParam == WM_LBUTTONDOWN ) { p_intf->p_sys->p_theme->getWindowManager().raiseAll(); CmdDlgHidePopupMenu aCmdPopup( p_intf ); aCmdPopup.execute(); return 0; } else if( (UINT)lParam == WM_RBUTTONDOWN ) { CmdDlgShowPopupMenu aCmdPopup( p_intf ); aCmdPopup.execute(); return 0; } else if( (UINT)lParam == WM_LBUTTONDBLCLK ) { CmdRestore aCmdRestore( p_intf ); aCmdRestore.execute(); return 0; } } } else if( pWin ) { Win32Loop* pLoop = (Win32Loop*) OSFactory::instance( p_intf )->getOSLoop(); if( pLoop ) return pLoop->processEvent( hwnd, uMsg, wParam, lParam ); } // If hwnd does not match any window or message not processed return DefWindowProc( hwnd, uMsg, wParam, lParam ); }
Win32Window::Win32Window( intf_thread_t *pIntf, GenericWindow &rWindow, HINSTANCE hInst, HWND hParentWindow, bool dragDrop, bool playOnDrop, Win32Window *pParentWindow, GenericWindow::WindowType_t type ): OSWindow( pIntf ), m_dragDrop( dragDrop ), m_isLayered( false ), m_pParent( pParentWindow ), m_type ( type ) { (void)hParentWindow; Win32Factory *pFactory = (Win32Factory*)Win32Factory::instance( getIntf() ); const char* vlc_name = "VlC Media Player"; const char* vlc_class = "SkinWindowClass"; // Create the window if( type == GenericWindow::VoutWindow ) { // Child window (for vout) m_hWnd_parent = pParentWindow->getHandle(); m_hWnd = CreateWindowEx( WS_EX_TOOLWINDOW | WS_EX_NOPARENTNOTIFY, vlc_class, vlc_name, WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0, 0, 0, 0, m_hWnd_parent, 0, hInst, NULL ); } else if( type == GenericWindow::FullscreenWindow ) { // top-level window m_hWnd = CreateWindowEx( WS_EX_APPWINDOW, vlc_class, vlc_name, WS_POPUP | WS_CLIPCHILDREN, 0, 0, 0, 0, NULL, 0, hInst, NULL ); // Store with it a pointer to the interface thread SetWindowLongPtr( m_hWnd, GWLP_USERDATA, (LONG_PTR)getIntf() ); } else if( type == GenericWindow::FscWindow ) { VoutManager* pVoutManager = VoutManager::instance( getIntf() ); GenericWindow* pParent = (GenericWindow*)pVoutManager->getVoutMainWindow(); m_hWnd_parent = (HWND)pParent->getOSHandle(); // top-level window m_hWnd = CreateWindowEx( WS_EX_APPWINDOW, vlc_class, vlc_name, WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0, 0, 0, 0, m_hWnd_parent, 0, hInst, NULL ); // Store with it a pointer to the interface thread SetWindowLongPtr( m_hWnd, GWLP_USERDATA, (LONG_PTR)getIntf() ); } else { // top-level window (owned by the root window) HWND hWnd_owner = pFactory->getParentWindow(); m_hWnd = CreateWindowEx( 0, vlc_class, vlc_name, WS_POPUP | WS_CLIPCHILDREN, 0, 0, 0, 0, hWnd_owner, 0, hInst, NULL ); // Store with it a pointer to the interface thread SetWindowLongPtr( m_hWnd, GWLP_USERDATA, (LONG_PTR)getIntf() ); } if( !m_hWnd ) { msg_Err( getIntf(), "CreateWindow failed" ); return; } // Store a pointer to the GenericWindow in a map pFactory->m_windowMap[m_hWnd] = &rWindow; // Drag & drop if( m_dragDrop ) { m_pDropTarget = (LPDROPTARGET) new Win32DragDrop( getIntf(), playOnDrop, &rWindow ); // Register the window as a drop target RegisterDragDrop( m_hWnd, m_pDropTarget ); } }