From ef1f9bd06cdc5aebdcfd49ea4465fc6f18bc8213 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Tue, 8 Jul 2008 18:58:07 +0000 Subject: [PATCH] Win32k/User32: - Removed NtUserGetSystemMetric, updated all related. - Add GetConnected, this is needed, sometimes global pointers are initilized with zeros. This is normal. - Fix prototype for NtUserDragDetect, and add the Esc key hit to DragDetect. svn path=/trunk/; revision=34370 --- reactos/dll/win32/user32/include/user32.h | 1 + reactos/dll/win32/user32/misc/desktop.c | 6 ++--- reactos/dll/win32/user32/misc/dllmain.c | 22 ++++++++++++++++++ reactos/dll/win32/user32/windows/input.c | 23 ++++++++++++++----- reactos/include/reactos/win32k/ntuser.h | 7 +----- .../subsystems/win32/win32k/ntuser/input.c | 3 +-- .../subsystems/win32/win32k/ntuser/metric.c | 16 ------------- 7 files changed, 44 insertions(+), 34 deletions(-) diff --git a/reactos/dll/win32/user32/include/user32.h b/reactos/dll/win32/user32/include/user32.h index d9326de106d..976241bce63 100644 --- a/reactos/dll/win32/user32/include/user32.h +++ b/reactos/dll/win32/user32/include/user32.h @@ -115,3 +115,4 @@ PWINDOW FASTCALL ValidateHwndOrDesk(HWND hwnd); PWINDOW FASTCALL GetThreadDesktopWnd(VOID); PVOID FASTCALL ValidateHandleNoErr(HANDLE handle, UINT uType); PWINDOW FASTCALL ValidateHwndNoErr(HWND hwnd); +VOID FASTCALL GetConnected(VOID); diff --git a/reactos/dll/win32/user32/misc/desktop.c b/reactos/dll/win32/user32/misc/desktop.c index bca1a8db6dc..93e1e2981ce 100644 --- a/reactos/dll/win32/user32/misc/desktop.c +++ b/reactos/dll/win32/user32/misc/desktop.c @@ -99,12 +99,10 @@ LogFontW2A(LPLOGFONTA pA, CONST LOGFONTW *pW) int STDCALL GetSystemMetrics(int nIndex) { + GetConnected(); // FIXME("Global Sever Data -> %x\n",g_psi); if (nIndex < 0 || nIndex >= SM_CMETRICS) return 0; - if (g_psi) - return g_psi->SystemMetrics[nIndex]; - else - return(NtUserGetSystemMetrics(nIndex)); + return g_psi->SystemMetrics[nIndex]; } diff --git a/reactos/dll/win32/user32/misc/dllmain.c b/reactos/dll/win32/user32/misc/dllmain.c index 229a5fce0e8..49cc0d6d5d3 100644 --- a/reactos/dll/win32/user32/misc/dllmain.c +++ b/reactos/dll/win32/user32/misc/dllmain.c @@ -295,3 +295,25 @@ DllMain( return TRUE; } + + +VOID +FASTCALL +GetConnected(VOID) +{ + PW32PROCESSINFO pi; + + if ((PW32THREADINFO)NtCurrentTeb()->Win32ThreadInfo == NULL) + NtUserGetThreadState(THREADSTATE_GETTHREADINFO); + + if (g_pi && g_kpi && g_psi) return; + + pi = GetW32ProcessInfo(); + if (!g_pi) g_pi = pi; + if (!g_kpi) g_kpi = SharedPtrToKernel(pi); + if (!g_psi) g_psi = SharedPtrToUser(pi->psi); + if (!g_psi) { WARN("Global Share Information has not been initialized!\n"); } + if (!gHandleTable) gHandleTable = SharedPtrToUser(pi->UserHandleTable); + if (!gHandleEntries) gHandleEntries = SharedPtrToUser(gHandleTable->handles); + +} diff --git a/reactos/dll/win32/user32/windows/input.c b/reactos/dll/win32/user32/windows/input.c index 610d5e24c8c..c92fc34f653 100644 --- a/reactos/dll/win32/user32/windows/input.c +++ b/reactos/dll/win32/user32/windows/input.c @@ -50,13 +50,13 @@ DragDetect( POINT pt) { #if 0 - return NtUserDragDetect(hWnd, pt.x, pt.y); + return NtUserDragDetect(hWnd, pt); #else MSG msg; RECT rect; POINT tmp; - ULONG dx = NtUserGetSystemMetrics(SM_CXDRAG); - ULONG dy = NtUserGetSystemMetrics(SM_CYDRAG); + ULONG dx = GetSystemMetrics(SM_CXDRAG); + ULONG dy = GetSystemMetrics(SM_CYDRAG); rect.left = pt.x - dx; rect.right = pt.x + dx; @@ -67,12 +67,15 @@ DragDetect( for (;;) { - while (PeekMessageW(&msg, 0, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE)) + while ( + PeekMessageW(&msg, 0, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE) || + PeekMessageW(&msg, 0, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE) + ) { if (msg.message == WM_LBUTTONUP) { ReleaseCapture(); - return 0; + return FALSE; } if (msg.message == WM_MOUSEMOVE) { @@ -81,9 +84,17 @@ DragDetect( if (!PtInRect(&rect, tmp)) { ReleaseCapture(); - return 1; + return TRUE; } } + if (msg.message == WM_KEYDOWN) + { + if (msg.wParam == VK_ESCAPE) + { + ReleaseCapture(); + return TRUE; + } + } } WaitMessage(); } diff --git a/reactos/include/reactos/win32k/ntuser.h b/reactos/include/reactos/win32k/ntuser.h index def5fc8417b..aeecf7a9fd2 100644 --- a/reactos/include/reactos/win32k/ntuser.h +++ b/reactos/include/reactos/win32k/ntuser.h @@ -1062,8 +1062,7 @@ BOOL NTAPI NtUserDragDetect( HWND hWnd, - LONG x, - LONG y); + POINT pt); DWORD NTAPI @@ -2718,10 +2717,6 @@ HWND NTAPI NtUserGetShellWindow(); -ULONG -NTAPI -NtUserGetSystemMetrics(ULONG Index); - HWND NTAPI NtUserGetWindow(HWND hWnd, UINT Relationship); diff --git a/reactos/subsystems/win32/win32k/ntuser/input.c b/reactos/subsystems/win32/win32k/ntuser/input.c index 819b85593cf..a86b1984c7a 100644 --- a/reactos/subsystems/win32/win32k/ntuser/input.c +++ b/reactos/subsystems/win32/win32k/ntuser/input.c @@ -885,8 +885,7 @@ BOOL STDCALL NtUserDragDetect( HWND hWnd, - LONG x, - LONG y) + POINT pt) // Just like the User call. { UNIMPLEMENTED return 0; diff --git a/reactos/subsystems/win32/win32k/ntuser/metric.c b/reactos/subsystems/win32/win32k/ntuser/metric.c index 45fe6c70224..311e9050e72 100644 --- a/reactos/subsystems/win32/win32k/ntuser/metric.c +++ b/reactos/subsystems/win32/win32k/ntuser/metric.c @@ -467,21 +467,5 @@ UserGetSystemMetrics(ULONG Index) } } -ULONG STDCALL -NtUserGetSystemMetrics(ULONG Index) -{ - DECLARE_RETURN(ULONG); - - DPRINT("Enter NtUserGetSystemMetrics\n"); - UserEnterShared(); - - RETURN(UserGetSystemMetrics(Index)); - -CLEANUP: - DPRINT("Leave NtUserGetSystemMetrics, ret=%i\n",_ret_); - UserLeave(); - END_CLEANUP; -} - /* EOF */