From 7627920bef632c56d86a7690106aec46376ee720 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Tue, 1 Sep 2015 01:48:37 +0000 Subject: [PATCH] [Win32k] - Fix more ATI issues, pass more related tests. See CORE-6551. svn path=/trunk/; revision=68889 --- reactos/win32ss/user/ntuser/input.c | 35 +++++++++++++++------- reactos/win32ss/user/ntuser/msgqueue.c | 41 +++++++++++++++++++++----- 2 files changed, 58 insertions(+), 18 deletions(-) diff --git a/reactos/win32ss/user/ntuser/input.c b/reactos/win32ss/user/ntuser/input.c index c087b8ffa6f..aac846a8e9c 100644 --- a/reactos/win32ss/user/ntuser/input.c +++ b/reactos/win32ss/user/ntuser/input.c @@ -492,16 +492,6 @@ UserAttachThreadInput(PTHREADINFO ptiFrom, PTHREADINFO ptiTo, BOOL fAttach) ptiTo->MessageQueue->iCursorLevel -= ptiFrom->iCursorLevel; - // FIXME: conditions? - if (ptiTo->MessageQueue == gpqForeground) - { - ERR("ptiTo is Foreground\n"); - } - else - { - ERR("ptiTo NOT Foreground\n"); - } - if (ptiFrom->MessageQueue == gpqForeground) { ERR("ptiFrom is Foreground\n"); @@ -517,6 +507,10 @@ UserAttachThreadInput(PTHREADINFO ptiFrom, PTHREADINFO ptiTo, BOOL fAttach) else { ERR("ptiFrom NOT Foreground\n"); + if ( ptiTo->MessageQueue->spwndActive == 0 ) + ptiTo->MessageQueue->spwndActive = ptiFrom->MessageQueue->spwndActive; + if ( ptiTo->MessageQueue->spwndFocus == 0 ) + ptiTo->MessageQueue->spwndFocus = ptiFrom->MessageQueue->spwndFocus; } CurIcon = ptiFrom->MessageQueue->CursorObject; @@ -584,6 +578,9 @@ UserAttachThreadInput(PTHREADINFO ptiFrom, PTHREADINFO ptiTo, BOOL fAttach) if (ptiTo->MessageQueue == ptiFrom->MessageQueue) { + PWND spwndActive = ptiTo->MessageQueue->spwndActive; + PWND spwndFocus = ptiTo->MessageQueue->spwndFocus; + if (gptiForeground == ptiFrom) { ERR("ptiTo is now pti FG.\n"); @@ -598,6 +595,22 @@ UserAttachThreadInput(PTHREADINFO ptiFrom, PTHREADINFO ptiTo, BOOL fAttach) ptiFrom->MessageQueue = MsqCreateMessageQueue(ptiFrom); + if (spwndActive) + { + if (spwndActive->head.pti == ptiFrom) + { + ptiFrom->MessageQueue->spwndActive = spwndActive; + ptiTo->MessageQueue->spwndActive = 0; + } + } + if (spwndFocus) + { + if (spwndFocus->head.pti == ptiFrom) + { + ptiFrom->MessageQueue->spwndFocus = spwndFocus; + ptiTo->MessageQueue->spwndFocus = 0; + } + } ptiTo->MessageQueue->iCursorLevel -= ptiFrom->iCursorLevel; } else @@ -611,6 +624,8 @@ UserAttachThreadInput(PTHREADINFO ptiFrom, PTHREADINFO ptiTo, BOOL fAttach) */ RtlCopyMemory(ptiTo->MessageQueue->afKeyState, gafAsyncKeyState, sizeof(gafAsyncKeyState)); + ptiTo->MessageQueue->msgDblClk.message = 0; + /* Generate mouse move message */ msg.message = WM_MOUSEMOVE; msg.wParam = UserGetMouseButtonsState(); diff --git a/reactos/win32ss/user/ntuser/msgqueue.c b/reactos/win32ss/user/ntuser/msgqueue.c index f17f62f9c49..911c32aa239 100644 --- a/reactos/win32ss/user/ntuser/msgqueue.c +++ b/reactos/win32ss/user/ntuser/msgqueue.c @@ -639,7 +639,13 @@ co_MsqInsertMouseMessage(MSG* Msg, DWORD flags, ULONG_PTR dwExtraInfo, BOOL Hook return; } - MessageQueue->ptiMouse = pti; + // Check to see if this is attached. + if ( pti != MessageQueue->ptiMouse && + MessageQueue->cThreads > 1 ) + { + // Set the send pti to the message queue mouse pti. + pti = MessageQueue->ptiMouse; + } if (Msg->message == WM_MOUSEMOVE) { @@ -1252,6 +1258,7 @@ co_MsqSendMessage(PTHREADINFO ptirec, } Entry = Entry->Flink; } + break; } if (WaitStatus == STATUS_USER_APC) break; @@ -1413,7 +1420,7 @@ IntTrackMouseMove(PWND pwndTrack, PDESKTOP pDesk, PMSG msg, USHORT hittest) } } -BOOL co_IntProcessMouseMessage(MSG* msg, BOOL* RemoveMessages, UINT first, UINT last) +BOOL co_IntProcessMouseMessage(MSG* msg, BOOL* RemoveMessages, BOOL* NotForUs, UINT first, UINT last) { MSG clk_msg; POINT pt; @@ -1454,7 +1461,7 @@ BOOL co_IntProcessMouseMessage(MSG* msg, BOOL* RemoveMessages, UINT first, UINT TRACE("Got mouse message for %p, hittest: 0x%x\n", msg->hwnd, hittest); // Null window or not the same "Hardware" message queue. - if (pwndMsg == NULL || pwndMsg->head.pti->MessageQueue != pti->MessageQueue) + if (pwndMsg == NULL || pwndMsg->head.pti->MessageQueue != MessageQueue) { // Crossing a boundary, so set cursor. See default message queue cursor. UserSetCursor(SYSTEMCUR(ARROW), FALSE); @@ -1463,6 +1470,16 @@ BOOL co_IntProcessMouseMessage(MSG* msg, BOOL* RemoveMessages, UINT first, UINT return FALSE; } + // Check to see if this is attached, + if ( pwndMsg->head.pti != pti && // window thread is not current, + MessageQueue->cThreads > 1 ) // and is attached... + { + // This is not for us and we should leave so the other thread can check for messages!!! + *NotForUs = TRUE; + *RemoveMessages = TRUE; + return FALSE; + } + if ( MessageQueue == gpqCursor ) // Cursor must use the same Queue! { IntTrackMouseMove(pwndMsg, pDesk, msg, hittest); @@ -1795,11 +1812,11 @@ BOOL co_IntProcessKeyboardMessage(MSG* Msg, BOOL* RemoveMessages) return Ret; } -BOOL co_IntProcessHardwareMessage(MSG* Msg, BOOL* RemoveMessages, UINT first, UINT last) +BOOL co_IntProcessHardwareMessage(MSG* Msg, BOOL* RemoveMessages, BOOL* NotForUs, UINT first, UINT last) { if ( IS_MOUSE_MESSAGE(Msg->message)) { - return co_IntProcessMouseMessage(Msg, RemoveMessages, first, last); + return co_IntProcessMouseMessage(Msg, RemoveMessages, NotForUs, first, last); } else if ( IS_KBD_MESSAGE(Msg->message)) { @@ -1835,7 +1852,7 @@ co_MsqPeekHardwareMessage(IN PTHREADINFO pti, IN UINT QSflags, OUT MSG* pMsg) { - BOOL AcceptMessage; + BOOL AcceptMessage, NotForUs; PUSER_MESSAGE CurrentMessage; PLIST_ENTRY ListHead; MSG msg; @@ -1858,7 +1875,7 @@ co_MsqPeekHardwareMessage(IN PTHREADINFO pti, if (MessageQueue->ptiSysLock != pti) { - ERR("MsqPeekHardwareMessage: Thread Q is locked to another pti!\n"); + ERR("Thread Q is locked to ptiSysLock 0x%p pti 0x%p\n",MessageQueue->ptiSysLock,pti); return FALSE; } @@ -1891,8 +1908,10 @@ co_MsqPeekHardwareMessage(IN PTHREADINFO pti, msg = CurrentMessage->Msg; QS_Flags = CurrentMessage->QS_Flags; + NotForUs = FALSE; + UpdateKeyStateFromMsg(MessageQueue, &msg); - AcceptMessage = co_IntProcessHardwareMessage(&msg, &Remove, MsgFilterLow, MsgFilterHigh); + AcceptMessage = co_IntProcessHardwareMessage(&msg, &Remove, &NotForUs, MsgFilterLow, MsgFilterHigh); if (Remove) { @@ -1906,6 +1925,12 @@ co_MsqPeekHardwareMessage(IN PTHREADINFO pti, MessageQueue->idSysPeek = idSave; + if (NotForUs) + { + Ret = FALSE; + break; + } + if (AcceptMessage) { *pMsg = msg; -- 2.17.1