[win32k]
authorMichael Martin <michael.martin@reactos.org>
Sun, 23 May 2010 11:53:01 +0000 (11:53 +0000)
committerMichael Martin <michael.martin@reactos.org>
Sun, 23 May 2010 11:53:01 +0000 (11:53 +0000)
- For the Low Level Mouse Hook (WH_MOUSE_LL), input can come from the mouse driver or mouse_event. Both of which result in a call to UserSetCursorPos.
UserMode SetCursorPos API also ends up here. Add BOOL parameter that can be used to determine if hooks are to be called.
- Move the code related to calling the hook procedure from MsqInsertSystemMessage into UserSetCursorPos and call the hook procedure here if needed.
If hook procedure returns non 0 value. Dont insert the system message.
- Fixes a recursive call to the hook procedure resulting thread using to much stack exposed by user32 winetest for input.

svn path=/trunk/; revision=47325

reactos/subsystems/win32/win32k/include/cursoricon.h
reactos/subsystems/win32/win32k/ntuser/cursoricon.c
reactos/subsystems/win32/win32k/ntuser/input.c
reactos/subsystems/win32/win32k/ntuser/msgqueue.c
reactos/subsystems/win32/win32k/ntuser/simplecall.c

index 280ab55..f79dca2 100644 (file)
@@ -77,7 +77,7 @@ BOOL UserDrawIconEx(HDC hDc, INT xLeft, INT yTop, PCURICON_OBJECT pIcon, INT cxW
    INT cyHeight, UINT istepIfAniCur, HBRUSH hbrFlickerFreeDraw, UINT diFlags);
 PCURICON_OBJECT FASTCALL UserGetCurIconObject(HCURSOR hCurIcon);
 
-BOOL UserSetCursorPos( INT x, INT y);
+BOOL UserSetCursorPos( INT x, INT y, BOOL CallHooks);
 
 int UserShowCursor(BOOL bShow);
 
index 3fe0211..2958bdf 100644 (file)
@@ -175,10 +175,12 @@ UserSetCursor(
     return hOldCursor;
 }
 
-BOOL UserSetCursorPos( INT x, INT y)
+BOOL UserSetCursorPos( INT x, INT y, BOOL CallHooks)
 {
     PWINDOW_OBJECT DesktopWindow;
     PSYSTEM_CURSORINFO CurInfo;
+    LARGE_INTEGER LargeTickCount;
+    MSLLHOOKSTRUCT MouseHookData;
     HDC hDC;
     MSG Msg;
 
@@ -221,6 +223,9 @@ BOOL UserSetCursorPos( INT x, INT y)
     gpsi->ptCursor.x = x;
     gpsi->ptCursor.y = y;
 
+    KeQueryTickCount(&LargeTickCount);
+    Msg.time = MsqCalculateMessageTime(&LargeTickCount);
+
     //Move the mouse pointer
     GreMovePointer(hDC, x, y);
 
@@ -229,8 +234,39 @@ BOOL UserSetCursorPos( INT x, INT y)
     Msg.wParam = CurInfo->ButtonsDown;
     Msg.lParam = MAKELPARAM(x, y);
     Msg.pt = gpsi->ptCursor;
-    MsqInsertSystemMessage(&Msg);
 
+    MouseHookData.pt.x = LOWORD(Msg.lParam);
+    MouseHookData.pt.y = HIWORD(Msg.lParam);
+    switch(Msg.message)
+    {
+        case WM_MOUSEWHEEL:
+            MouseHookData.mouseData = MAKELONG(0, GET_WHEEL_DELTA_WPARAM(Msg.wParam));
+            break;
+        case WM_XBUTTONDOWN:
+        case WM_XBUTTONUP:
+        case WM_XBUTTONDBLCLK:
+        case WM_NCXBUTTONDOWN:
+        case WM_NCXBUTTONUP:
+        case WM_NCXBUTTONDBLCLK:
+             MouseHookData.mouseData = MAKELONG(0, HIWORD(Msg.wParam));
+             break;
+        default:
+             MouseHookData.mouseData = 0;
+             break;
+     }
+
+    MouseHookData.flags = 0;
+    MouseHookData.time = Msg.time;
+    MouseHookData.dwExtraInfo = 0;
+
+    if (CallHooks)
+    {
+      /* If the hook procedure returned non zero, dont send the message */
+      if (co_HOOK_CallHooks(WH_MOUSE_LL, HC_ACTION, Msg.message, (LPARAM) &MouseHookData))
+        return FALSE;
+    }
+
+    MsqInsertSystemMessage(&Msg);
     return TRUE;
 }
 
