- 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; ICONINFO IconInfo;
} CURICON_OBJECT, *PCURICON_OBJECT; } 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 typedef struct _CURSORACCELERATION_INFO
{ {
UINT FirstThreshold; UINT FirstThreshold;
@ -45,7 +36,8 @@ typedef struct _SYSTEM_CURSORINFO
DWORD ClickLockTime; DWORD ClickLockTime;
// BOOL SwapButtons; // BOOL SwapButtons;
UINT ButtonsDown; UINT ButtonsDown;
CURSORCLIP_INFO CursorClipInfo; RECTL rcClip;
BOOL bClipped;
PCURICON_OBJECT CurrentCursorObject; PCURICON_OBJECT CurrentCursorObject;
INT ShowingCursor; INT ShowingCursor;
/* /*

View file

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