[WIN32SS][NTUSER] Fix message time (#1259)

Fix CORE-15565 and make #1245 GetMessageTime testcase successful. CORE-15565
- Erase MsqCalculateMessageTime function.
- Use (DWORD)EngGetTickCount() instead.
- Ghosting is temporarily disabled.
This commit is contained in:
Katayama Hirofumi MZ 2019-04-12 07:56:04 +09:00 committed by GitHub
parent 983cd57c1e
commit 94a42d43b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 25 additions and 66 deletions

View file

@ -40,6 +40,8 @@ APIENTRY
EngGetTickCount(
VOID);
#define EngGetTickCount32() (ULONG)EngGetTickCount()
HANDLE
APIENTRY
EngSecureMemForRead(

View file

@ -165,7 +165,7 @@ co_EVENT_CallEvents( DWORD event,
pEP->idObject,
pEP->idChild,
pEP->idThread,
(DWORD)EngGetTickCount(),
EngGetTickCount32(),
pEH->Proc,
pEH->ihmod,
pEH->offPfn);
@ -229,7 +229,7 @@ IntNotifyWinEvent(
idObject,
idChild,
PtrToUint(NtCurrentTeb()->ClientId.UniqueThread),
(DWORD)EngGetTickCount(),
EngGetTickCount32(),
pEH->Proc,
pEH->ihmod,
pEH->offPfn);

View file

@ -33,9 +33,7 @@ IntLastInputTick(BOOL bUpdate)
{
if (bUpdate)
{
LARGE_INTEGER TickCount;
KeQueryTickCount(&TickCount);
LastInputTick = MsqCalculateMessageTime(&TickCount);
LastInputTick = EngGetTickCount32();
if (gpsi) gpsi->dwLastRITEventTickCount = LastInputTick;
}
return LastInputTick;
@ -49,13 +47,11 @@ IntLastInputTick(BOOL bUpdate)
VOID FASTCALL
DoTheScreenSaver(VOID)
{
LARGE_INTEGER TickCount;
DWORD Test, TO;
if (gspv.iScrSaverTimeout > 0) // Zero means Off.
{
KeQueryTickCount(&TickCount);
Test = MsqCalculateMessageTime(&TickCount);
Test = EngGetTickCount32();
Test = Test - LastInputTick;
TO = 1000 * gspv.iScrSaverTimeout;
if (Test > TO)

View file

@ -976,7 +976,6 @@ UserSendKeyboardInput(KEYBDINPUT *pKbdInput, BOOL bInjected)
PKL pKl = NULL;
PKBDTABLES pKbdTbl;
PUSER_MESSAGE_QUEUE pFocusQueue;
LARGE_INTEGER LargeTickCount;
DWORD dwTime;
BOOL bExt = (pKbdInput->dwFlags & KEYEVENTF_EXTENDEDKEY) ? TRUE : FALSE;
@ -1030,8 +1029,7 @@ UserSendKeyboardInput(KEYBDINPUT *pKbdInput, BOOL bInjected)
dwTime = pKbdInput->time;
else
{
KeQueryTickCount(&LargeTickCount);
dwTime = MsqCalculateMessageTime(&LargeTickCount);
dwTime = EngGetTickCount32();
}
if (wVk == VK_RMENU && (pKbdTbl->fLocaleFlags & KLLF_ALTGR))
@ -1143,7 +1141,6 @@ IntTranslateKbdMessage(LPMSG lpMsg,
WCHAR wch[3] = { 0 };
MSG NewMsg = { 0 };
PKBDTABLES pKbdTbl;
LARGE_INTEGER LargeTickCount;
BOOL bResult = FALSE;
switch(lpMsg->message)
@ -1176,8 +1173,7 @@ IntTranslateKbdMessage(LPMSG lpMsg,
/* Init pt, hwnd and time msg fields */
NewMsg.pt = gpsi->ptCursor;
NewMsg.hwnd = lpMsg->hwnd;
KeQueryTickCount(&LargeTickCount);
NewMsg.time = MsqCalculateMessageTime(&LargeTickCount);
NewMsg.time = EngGetTickCount32();
TRACE("Enter IntTranslateKbdMessage msg %s, vk %x\n",
lpMsg->message == WM_SYSKEYDOWN ? "WM_SYSKEYDOWN" : "WM_KEYDOWN", lpMsg->wParam);

View file

@ -443,7 +443,6 @@ InitThreadCallback(PETHREAD Thread)
int i;
NTSTATUS Status = STATUS_SUCCESS;
PTEB pTeb;
LARGE_INTEGER LargeTickCount;
PRTL_USER_PROCESS_PARAMETERS ProcessParams;
Process = Thread->ThreadsProcess;
@ -504,9 +503,7 @@ InitThreadCallback(PETHREAD Thread)
goto error;
}
KeQueryTickCount(&LargeTickCount);
ptiCurrent->timeLast = LargeTickCount.u.LowPart;
ptiCurrent->timeLast = EngGetTickCount32();
ptiCurrent->MessageQueue = MsqCreateMessageQueue(ptiCurrent);
if (ptiCurrent->MessageQueue == NULL)
{

View file

@ -681,7 +681,6 @@ static LRESULT handle_internal_events( PTHREADINFO pti, PWND pWnd, DWORD dwQEven
LRESULT FASTCALL
IntDispatchMessage(PMSG pMsg)
{
LARGE_INTEGER TickCount;
LONG Time;
LRESULT retval = 0;
PTHREADINFO pti;
@ -710,8 +709,7 @@ IntDispatchMessage(PMSG pMsg)
{
if (ValidateTimerCallback(pti,pMsg->lParam))
{
KeQueryTickCount(&TickCount);
Time = MsqCalculateMessageTime(&TickCount);
Time = EngGetTickCount32();
retval = co_IntCallWindowProc((WNDPROC)pMsg->lParam,
TRUE,
pMsg->hwnd,
@ -727,8 +725,7 @@ IntDispatchMessage(PMSG pMsg)
PTIMER pTimer = FindSystemTimer(pMsg);
if (pTimer && pTimer->pfn)
{
KeQueryTickCount(&TickCount);
Time = MsqCalculateMessageTime(&TickCount);
Time = EngGetTickCount32();
pTimer->pfn(pMsg->hwnd, WM_SYSTIMER, (UINT)pMsg->wParam, Time);
}
return 0;
@ -815,7 +812,6 @@ co_IntPeekMessage( PMSG Msg,
BOOL bGMSG )
{
PTHREADINFO pti;
LARGE_INTEGER LargeTickCount;
BOOL RemoveMessages;
UINT ProcessMask;
BOOL Hit = FALSE;
@ -833,9 +829,8 @@ co_IntPeekMessage( PMSG Msg,
do
{
KeQueryTickCount(&LargeTickCount);
pti->timeLast = LargeTickCount.u.LowPart;
pti->pcti->tickLastMsgChecked = LargeTickCount.u.LowPart;
pti->timeLast = EngGetTickCount32();
pti->pcti->tickLastMsgChecked = pti->timeLast;
// Post mouse moves while looping through peek messages.
if (pti->MessageQueue->QF_flags & QF_MOUSEMOVED)
@ -1152,7 +1147,6 @@ UserPostThreadMessage( PTHREADINFO pti,
LPARAM lParam )
{
MSG Message;
LARGE_INTEGER LargeTickCount;
if (is_pointer_message(Msg))
{
@ -1164,9 +1158,7 @@ UserPostThreadMessage( PTHREADINFO pti,
Message.wParam = wParam;
Message.lParam = lParam;
Message.pt = gpsi->ptCursor;
KeQueryTickCount(&LargeTickCount);
Message.time = MsqCalculateMessageTime(&LargeTickCount);
Message.time = EngGetTickCount32();
MsqPostMessage(pti, &Message, FALSE, QS_POSTMESSAGE, 0, 0);
return TRUE;
}
@ -1193,7 +1185,6 @@ UserPostMessage( HWND Wnd,
{
PTHREADINFO pti;
MSG Message;
LARGE_INTEGER LargeTickCount;
LONG_PTR ExtraInfo = 0;
Message.hwnd = Wnd;
@ -1201,8 +1192,7 @@ UserPostMessage( HWND Wnd,
Message.wParam = wParam;
Message.lParam = lParam;
Message.pt = gpsi->ptCursor;
KeQueryTickCount(&LargeTickCount);
Message.time = MsqCalculateMessageTime(&LargeTickCount);
Message.time = EngGetTickCount32();
if (is_pointer_message(Message.message))
{
@ -1468,7 +1458,7 @@ co_IntSendMessageTimeoutSingle( HWND hWnd,
if (Status == STATUS_TIMEOUT)
{
if (MsqIsHung(ptiSendTo))
if (0 && MsqIsHung(ptiSendTo))
{
TRACE("Let's go Ghost!\n");
IntMakeHungWindowGhosted(hWnd);

View file

@ -295,11 +295,9 @@ NtUserGetThreadState(
case THREADSTATE_UPTIMELASTREAD:
{
PTHREADINFO pti;
LARGE_INTEGER LargeTickCount;
pti = PsGetCurrentThreadWin32Thread();
KeQueryTickCount(&LargeTickCount);
pti->timeLast = LargeTickCount.u.LowPart;
pti->pcti->tickLastMsgChecked = LargeTickCount.u.LowPart;
pti->timeLast = EngGetTickCount32();
pti->pcti->tickLastMsgChecked = pti->timeLast;
}
break;

View file

@ -210,9 +210,7 @@ UserSendMouseInput(MOUSEINPUT *pmi, BOOL bInjected)
Msg.time = pmi->time;
if (!Msg.time)
{
LARGE_INTEGER LargeTickCount;
KeQueryTickCount(&LargeTickCount);
Msg.time = MsqCalculateMessageTime(&LargeTickCount);
Msg.time = EngGetTickCount32();
}
/* Do GetMouseMovePointsEx FIFO. */

View file

@ -551,13 +551,11 @@ VOID FASTCALL
IntCoalesceMouseMove(PTHREADINFO pti)
{
MSG Msg;
LARGE_INTEGER LargeTickCount;
// Force time stamp to update, keeping message time in sync.
if (gdwMouseMoveTimeStamp == 0)
{
KeQueryTickCount(&LargeTickCount);
gdwMouseMoveTimeStamp = MsqCalculateMessageTime(&LargeTickCount);
gdwMouseMoveTimeStamp = EngGetTickCount32();
}
// Build mouse move message.
@ -581,7 +579,6 @@ IntCoalesceMouseMove(PTHREADINFO pti)
VOID FASTCALL
co_MsqInsertMouseMessage(MSG* Msg, DWORD flags, ULONG_PTR dwExtraInfo, BOOL Hook)
{
LARGE_INTEGER LargeTickCount;
MSLLHOOKSTRUCT MouseHookData;
// PDESKTOP pDesk;
PWND pwnd, pwndDesktop;
@ -590,8 +587,7 @@ co_MsqInsertMouseMessage(MSG* Msg, DWORD flags, ULONG_PTR dwExtraInfo, BOOL Hook
PUSER_MESSAGE_QUEUE MessageQueue;
PSYSTEM_CURSORINFO CurInfo;
KeQueryTickCount(&LargeTickCount);
Msg->time = MsqCalculateMessageTime(&LargeTickCount);
Msg->time = EngGetTickCount32();
MouseHookData.pt.x = LOWORD(Msg->lParam);
MouseHookData.pt.y = HIWORD(Msg->lParam);
@ -2197,11 +2193,7 @@ co_MsqWaitForNewMessages(PTHREADINFO pti, PWND WndFilter,
BOOL FASTCALL
MsqIsHung(PTHREADINFO pti)
{
LARGE_INTEGER LargeTickCount;
KeQueryTickCount(&LargeTickCount);
if ((LargeTickCount.u.LowPart - pti->timeLast) > MSQ_HUNG &&
if (EngGetTickCount32() - pti->timeLast > MSQ_HUNG &&
!(pti->pcti->fsWakeMask & QS_INPUT) &&
!PsGetThreadFreezeCount(pti->pEThread) &&
!(pti->ppi->W32PF_flags & W32PF_APPSTARTING))

View file

@ -249,12 +249,6 @@ VOID APIENTRY MsqRemoveWindowMessagesFromQueue(PWND pWindow);
HANDLE FASTCALL IntMsqSetWakeMask(DWORD WakeMask);
BOOL FASTCALL IntMsqClearWakeMask(VOID);
static __inline LONG
MsqCalculateMessageTime(IN PLARGE_INTEGER TickCount)
{
return (LONG)(TickCount->QuadPart * (KeQueryTimeIncrement() / 10000));
}
VOID FASTCALL IdlePing(VOID);
VOID FASTCALL IdlePong(VOID);
BOOL FASTCALL co_MsqReplyMessage(LRESULT);

View file

@ -399,7 +399,6 @@ PostTimerMessages(PWND Window)
PTHREADINFO pti;
BOOL Hit = FALSE;
PTIMER pTmr;
LARGE_INTEGER TickCount;
pti = PsGetCurrentThreadWin32Thread();
@ -412,13 +411,11 @@ PostTimerMessages(PWND Window)
(pTmr->pti == pti) &&
((pTmr->pWnd == Window) || (Window == NULL)) )
{
KeQueryTickCount(&TickCount);
Msg.hwnd = (pTmr->pWnd) ? pTmr->pWnd->head.h : 0;
Msg.message = (pTmr->flags & TMRF_SYSTEM) ? WM_SYSTIMER : WM_TIMER;
Msg.wParam = (WPARAM) pTmr->nID;
Msg.lParam = (LPARAM) pTmr->pfn;
Msg.time = MsqCalculateMessageTime(&TickCount);
Msg.time = EngGetTickCount32();
// Fix all wine win:test_GetMessagePos WM_TIMER tests. See CORE-10867.
Msg.pt = gpsi->ptCursor;
@ -448,7 +445,7 @@ VOID
FASTCALL
ProcessTimers(VOID)
{
LARGE_INTEGER TickCount, DueTime;
LARGE_INTEGER DueTime;
LONG Time;
PLIST_ENTRY pLE;
PTIMER pTmr;
@ -456,8 +453,7 @@ ProcessTimers(VOID)
TimerEnterExclusive();
pLE = TimersListHead.Flink;
KeQueryTickCount(&TickCount);
Time = MsqCalculateMessageTime(&TickCount);
Time = EngGetTickCount32();
DueTime.QuadPart = (LONGLONG)(-97656); // 1024hz .9765625 ms set to 10.0 ms