[EXPLORER] Send WM_POPUPSYSTEMMENU asynchronously (#4047)

- Delete useless SendMessageTimeout:WM_NULL call.
- Add useful SendMessageCallbackW:WM_POPUPSYSTEMMENU call.
- In the callback function of SendMessageCallbackW, do PostMessageW:WM_NULL to properly handle the popup menu.
CORE-16353
This commit is contained in:
Katayama Hirofumi MZ 2021-10-19 07:17:01 +09:00 committed by GitHub
parent 46fbc6f432
commit 037c744eb1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1630,6 +1630,11 @@ public:
return FALSE;
}
static VOID CALLBACK
SendAsyncProc(HWND hwnd, UINT uMsg, DWORD_PTR dwData, LRESULT lResult)
{
::PostMessageW(hwnd, WM_NULL, 0, 0);
}
VOID HandleTaskItemRightClick(IN OUT PTASK_ITEM TaskItem)
{
@ -1640,14 +1645,11 @@ public:
ActivateTask(TaskItem->hWnd);
/* Wait up to 2 seconds for the window to process the foreground notification. */
DWORD_PTR resultDummy;
if (!SendMessageTimeout(TaskItem->hWnd, WM_NULL, 0, 0, 0, 2000, &resultDummy))
ERR("HandleTaskItemRightClick detected the window was unresponsive for 2 seconds, or was destroyed\n");
if (GetForegroundWindow() != TaskItem->hWnd)
ERR("HandleTaskItemRightClick detected the window did not become foreground\n");
::SendMessageW(TaskItem->hWnd, WM_POPUPSYSTEMMENU, 0, MAKELPARAM(pt.x, pt.y));
::SendMessageCallbackW(TaskItem->hWnd, WM_POPUPSYSTEMMENU, 0, MAKELPARAM(pt.x, pt.y),
SendAsyncProc, (ULONG_PTR)TaskItem);
}
VOID HandleTaskGroupRightClick(IN OUT PTASK_GROUP TaskGroup)