Commit a66bbe1e authored by Erwan Tulou's avatar Erwan Tulou

skins(Win32): Process events in the winProc (instead of the message loop)

Events like WM_PAINT should be processed in the WinProc, because
some functions directly call the WinProc (e.g UpdateWindow())
parent a38c6d0f
...@@ -45,7 +45,8 @@ ...@@ -45,7 +45,8 @@
#define MY_WM_TRAYACTION (WM_APP + 1) #define MY_WM_TRAYACTION (WM_APP + 1)
LRESULT CALLBACK Win32Proc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) LRESULT CALLBACK Win32Factory::Win32Proc( HWND hwnd, UINT uMsg,
WPARAM wParam, LPARAM lParam )
{ {
// Get pointer to thread info: should only work with the parent window // Get pointer to thread info: should only work with the parent window
intf_thread_t *p_intf = (intf_thread_t *)GetWindowLongPtr( hwnd, intf_thread_t *p_intf = (intf_thread_t *)GetWindowLongPtr( hwnd,
...@@ -58,6 +59,7 @@ LRESULT CALLBACK Win32Proc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) ...@@ -58,6 +59,7 @@ LRESULT CALLBACK Win32Proc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
} }
Win32Factory *pFactory = (Win32Factory*)Win32Factory::instance( p_intf ); Win32Factory *pFactory = (Win32Factory*)Win32Factory::instance( p_intf );
GenericWindow *pWin = pFactory->m_windowMap[hwnd];
if( hwnd == pFactory->getParentWindow() ) if( hwnd == pFactory->getParentWindow() )
{ {
...@@ -92,19 +94,29 @@ LRESULT CALLBACK Win32Proc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) ...@@ -92,19 +94,29 @@ LRESULT CALLBACK Win32Proc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
p_intf->p_sys->p_theme->getWindowManager().raiseAll(); p_intf->p_sys->p_theme->getWindowManager().raiseAll();
CmdDlgHidePopupMenu aCmdPopup( p_intf ); CmdDlgHidePopupMenu aCmdPopup( p_intf );
aCmdPopup.execute(); aCmdPopup.execute();
return 0;
} }
else if( (UINT)lParam == WM_RBUTTONDOWN ) else if( (UINT)lParam == WM_RBUTTONDOWN )
{ {
CmdDlgShowPopupMenu aCmdPopup( p_intf ); CmdDlgShowPopupMenu aCmdPopup( p_intf );
aCmdPopup.execute(); aCmdPopup.execute();
return 0;
} }
else if( (UINT)lParam == WM_LBUTTONDBLCLK ) else if( (UINT)lParam == WM_LBUTTONDBLCLK )
{ {
CmdRestore aCmdRestore( p_intf ); CmdRestore aCmdRestore( p_intf );
aCmdRestore.execute(); 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 // If hwnd does not match any window or message not processed
return DefWindowProc( hwnd, uMsg, wParam, lParam ); return DefWindowProc( hwnd, uMsg, wParam, lParam );
...@@ -131,7 +143,7 @@ bool Win32Factory::init() ...@@ -131,7 +143,7 @@ bool Win32Factory::init()
// Create window class // Create window class
WNDCLASS skinWindowClass; WNDCLASS skinWindowClass;
skinWindowClass.style = CS_DBLCLKS; skinWindowClass.style = CS_DBLCLKS;
skinWindowClass.lpfnWndProc = (WNDPROC) Win32Proc; skinWindowClass.lpfnWndProc = (WNDPROC)Win32Factory::Win32Proc;
skinWindowClass.lpszClassName = _T("SkinWindowClass"); skinWindowClass.lpszClassName = _T("SkinWindowClass");
skinWindowClass.lpszMenuName = NULL; skinWindowClass.lpszMenuName = NULL;
skinWindowClass.cbClsExtra = 0; skinWindowClass.cbClsExtra = 0;
...@@ -325,7 +337,6 @@ OSPopup *Win32Factory::createOSPopup() ...@@ -325,7 +337,6 @@ OSPopup *Win32Factory::createOSPopup()
int Win32Factory::getScreenWidth() const int Win32Factory::getScreenWidth() const
{ {
return GetSystemMetrics(SM_CXSCREEN); return GetSystemMetrics(SM_CXSCREEN);
} }
......
...@@ -118,6 +118,10 @@ public: ...@@ -118,6 +118,10 @@ public:
HWND getParentWindow() { return m_hParentWindow; } HWND getParentWindow() { return m_hParentWindow; }
/// Callback function (Windows Procedure)
static LRESULT CALLBACK Win32Proc( HWND hwnd, UINT uMsg,
WPARAM wParam, LPARAM lParam );
private: private:
/// Handle of the instance /// Handle of the instance
HINSTANCE m_hInst; HINSTANCE m_hInst;
......
This diff is collapsed.
...@@ -48,6 +48,10 @@ public: ...@@ -48,6 +48,10 @@ public:
/// Exit the main loop /// Exit the main loop
virtual void exit(); virtual void exit();
/// called by the window procedure callback
virtual LRESULT CALLBACK processEvent( HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam );
private: private:
// Private because it is a singleton // Private because it is a singleton
Win32Loop( intf_thread_t *pIntf ); Win32Loop( intf_thread_t *pIntf );
......
...@@ -69,8 +69,10 @@ Win32Window::Win32Window( intf_thread_t *pIntf, GenericWindow &rWindow, ...@@ -69,8 +69,10 @@ Win32Window::Win32Window( intf_thread_t *pIntf, GenericWindow &rWindow,
m_hWnd = CreateWindowEx( WS_EX_APPWINDOW, "SkinWindowClass", m_hWnd = CreateWindowEx( WS_EX_APPWINDOW, "SkinWindowClass",
"default name", WS_POPUP | WS_CLIPCHILDREN, "default name", WS_POPUP | WS_CLIPCHILDREN,
0, 0, 0, 0, NULL, 0, hInst, NULL ); 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 else
{ {
// top-level window (owned by the root window) // top-level window (owned by the root window)
...@@ -78,6 +80,9 @@ Win32Window::Win32Window( intf_thread_t *pIntf, GenericWindow &rWindow, ...@@ -78,6 +80,9 @@ Win32Window::Win32Window( intf_thread_t *pIntf, GenericWindow &rWindow,
m_hWnd = CreateWindowEx( 0, "SkinWindowClass", m_hWnd = CreateWindowEx( 0, "SkinWindowClass",
"default name", WS_POPUP | WS_CLIPCHILDREN, "default name", WS_POPUP | WS_CLIPCHILDREN,
0, 0, 0, 0, hWnd_owner, 0, hInst, NULL ); 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 ) if( !m_hWnd )
......
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