From ed585faa1dc07ca96db018f3d1737108b50132e7 Mon Sep 17 00:00:00 2001 From: Katayama Hirofumi MZ Date: Mon, 18 Oct 2021 20:54:15 +0900 Subject: [PATCH] [EXPLORER] Send WM_POPUPSYSTEMMENU asynchronizedly --- base/shell/explorer/taskswnd.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/base/shell/explorer/taskswnd.cpp b/base/shell/explorer/taskswnd.cpp index 5d90d36ebc3b..d6e6d2a97ac9 100644 --- a/base/shell/explorer/taskswnd.cpp +++ b/base/shell/explorer/taskswnd.cpp @@ -1630,6 +1630,11 @@ class CTaskSwitchWnd : 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 @@ class CTaskSwitchWnd : 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)