diff --git a/reactos/lib/user32/include/user32.h b/reactos/lib/user32/include/user32.h index ddc9630a300..cf58bbfd788 100644 --- a/reactos/lib/user32/include/user32.h +++ b/reactos/lib/user32/include/user32.h @@ -6,3 +6,11 @@ */ #include #include + +typedef struct _USER32_THREAD_DATA +{ + MSG LastMessage; +} USER32_THREAD_DATA, *PUSER32_THREAD_DATA; + +PUSER32_THREAD_DATA +User32GetThreadData(); diff --git a/reactos/lib/user32/misc/dllmain.c b/reactos/lib/user32/misc/dllmain.c index 507d543f89e..190ea2e79a2 100644 --- a/reactos/lib/user32/misc/dllmain.c +++ b/reactos/lib/user32/misc/dllmain.c @@ -4,6 +4,7 @@ #include #include #include +#include #ifdef DBG @@ -12,11 +13,39 @@ DWORD DebugTraceLevel = MIN_TRACE; #endif /* DBG */ +static ULONG User32TlsIndex; + /* To make the linker happy */ VOID STDCALL KeBugCheck (ULONG BugCheckCode) {} HWINSTA ProcessWindowStation; +PUSER32_THREAD_DATA +User32GetThreadData() +{ + return((PUSER32_THREAD_DATA)TlsGetValue(User32TlsIndex)); +} + +VOID +InitThread(VOID) +{ + PUSER32_THREAD_DATA ThreadData; + + ThreadData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, + sizeof(USER32_THREAD_DATA)); + TlsSetValue(User32TlsIndex, ThreadData); +} + +VOID +CleanupThread(VOID) +{ + PUSER32_THREAD_DATA ThreadData; + + ThreadData = (PUSER32_THREAD_DATA)TlsGetValue(User32TlsIndex); + HeapFree(GetProcessHeap(), HEAP_ZERO_MEMORY, ThreadData); + TlsSetValue(User32TlsIndex, 0); +} + DWORD Init(VOID) { @@ -44,6 +73,9 @@ Init(VOID) NtCurrentPeb()->KernelCallbackTable[USER32_CALLBACK_SENDSTYLECHANGED] = (PVOID)User32SendSTYLECHANGEDMessageForKernel; + /* Allocate an index for user32 thread local data. */ + User32TlsIndex = TlsAlloc(); + UserSetupInternalPos(); MenuInit(); @@ -61,9 +93,13 @@ Cleanup(VOID) GdiDllInitialize(NULL, DLL_PROCESS_DETACH, NULL); + TlsFree(User32TlsIndex); + return(Status); } + + INT STDCALL DllMain(PVOID hinstDll, ULONG dwReason, @@ -75,12 +111,16 @@ DllMain(PVOID hinstDll, { case DLL_PROCESS_ATTACH: Init(); + InitThread(); break; case DLL_THREAD_ATTACH: + InitThread(); break; case DLL_THREAD_DETACH: + CleanupThread(); break; case DLL_PROCESS_DETACH: + CleanupThread(); Cleanup(); break; } diff --git a/reactos/lib/user32/windows/message.c b/reactos/lib/user32/windows/message.c index 275a8fabff4..e0651e63bec 100644 --- a/reactos/lib/user32/windows/message.c +++ b/reactos/lib/user32/windows/message.c @@ -1,4 +1,4 @@ -/* $Id: message.c,v 1.20 2003/07/30 19:36:36 hbirr Exp $ +/* $Id: message.c,v 1.21 2003/08/01 18:45:35 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS user32.dll @@ -13,9 +13,8 @@ #include #include - /* - * @unimplemented + * @implemented */ LPARAM STDCALL @@ -27,26 +26,25 @@ GetMessageExtraInfo(VOID) /* - * @unimplemented + * @implemented */ DWORD STDCALL GetMessagePos(VOID) { - UNIMPLEMENTED; - return 0; + PUSER32_THREAD_DATA ThreadData = User32GetThreadData(); + return(MAKELONG(ThreadData->LastMessage.pt.x, ThreadData->LastMessage.pt.y)); } /* - * @unimplemented + * @implemented */ -LONG -STDCALL +LONG STDCALL GetMessageTime(VOID) { - UNIMPLEMENTED; - return 0; + PUSER32_THREAD_DATA ThreadData = User32GetThreadData(); + return(ThreadData->LastMessage.time); } @@ -351,46 +349,64 @@ DispatchMessageW(CONST MSG *lpmsg) /* * @implemented */ -WINBOOL -STDCALL -GetMessageA( - LPMSG lpMsg, - HWND hWnd, - UINT wMsgFilterMin, - UINT wMsgFilterMax) +WINBOOL STDCALL +GetMessageA(LPMSG lpMsg, + HWND hWnd, + UINT wMsgFilterMin, + UINT wMsgFilterMax) { - return NtUserGetMessage(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax); + BOOL Res; + PUSER32_THREAD_DATA ThreadData = User32GetThreadData(); + + Res = NtUserGetMessage(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax); + if (Res && lpMsg->message != WM_PAINT && lpMsg->message != WM_QUIT) + { + ThreadData->LastMessage = *lpMsg; + } + return(Res); } /* * @implemented */ -WINBOOL -STDCALL -GetMessageW( - LPMSG lpMsg, - HWND hWnd, - UINT wMsgFilterMin, - UINT wMsgFilterMax) +WINBOOL STDCALL +GetMessageW(LPMSG lpMsg, + HWND hWnd, + UINT wMsgFilterMin, + UINT wMsgFilterMax) { - return NtUserGetMessage(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax); + BOOL Res; + PUSER32_THREAD_DATA ThreadData = User32GetThreadData(); + + Res = NtUserGetMessage(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax); + if (Res && lpMsg->message != WM_PAINT && lpMsg->message != WM_QUIT) + { + ThreadData->LastMessage = *lpMsg; + } + return(Res); } /* * @implemented */ -WINBOOL -STDCALL -PeekMessageA( - LPMSG lpMsg, - HWND hWnd, - UINT wMsgFilterMin, - UINT wMsgFilterMax, - UINT wRemoveMsg) +WINBOOL STDCALL +PeekMessageA(LPMSG lpMsg, + HWND hWnd, + UINT wMsgFilterMin, + UINT wMsgFilterMax, + UINT wRemoveMsg) { - return NtUserPeekMessage(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg); + BOOL Res; + PUSER32_THREAD_DATA ThreadData = User32GetThreadData(); + + Res = NtUserPeekMessage(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg); + if (Res && lpMsg->message != WM_PAINT && lpMsg->message != WM_QUIT) + { + ThreadData->LastMessage = *lpMsg; + } + return(Res); } @@ -406,7 +422,15 @@ PeekMessageW( UINT wMsgFilterMax, UINT wRemoveMsg) { - return NtUserPeekMessage(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg); + BOOL Res; + PUSER32_THREAD_DATA ThreadData = User32GetThreadData(); + + Res = NtUserPeekMessage(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg); + if (Res && lpMsg->message != WM_PAINT && lpMsg->message != WM_QUIT) + { + ThreadData->LastMessage = *lpMsg; + } + return(Res); }