Browse Source

Win+X shows correctly on multi monitor setups

pull/20/head
Valentin Radu 4 years ago
parent
commit
557c74da28
  1. 32
      ExplorerPatcher/dllmain.c

32
ExplorerPatcher/dllmain.c

@ -913,6 +913,8 @@ DWORD ShowLauncherTipContextMenu(
POINT GetDefaultWinXPosition() POINT GetDefaultWinXPosition()
{ {
POINT point, ptCursor; POINT point, ptCursor;
point.x = 0;
point.y = 0;
GetCursorPos(&ptCursor); GetCursorPos(&ptCursor);
HMONITOR hMonitor = MonitorFromPoint(ptCursor, MONITOR_DEFAULTTOPRIMARY); HMONITOR hMonitor = MonitorFromPoint(ptCursor, MONITOR_DEFAULTTOPRIMARY);
MONITORINFO mi; MONITORINFO mi;
@ -924,33 +926,37 @@ POINT GetDefaultWinXPosition()
), ),
&mi &mi
); );
HWND hWnd = FindWindowEx( HWND hWnd = NULL;
NULL, do
NULL,
L"Shell_TrayWnd",
NULL
);
if (MonitorFromWindow(hWnd, MONITOR_DEFAULTTOPRIMARY) != hMonitor)
{ {
hWnd = FindWindowEx( hWnd = FindWindowEx(
NULL, NULL,
NULL, hWnd,
L"Shell_SecondaryTrayWnd", L"Shell_SecondaryTrayWnd",
NULL NULL
); );
while (hWnd)
{
if (MonitorFromWindow(hWnd, MONITOR_DEFAULTTOPRIMARY) == hMonitor) if (MonitorFromWindow(hWnd, MONITOR_DEFAULTTOPRIMARY) == hMonitor)
{ {
break; break;
} }
} while (hWnd);
if (!hWnd)
{
hWnd = FindWindowEx( hWnd = FindWindowEx(
NULL, NULL,
hWnd, NULL,
L"Shell_SecondaryTrayWnd", L"Shell_TrayWnd",
NULL NULL
); );
} ptCursor.x = 0;
ptCursor.y = 0;
GetMonitorInfo(
MonitorFromPoint(
ptCursor,
MONITOR_DEFAULTTOPRIMARY
),
&mi
);
} }
if (hWnd) if (hWnd)
{ {

Loading…
Cancel
Save