Browse Source

Fixed Windows 11 secondary taskbar context menu when auto hide is on

pull/886/head
Valentin Radu 4 years ago
parent
commit
008eddd597
  1. 72
      ExplorerPatcher/dllmain.c

72
ExplorerPatcher/dllmain.c

@ -1456,7 +1456,11 @@ BOOL Shell_TrayWnd_IsTaskbarRightClick(POINT pt)
} }
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
WCHAR wszClassName[200];
GetClassNameW(hWnd, wszClassName, 200);
if (IsWindow(hWnd)) if (IsWindow(hWnd))
{
if (!wcscmp(wszClassName, L"Windows.UI.Input.InputSite.WindowClass"))
{ {
HWND hAncestor = GetAncestor(hWnd, GA_ROOT); HWND hAncestor = GetAncestor(hWnd, GA_ROOT);
HWND hWindow = FindWindowExW(hAncestor, NULL, L"Windows.UI.Composition.DesktopWindowContentBridge", NULL); HWND hWindow = FindWindowExW(hAncestor, NULL, L"Windows.UI.Composition.DesktopWindowContentBridge", NULL);
@ -1472,6 +1476,64 @@ BOOL Shell_TrayWnd_IsTaskbarRightClick(POINT pt)
} }
} }
} }
else if (!wcscmp(wszClassName, L"MSTaskListWClass"))
{
IUIAutomationTreeWalker* pControlWalker = NULL;
IUIAutomationElement* pTaskbarButton = NULL;
IUIAutomationElement* pNextTaskbarButton = NULL;
RECT rc;
if (SUCCEEDED(hr))
{
hr = pIUIAutomation2->lpVtbl->get_RawViewWalker(pIUIAutomation2, &pControlWalker);
}
if (SUCCEEDED(hr) && pControlWalker)
{
hr = pControlWalker->lpVtbl->GetFirstChildElement(pControlWalker, pIUIAutomationElement, &pTaskbarButton);
}
BOOL bValid = TRUE, bFirst = TRUE;
while (SUCCEEDED(hr) && pTaskbarButton)
{
pControlWalker->lpVtbl->GetNextSiblingElement(pControlWalker, pTaskbarButton, &pNextTaskbarButton);
SetRect(&rc, 0, 0, 0, 0);
pTaskbarButton->lpVtbl->get_CurrentBoundingRectangle(pTaskbarButton, &rc);
if (bFirst)
{
// Account for Start button as well
rc.left -= (rc.right - rc.left);
bFirst = FALSE;
}
//printf("PT %d %d RECT %d %d %d %d\n", pt.x, pt.y, rc.left, rc.top, rc.right, rc.bottom);
if (pNextTaskbarButton && PtInRect(&rc, pt))
{
bValid = FALSE;
}
pTaskbarButton->lpVtbl->Release(pTaskbarButton);
pTaskbarButton = pNextTaskbarButton;
}
//printf("IS VALID %d\n", bValid);
//printf("\n");
if (pControlWalker)
{
pControlWalker->lpVtbl->Release(pControlWalker);
}
if (bValid)
{
HWND hAncestor = GetAncestor(hWnd, GA_ROOT);
HWND hWindow = FindWindowExW(hAncestor, NULL, L"WorkerW", NULL);
if (IsWindow(hWindow))
{
hWindow = FindWindowExW(hWindow, NULL, L"MSTaskListWClass", NULL);
if (IsWindow(hWindow))
{
if (hWindow == hWnd)
{
bRet = TRUE;
}
}
}
}
}
}
} }
if (pIUIAutomationElement) if (pIUIAutomationElement)
{ {
@ -1516,6 +1578,14 @@ INT64 Shell_TrayWndSubclassProc(
{ {
RemoveWindowSubclass(hWnd, Shell_TrayWndSubclassProc, Shell_TrayWndSubclassProc); RemoveWindowSubclass(hWnd, Shell_TrayWndSubclassProc, Shell_TrayWndSubclassProc);
} }
else if (!bIsPrimaryTaskbar && uMsg == WM_CONTEXTMENU)
{
// Received some times when right clicking a secondary taskbar button, and it would
// show the classic taskbar context menu but containing only "Show desktop" instead
// of ours or a button's jump list, so we cancel it and that seems to properly invoke
// the right menu
return 0;
}
else if (!bIsPrimaryTaskbar && uMsg == WM_SETCURSOR) else if (!bIsPrimaryTaskbar && uMsg == WM_SETCURSOR)
{ {
// Received when mouse is over taskbar edge and autohide is on // Received when mouse is over taskbar edge and autohide is on
@ -1551,7 +1621,7 @@ INT64 Shell_TrayWndSubclassProc(
} }
return lRes;*/ return lRes;*/
} }
else if (uMsg == WM_DISPLAYCHANGE) else if (bIsPrimaryTaskbar && uMsg == WM_DISPLAYCHANGE)
{ {
UpdateStartMenuPositioning(MAKELPARAM(TRUE, FALSE)); UpdateStartMenuPositioning(MAKELPARAM(TRUE, FALSE));
} }

Loading…
Cancel
Save