@@ -814,7 +850,7 @@ NtUserClipCursor(
         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);
+        UserSetCursorPos(gpsi->ptCursor.x, gpsi->ptCursor.y, FALSE);
 
         RETURN(TRUE);
     }
index 006b0f1..8764e19 100644 (file)
@@ -1128,7 +1128,7 @@ IntMouseInput(MOUSEINPUT *mi)
 
    if(mi->dwFlags & MOUSEEVENTF_MOVE)
    {
-      UserSetCursorPos(MousePos.x, MousePos.y);
+      UserSetCursorPos(MousePos.x, MousePos.y, TRUE);
    }
    if(mi->dwFlags & MOUSEEVENTF_LEFTDOWN)
    {
index 5bfe414..e71de54 100644 (file)
@@ -171,38 +171,8 @@ MsqInitializeImpl(VOID)
 VOID FASTCALL
 MsqInsertSystemMessage(MSG* Msg)
 {
-   LARGE_INTEGER LargeTickCount;
    KIRQL OldIrql;
    ULONG Prev;
-   MSLLHOOKSTRUCT MouseHookData;
-
-   KeQueryTickCount(&LargeTickCount);
-   Msg->time = MsqCalculateMessageTime(&LargeTickCount);
-
-   MouseHookData.pt.x = LOWORD(Msg->lParam);
-   MouseHookData.pt.y = HIWORD(Msg->lParam);
-   switch(Msg->message)
-   {
-        case WM_MOUSEWHEEL:
-           MouseHookData.mouseData = MAKELONG(0, GET_WHEEL_DELTA_WPARAM(Msg->wParam));
-           break;
-        case WM_XBUTTONDOWN:
-        case WM_XBUTTONUP:
-        case WM_XBUTTONDBLCLK:
-        case WM_NCXBUTTONDOWN:
-        case WM_NCXBUTTONUP:
-        case WM_NCXBUTTONDBLCLK:
-           MouseHookData.mouseData = MAKELONG(0, HIWORD(Msg->wParam));
-           break;
-        default:
-           MouseHookData.mouseData = 0;
-           break;
-     }
-     MouseHookData.flags = 0;
-     MouseHookData.time = Msg->time;
-     MouseHookData.dwExtraInfo = 0;
-     if( co_HOOK_CallHooks(WH_MOUSE_LL, HC_ACTION, Msg->message, (LPARAM) &MouseHookData))
-         return;
 
    /*
     * If we got WM_MOUSEMOVE and there are already messages in the
index 77d8fb9..cdd4a22 100644 (file)
@@ -440,7 +440,7 @@ NtUserCallTwoParam(
          RETURN( (DWORD_PTR)co_IntRegisterLogonProcess((HANDLE)Param1, (BOOL)Param2));
 
       case TWOPARAM_ROUTINE_SETCURSORPOS:
-         RETURN( (DWORD_PTR)UserSetCursorPos((int)Param1, (int)Param2));
+         RETURN( (DWORD_PTR)UserSetCursorPos((int)Param1, (int)Param2, FALSE));
 
    }
    DPRINT1("Calling invalid routine number 0x%x in NtUserCallTwoParam(), Param1=0x%x Parm2=0x%x\n",