[0.4.9][NTUSER][USER32] Tracking menu CORE-17338 (#4048), [EXPLORER] Send WM_POPUPSYSTEMMENU asynchronously (#4047) CORE-16353

This prevents the tracking menu from erroneously closing itself right after it was opened in some cases.
Fixes CORE-17338 which got unhidden by 0.4.15-dev-1126-g 58b0558f94
And fixes CORE-15760 which got unhidden by SVN r74972 == git 19dd22d422

Since both symptoms look very similar but the unhiding revisions did differ,
that could mean we do have some kind of race condition here.
I guess this fix is more like a workaround.

2 Fixes picked:
0.4.15-dev-3313-g 6417b2323d [NTUSER][USER32] Workaround tracking menu on CORE-17338 CORE-15760 (#4048)
to prevent the menu from auto-closing

and
0.4.15-dev-3297-g 037c744eb1 [EXPLORER] Send WM_POPUPSYSTEMMENU asynchronously CORE-16353 (#4047)
to make the taskbar button turn into pressed state when the menu opens
This commit is contained in:
Joachim Henze 2022-01-10 07:18:41 +01:00
parent b6f78a26cf
commit 175fa27755
3 changed files with 14 additions and 2 deletions

View file

@ -1635,6 +1635,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)
{
@ -1645,7 +1650,11 @@ public:
ActivateTask(TaskItem->hWnd);
::SendMessageW(TaskItem->hWnd, WM_POPUPSYSTEMMENU, 0, MAKELPARAM(pt.x, pt.y));
if (GetForegroundWindow() != TaskItem->hWnd)
ERR("HandleTaskItemRightClick detected the window did not become foreground\n");
::SendMessageCallbackW(TaskItem->hWnd, WM_POPUPSYSTEMMENU, 0, MAKELPARAM(pt.x, pt.y),
SendAsyncProc, (ULONG_PTR)TaskItem);
}
VOID HandleTaskGroupRightClick(IN OUT PTASK_GROUP TaskGroup)