Skip to content

Commit

Permalink
Win+X shows correctly on multi monitor setups
Browse files Browse the repository at this point in the history
  • Loading branch information
valinet committed Sep 1, 2021
1 parent 9074649 commit 557c74d
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions ExplorerPatcher/dllmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,8 @@ DWORD ShowLauncherTipContextMenu(
POINT GetDefaultWinXPosition()
{
POINT point, ptCursor;
point.x = 0;
point.y = 0;
GetCursorPos(&ptCursor);
HMONITOR hMonitor = MonitorFromPoint(ptCursor, MONITOR_DEFAULTTOPRIMARY);
MONITORINFO mi;
Expand All @@ -924,33 +926,37 @@ POINT GetDefaultWinXPosition()
),
&mi
);
HWND hWnd = FindWindowEx(
NULL,
NULL,
L"Shell_TrayWnd",
NULL
);
if (MonitorFromWindow(hWnd, MONITOR_DEFAULTTOPRIMARY) != hMonitor)
HWND hWnd = NULL;
do
{
hWnd = FindWindowEx(
NULL,
NULL,
hWnd,
L"Shell_SecondaryTrayWnd",
NULL
);
while (hWnd)
if (MonitorFromWindow(hWnd, MONITOR_DEFAULTTOPRIMARY) == hMonitor)
{
if (MonitorFromWindow(hWnd, MONITOR_DEFAULTTOPRIMARY) == hMonitor)
{
break;
}
hWnd = FindWindowEx(
NULL,
hWnd,
L"Shell_SecondaryTrayWnd",
NULL
);
break;
}
} while (hWnd);
if (!hWnd)
{
hWnd = FindWindowEx(
NULL,
NULL,
L"Shell_TrayWnd",
NULL
);
ptCursor.x = 0;
ptCursor.y = 0;
GetMonitorInfo(
MonitorFromPoint(
ptCursor,
MONITOR_DEFAULTTOPRIMARY
),
&mi
);
}
if (hWnd)
{
Expand Down

0 comments on commit 557c74d

Please sign in to comment.