changed SetCursorPos() to use SendInput()

svn path=/trunk/; revision=9262
This commit is contained in:
Thomas Bluemel 2004-05-01 09:31:59 +00:00
parent d490382a4f
commit 9900ed382e
4 changed files with 48 additions and 67 deletions

View file

@ -177,6 +177,7 @@ NtUserCallNoParam(
#define ONEPARAM_ROUTINE_ENUMCLIPBOARDFORMATS 0x09 #define ONEPARAM_ROUTINE_ENUMCLIPBOARDFORMATS 0x09
#define ONEPARAM_ROUTINE_GETWINDOWINSTANCE 0x10 #define ONEPARAM_ROUTINE_GETWINDOWINSTANCE 0x10
#define ONEPARAM_ROUTINE_SETMESSAGEEXTRAINFO 0x0a #define ONEPARAM_ROUTINE_SETMESSAGEEXTRAINFO 0x0a
#define ONEPARAM_ROUTINE_GETCURSORPOSITION 0x0b
DWORD DWORD
STDCALL STDCALL
NtUserCallOneParam( NtUserCallOneParam(
@ -203,7 +204,6 @@ NtUserCallOneParam(
#define TWOPARAM_ROUTINE_SWITCHTOTHISWINDOW 0x56 #define TWOPARAM_ROUTINE_SWITCHTOTHISWINDOW 0x56
#define TWOPARAM_ROUTINE_VALIDATERGN 0x57 #define TWOPARAM_ROUTINE_VALIDATERGN 0x57
#define TWOPARAM_ROUTINE_SETWNDCONTEXTHLPID 0x58 #define TWOPARAM_ROUTINE_SETWNDCONTEXTHLPID 0x58
#define TWOPARAM_ROUTINE_CURSORPOSITION 0x59
#define TWOPARAM_ROUTINE_SETCARETPOS 0x60 #define TWOPARAM_ROUTINE_SETCARETPOS 0x60
#define TWOPARAM_ROUTINE_GETWINDOWINFO 0x61 #define TWOPARAM_ROUTINE_GETWINDOWINFO 0x61
DWORD DWORD

View file

@ -40,12 +40,6 @@ void DrawCaret(HWND hWnd, PTHRDCARETINFO CaretInfo);
#define NtUserSetCaretPos(X, Y) \ #define NtUserSetCaretPos(X, Y) \
(BOOL)NtUserCallTwoParam((DWORD)X, (DWORD)Y, TWOPARAM_ROUTINE_SETCARETPOS) (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) \ #define NtUserSetGUIThreadHandle(field, hwnd) \
(BOOL)NtUserCallTwoParam((DWORD)field, (DWORD)hwnd, TWOPARAM_ROUTINE_SETGUITHRDHANDLE) (BOOL)NtUserCallTwoParam((DWORD)field, (DWORD)hwnd, TWOPARAM_ROUTINE_SETGUITHRDHANDLE)
@ -88,6 +82,9 @@ void DrawCaret(HWND hWnd, PTHRDCARETINFO CaretInfo);
#define NtUserGetWindowInstance(hwnd) \ #define NtUserGetWindowInstance(hwnd) \
(HINSTANCE)NtUserCallOneParam((DWORD)hwnd, ONEPARAM_ROUTINE_GETWINDOWINSTANCE) (HINSTANCE)NtUserCallOneParam((DWORD)hwnd, ONEPARAM_ROUTINE_GETWINDOWINSTANCE)
#define NtUserGetCursorPos(lpPoint) \
(BOOL)NtUserCallOneParam((DWORD)lpPoint, ONEPARAM_ROUTINE_GETCURSORPOSITION)
LONG WINAPI RegCloseKey(HKEY); LONG WINAPI RegCloseKey(HKEY);
LONG WINAPI RegOpenKeyExW(HKEY,LPCWSTR,DWORD,REGSAM,PHKEY); LONG WINAPI RegOpenKeyExW(HKEY,LPCWSTR,DWORD,REGSAM,PHKEY);
LONG WINAPI RegQueryValueExW(HKEY,LPCWSTR,LPDWORD,LPDWORD,LPBYTE,LPDWORD); LONG WINAPI RegQueryValueExW(HKEY,LPCWSTR,LPDWORD,LPDWORD,LPBYTE,LPDWORD);

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 * PROJECT: ReactOS user32.dll
* FILE: lib/user32/windows/cursor.c * FILE: lib/user32/windows/cursor.c
@ -260,10 +260,18 @@ BOOL STDCALL
SetCursorPos(int X, SetCursorPos(int X,
int Y) int Y)
{ {
POINT pos; INPUT Input;
pos.x = (LONG)X;
pos.y = (LONG)Y; Input.type = INPUT_MOUSE;
return NtUserSetCursorPos(&pos); 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;
} }

View file

@ -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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -185,6 +185,36 @@ NtUserCallOneParam(
case ONEPARAM_ROUTINE_SETMESSAGEEXTRAINFO: case ONEPARAM_ROUTINE_SETMESSAGEEXTRAINFO:
return (DWORD)MsqSetMessageExtraInfo((LPARAM)Param); 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", DPRINT1("Calling invalid routine number 0x%x in NtUserCallOneParam()\n Param=0x%x\n",
Routine, Param); Routine, Param);
@ -205,8 +235,6 @@ NtUserCallTwoParam(
{ {
NTSTATUS Status; NTSTATUS Status;
PWINDOW_OBJECT WindowObject; PWINDOW_OBJECT WindowObject;
PWINSTATION_OBJECT WinStaObject;
POINT Pos;
switch(Routine) switch(Routine)
{ {
@ -315,58 +343,6 @@ NtUserCallTwoParam(
IntReleaseWindowObject(WindowObject); IntReleaseWindowObject(WindowObject);
return (DWORD)TRUE; 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: case TWOPARAM_ROUTINE_SETCARETPOS:
return (DWORD)IntSetCaretPos((int)Param1, (int)Param2); return (DWORD)IntSetCaretPos((int)Param1, (int)Param2);