[Win32k]
authorJames Tabor <james.tabor@reactos.org>
Fri, 8 Jun 2012 21:19:31 +0000 (21:19 +0000)
committerJames Tabor <james.tabor@reactos.org>
Fri, 8 Jun 2012 21:19:31 +0000 (21:19 +0000)
- Fix attach thread input based on which thread is foreground. Tested with wine Msg test_SetFocus, CursorIcon test_SetCursor and test_ShowCursor, still needs more testing. See bug 7098 and bug 7107, used the test cases and it works with Qemu.

svn path=/trunk/; revision=56714

reactos/win32ss/user/ntuser/input.c

index 2dcb5e7..83d1463 100644 (file)
@@ -397,6 +397,7 @@ NtUserBlockInput(
 BOOL FASTCALL
 UserAttachThreadInput(PTHREADINFO ptiFrom, PTHREADINFO ptiTo, BOOL fAttach)
 {
+    MSG msg;
     PATTACHINFO pai;
 
     /* Can not be the same thread. */
@@ -424,9 +425,16 @@ UserAttachThreadInput(PTHREADINFO ptiFrom, PTHREADINFO ptiTo, BOOL fAttach)
         ptiFrom->pqAttach = ptiFrom->MessageQueue;
         ptiFrom->MessageQueue = ptiTo->MessageQueue;
         // FIXME: conditions?
+        if (ptiFrom->pqAttach == gpqForeground)
+        {
         ptiFrom->MessageQueue->spwndActive = ptiFrom->pqAttach->spwndActive;
         ptiFrom->MessageQueue->spwndFocus = ptiFrom->pqAttach->spwndFocus;
         ptiFrom->MessageQueue->CursorObject = ptiFrom->pqAttach->CursorObject;
+        ptiFrom->MessageQueue->CaptureWindow = ptiFrom->pqAttach->CaptureWindow;
+        ptiFrom->MessageQueue->spwndCapture = ptiFrom->pqAttach->spwndCapture;
+        ptiFrom->MessageQueue->QF_flags ^= ((ptiFrom->MessageQueue->QF_flags ^ ptiFrom->pqAttach->QF_flags) & QF_CAPTURELOCKED);
+        ptiFrom->MessageQueue->CaretInfo = ptiFrom->pqAttach->CaretInfo;
+        }
     }
     else /* If clear, unlink and free it. */
     {
@@ -464,6 +472,14 @@ UserAttachThreadInput(PTHREADINFO ptiFrom, PTHREADINFO ptiTo, BOOL fAttach)
        ATM which one?
      */
     RtlCopyMemory(ptiTo->MessageQueue->afKeyState, gafAsyncKeyState, sizeof(gafAsyncKeyState));
+
+    /* Generate mouse move message */
+    msg.message = WM_MOUSEMOVE;
+    msg.wParam = UserGetMouseButtonsState();
+    msg.lParam = MAKELPARAM(gpsi->ptCursor.x, gpsi->ptCursor.y);
+    msg.pt = gpsi->ptCursor;
+    co_MsqInsertMouseMessage(&msg, 0, 0, TRUE);
+
     return TRUE;
 }