From 9900ed382e69d9abf520112fdba316395a00e393 Mon Sep 17 00:00:00 2001 From: Thomas Bluemel Date: Sat, 1 May 2004 09:31:59 +0000 Subject: [PATCH] changed SetCursorPos() to use SendInput() svn path=/trunk/; revision=9262 --- reactos/include/win32k/ntuser.h | 2 +- reactos/lib/user32/include/user32.h | 9 +-- reactos/lib/user32/windows/cursor.c | 18 ++++-- reactos/subsys/win32k/ntuser/misc.c | 86 +++++++++++------------------ 4 files changed, 48 insertions(+), 67 deletions(-) diff --git a/reactos/include/win32k/ntuser.h b/reactos/include/win32k/ntuser.h index ece27718a4c..3ab2b9086e9 100644 --- a/reactos/include/win32k/ntuser.h +++ b/reactos/include/win32k/ntuser.h @@ -177,6 +177,7 @@ NtUserCallNoParam( #define ONEPARAM_ROUTINE_ENUMCLIPBOARDFORMATS 0x09 #define ONEPARAM_ROUTINE_GETWINDOWINSTANCE 0x10 #define ONEPARAM_ROUTINE_SETMESSAGEEXTRAINFO 0x0a +#define ONEPARAM_ROUTINE_GETCURSORPOSITION 0x0b DWORD STDCALL NtUserCallOneParam( @@ -203,7 +204,6 @@ NtUserCallOneParam( #define TWOPARAM_ROUTINE_SWITCHTOTHISWINDOW 0x56 #define TWOPARAM_ROUTINE_VALIDATERGN 0x57 #define TWOPARAM_ROUTINE_SETWNDCONTEXTHLPID 0x58 -#define TWOPARAM_ROUTINE_CURSORPOSITION 0x59 #define TWOPARAM_ROUTINE_SETCARETPOS 0x60 #define TWOPARAM_ROUTINE_GETWINDOWINFO 0x61 DWORD diff --git a/reactos/lib/user32/include/user32.h b/reactos/lib/user32/include/user32.h index fff142e46bd..25f0fa8fb6d 100644 --- a/reactos/lib/user32/include/user32.h +++ b/reactos/lib/user32/include/user32.h @@ -40,12 +40,6 @@ void DrawCaret(HWND hWnd, PTHRDCARETINFO CaretInfo); #define NtUserSetCaretPos(X, Y) \ (BOOL)NtUserCallTwoParam((DWORD)X, (DWORD)Y, TWOPARAM_ROUTINE_SETCARETPOS) -#define NtUserGetCursorPos(lpPoint) \ - (BOOL)NtUserCallTwoParam((DWORD)lpPoint, (DWORD)FALSE, TWOPARAM_ROUTINE_CURSORPOSITION) - -#define NtUserSetCursorPos(lpPoint) \ - (BOOL)NtUserCallTwoParam((DWORD)lpPoint, (DWORD)TRUE, TWOPARAM_ROUTINE_CURSORPOSITION) - #define NtUserSetGUIThreadHandle(field, hwnd) \ (BOOL)NtUserCallTwoParam((DWORD)field, (DWORD)hwnd, TWOPARAM_ROUTINE_SETGUITHRDHANDLE) @@ -88,6 +82,9 @@ void DrawCaret(HWND hWnd, PTHRDCARETINFO CaretInfo); #define NtUserGetWindowInstance(hwnd) \ (HINSTANCE)NtUserCallOneParam((DWORD)hwnd, ONEPARAM_ROUTINE_GETWINDOWINSTANCE) +#define NtUserGetCursorPos(lpPoint) \ + (BOOL)NtUserCallOneParam((DWORD)lpPoint, ONEPARAM_ROUTINE_GETCURSORPOSITION) + LONG WINAPI RegCloseKey(HKEY); LONG WINAPI RegOpenKeyExW(HKEY,LPCWSTR,DWORD,REGSAM,PHKEY); LONG WINAPI RegQueryValueExW(HKEY,LPCWSTR,LPDWORD,LPDWORD,LPBYTE,LPDWORD); diff --git a/reactos/lib/user32/windows/cursor.c b/reactos/lib/user32/windows/cursor.c index 128f9baa1b9..a2b840b8445 100644 --- a/reactos/lib/user32/windows/cursor.c +++ b/reactos/lib/user32/windows/cursor.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: cursor.c,v 1.20 2004/04/09 20:03:14 navaraf Exp $ +/* $Id: cursor.c,v 1.21 2004/05/01 09:31:59 weiden Exp $ * * PROJECT: ReactOS user32.dll * FILE: lib/user32/windows/cursor.c @@ -260,10 +260,18 @@ BOOL STDCALL SetCursorPos(int X, int Y) { - POINT pos; - pos.x = (LONG)X; - pos.y = (LONG)Y; - return NtUserSetCursorPos(&pos); + INPUT Input; + + Input.type = INPUT_MOUSE; + Input.mi.dx = (LONG)X; + Input.mi.dy = (LONG)Y; + Input.mi.mouseData = 0; + Input.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE; + Input.mi.time = 0; + Input.mi.dwExtraInfo = 0; + + NtUserSendInput(1, &Input, sizeof(INPUT)); + return TRUE; } diff --git a/reactos/subsys/win32k/ntuser/misc.c b/reactos/subsys/win32k/ntuser/misc.c index 100b6138f43..1fe2e0f3230 100644 --- a/reactos/subsys/win32k/ntuser/misc.c +++ b/reactos/subsys/win32k/ntuser/misc.c @@ -1,4 +1,4 @@ -/* $Id: misc.c,v 1.64 2004/04/30 22:18:00 weiden Exp $ +/* $Id: misc.c,v 1.65 2004/05/01 09:31:59 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -185,6 +185,36 @@ NtUserCallOneParam( case ONEPARAM_ROUTINE_SETMESSAGEEXTRAINFO: return (DWORD)MsqSetMessageExtraInfo((LPARAM)Param); + + case ONEPARAM_ROUTINE_GETCURSORPOSITION: + { + POINT Pos; + + if(!Param) + return (DWORD)FALSE; + Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(), + KernelMode, + 0, + &WinStaObject); + if (!NT_SUCCESS(Status)) + return (DWORD)FALSE; + + /* FIXME - check if process has WINSTA_READATTRIBUTES */ + Pos.x = WinStaObject->SystemCursor.x; + Pos.y = WinStaObject->SystemCursor.y; + + Status = MmCopyToCaller((PPOINT)Param, &Pos, sizeof(POINT)); + if(!NT_SUCCESS(Status)) + { + ObDereferenceObject(WinStaObject); + SetLastNtError(Status); + return FALSE; + } + + ObDereferenceObject(WinStaObject); + + return (DWORD)TRUE; + } } DPRINT1("Calling invalid routine number 0x%x in NtUserCallOneParam()\n Param=0x%x\n", Routine, Param); @@ -205,8 +235,6 @@ NtUserCallTwoParam( { NTSTATUS Status; PWINDOW_OBJECT WindowObject; - PWINSTATION_OBJECT WinStaObject; - POINT Pos; switch(Routine) { @@ -315,58 +343,6 @@ NtUserCallTwoParam( IntReleaseWindowObject(WindowObject); return (DWORD)TRUE; - - case TWOPARAM_ROUTINE_CURSORPOSITION: - if(!Param1) - return (DWORD)FALSE; - Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(), - KernelMode, - 0, - &WinStaObject); - if (!NT_SUCCESS(Status)) - return (DWORD)FALSE; - - if(Param2) - { - /* set cursor position */ - MOUSEINPUT mi; - - Status = MmCopyFromCaller(&Pos, (PPOINT)Param1, sizeof(POINT)); - if(!NT_SUCCESS(Status)) - { - ObDereferenceObject(WinStaObject); - SetLastNtError(Status); - return FALSE; - } - - mi.dx = Pos.x; - mi.dy = Pos.y; - mi.mouseData = 0; - mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE; - mi.time = 0; - mi.dwExtraInfo = 0; - IntMouseInput(&mi); - } - else - { - /* get cursor position */ - /* FIXME - check if process has WINSTA_READATTRIBUTES */ - Pos.x = WinStaObject->SystemCursor.x; - Pos.y = WinStaObject->SystemCursor.y; - - Status = MmCopyToCaller((PPOINT)Param1, &Pos, sizeof(POINT)); - if(!NT_SUCCESS(Status)) - { - ObDereferenceObject(WinStaObject); - SetLastNtError(Status); - return FALSE; - } - - } - - ObDereferenceObject(WinStaObject); - - return (DWORD)TRUE; case TWOPARAM_ROUTINE_SETCARETPOS: return (DWORD)IntSetCaretPos((int)Param1, (int)Param2);