- Cleanup UserSetCursorPos
- UserSetCursorPos: set the new position after sending WM_MOUSEMOVE message
now we pass all tests for SetCursorPos

svn path=/trunk/; revision=48879
This commit is contained in:
Giannis Adamopoulos 2010-09-25 16:59:53 +00:00
parent f6e6759404
commit 28b33bcfe7
2 changed files with 39 additions and 61 deletions

View file

@ -22,15 +22,6 @@ typedef struct _CURICON_OBJECT
ICONINFO IconInfo;
} CURICON_OBJECT, *PCURICON_OBJECT;
typedef struct _CURSORCLIP_INFO
{
BOOL IsClipped;
UINT Left;
UINT Top;
UINT Right;
UINT Bottom;
} CURSORCLIP_INFO, *PCURSORCLIP_INFO;
typedef struct _CURSORACCELERATION_INFO
{
UINT FirstThreshold;
@ -45,7 +36,8 @@ typedef struct _SYSTEM_CURSORINFO
DWORD ClickLockTime;
// BOOL SwapButtons;
UINT ButtonsDown;
CURSORCLIP_INFO CursorClipInfo;
RECTL rcClip;
BOOL bClipped;
PCURICON_OBJECT CurrentCursorObject;
INT ShowingCursor;
/*

View file

@ -60,7 +60,7 @@ InitCursorImpl()
gSysCursorInfo.Enabled = FALSE;
gSysCursorInfo.ButtonsDown = 0;
gSysCursorInfo.CursorClipInfo.IsClipped = FALSE;
gSysCursorInfo.bClipped = FALSE;
gSysCursorInfo.LastBtnDown = 0;
gSysCursorInfo.CurrentCursorObject = NULL;
gSysCursorInfo.ShowingCursor = 0;
@ -180,59 +180,52 @@ BOOL UserSetCursorPos( INT x, INT y, BOOL SendMouseMoveMsg)
PSYSTEM_CURSORINFO CurInfo;
HDC hDC;
MSG Msg;
RECTL rcClip;
POINT pt;
if(!(hDC = IntGetScreenDC()))
{
return FALSE;
}
if(!(DesktopWindow = UserGetDesktopWindow()))
{
return FALSE;
}
CurInfo = IntGetSysCursorInfo();
DesktopWindow = UserGetDesktopWindow();
/* Clip cursor position */
if (!CurInfo->bClipped)
rcClip = DesktopWindow->Wnd->rcClient;
else
rcClip = CurInfo->rcClip;
if (DesktopWindow)
if(x >= rcClip.right) x = rcClip.right - 1;
if(x < rcClip.left) x = rcClip.left;
if(y >= rcClip.bottom) y = rcClip.bottom - 1;
if(y < rcClip.top) y = rcClip.top;
pt.x = x;
pt.y = y;
if (SendMouseMoveMsg)
{
if(x >= DesktopWindow->Wnd->rcClient.right)
x = DesktopWindow->Wnd->rcClient.right - 1;
if(y >= DesktopWindow->Wnd->rcClient.bottom)
y = DesktopWindow->Wnd->rcClient.bottom - 1;
/* Generate a mouse move message */
Msg.message = WM_MOUSEMOVE;
Msg.wParam = CurInfo->ButtonsDown;
Msg.lParam = MAKELPARAM(x, y);
Msg.pt = pt;
MsqInsertSystemMessage(&Msg);
}
if(x < 0)
x = 0;
if(y < 0)
y = 0;
/* Store the new cursor position */
gpsi->ptCursor = pt;
//Clip cursor position
if(CurInfo->CursorClipInfo.IsClipped)
{
if(x >= (LONG)CurInfo->CursorClipInfo.Right)
x = (LONG)CurInfo->CursorClipInfo.Right - 1;
if(x < (LONG)CurInfo->CursorClipInfo.Left)
x = (LONG)CurInfo->CursorClipInfo.Left;
if(y >= (LONG)CurInfo->CursorClipInfo.Bottom)
y = (LONG)CurInfo->CursorClipInfo.Bottom - 1;
if(y < (LONG)CurInfo->CursorClipInfo.Top)
y = (LONG)CurInfo->CursorClipInfo.Top;
}
//Store the new cursor position
gpsi->ptCursor.x = x;
gpsi->ptCursor.y = y;
//Move the mouse pointer
/* Move the mouse pointer */
GreMovePointer(hDC, x, y);
if (!SendMouseMoveMsg)
return TRUE;
//Generate a mouse move message
Msg.message = WM_MOUSEMOVE;
Msg.wParam = CurInfo->ButtonsDown;
Msg.lParam = MAKELPARAM(x, y);
Msg.pt = gpsi->ptCursor;
MsqInsertSystemMessage(&Msg);
return TRUE;
}
@ -731,18 +724,14 @@ NtUserClipCursor(
&& DesktopWindow && UnsafeRect != NULL)
{
CurInfo->CursorClipInfo.IsClipped = TRUE;
CurInfo->CursorClipInfo.Left = max(Rect.left, DesktopWindow->Wnd->rcWindow.left);
CurInfo->CursorClipInfo.Top = max(Rect.top, DesktopWindow->Wnd->rcWindow.top);
CurInfo->CursorClipInfo.Right = min(Rect.right, DesktopWindow->Wnd->rcWindow.right);
CurInfo->CursorClipInfo.Bottom = min(Rect.bottom, DesktopWindow->Wnd->rcWindow.bottom);
CurInfo->bClipped = TRUE;
RECTL_bIntersectRect(&CurInfo->rcClip, &Rect, &DesktopWindow->Wnd->rcWindow);
UserSetCursorPos(gpsi->ptCursor.x, gpsi->ptCursor.y, FALSE);
RETURN(TRUE);
}
CurInfo->CursorClipInfo.IsClipped = FALSE;
CurInfo->bClipped = FALSE;
RETURN(TRUE);
CLEANUP:
@ -843,12 +832,9 @@ NtUserGetClipCursor(
RETURN(FALSE);
CurInfo = IntGetSysCursorInfo();
if (CurInfo->CursorClipInfo.IsClipped)
if (CurInfo->bClipped)
{
Rect.left = CurInfo->CursorClipInfo.Left;
Rect.top = CurInfo->CursorClipInfo.Top;
Rect.right = CurInfo->CursorClipInfo.Right;
Rect.bottom = CurInfo->CursorClipInfo.Bottom;
Rect = CurInfo->rcClip;
}
else
{