mirror of
https://github.com/Open-Shell/Open-Shell-Menu.git
synced 2026-04-11 17:37:22 +10:00
Properly handle automatically hiding taskbar on multi-monitor setup
When taskbar is hidden its window is moved off the screen (except for few pixels at border). It may happen that the taskbar window actually spans to another monitor (though still not visible). MonitorFromWindow API may thus return different monitor handle than the one visible taskbar is on. We will use GetTaskbarPosition function that correctly identifies taskbar's monitor by checking rectangle of visible taskbar. Fixes #908
This commit is contained in:
@@ -7652,6 +7652,9 @@ HWND CMenuContainer::ToggleStartMenu( int taskbarId, bool bKeyboard, bool bAllPr
|
||||
// initialize all settings
|
||||
bool bErr=false;
|
||||
HMONITOR initialMonitor=MonitorFromWindow(s_TaskBar,MONITOR_DEFAULTTONEAREST);
|
||||
// note: GetTaskbarPosition properly identifies monitor in case of multi-monitor setup and automatic taskbar hiding
|
||||
GetTaskbarPosition(s_TaskBar,NULL,&initialMonitor,NULL);
|
||||
|
||||
int dpi=CItemManager::GetDPI(true);
|
||||
if (!CItemManager::GetDPIOverride() && GetWinVersion()>=WIN_VER_WIN81)
|
||||
{
|
||||
|
||||
@@ -617,12 +617,12 @@ UINT GetTaskbarPosition( HWND taskBar, MONITORINFO *pInfo, HMONITOR *pMonitor, R
|
||||
if (pRc->right>rc.right) pRc->right=rc.right;
|
||||
}
|
||||
}
|
||||
HMONITOR monitor=MonitorFromRect(&appbar.rc,MONITOR_DEFAULTTONEAREST);
|
||||
if (pMonitor) *pMonitor=monitor;
|
||||
if (pInfo)
|
||||
{
|
||||
pInfo->cbSize=sizeof(MONITORINFO);
|
||||
HMONITOR monitor=MonitorFromRect(&appbar.rc,MONITOR_DEFAULTTONEAREST);
|
||||
GetMonitorInfo(monitor,pInfo);
|
||||
if (pMonitor) *pMonitor=monitor;
|
||||
}
|
||||
return appbar.uEdge;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user