Skip to content

Commit 7044592

Browse files
committed
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
1 parent 04770c4 commit 7044592

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Src/StartMenu/StartMenuDLL/MenuContainer.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7652,6 +7652,9 @@ HWND CMenuContainer::ToggleStartMenu( int taskbarId, bool bKeyboard, bool bAllPr
76527652
// initialize all settings
76537653
bool bErr=false;
76547654
HMONITOR initialMonitor=MonitorFromWindow(s_TaskBar,MONITOR_DEFAULTTONEAREST);
7655+
// note: GetTaskbarPosition properly identifies monitor in case of multi-monitor setup and automatic taskbar hiding
7656+
GetTaskbarPosition(s_TaskBar,NULL,&initialMonitor,NULL);
7657+
76557658
int dpi=CItemManager::GetDPI(true);
76567659
if (!CItemManager::GetDPIOverride() && GetWinVersion()>=WIN_VER_WIN81)
76577660
{

Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,12 +617,12 @@ UINT GetTaskbarPosition( HWND taskBar, MONITORINFO *pInfo, HMONITOR *pMonitor, R
617617
if (pRc->right>rc.right) pRc->right=rc.right;
618618
}
619619
}
620+
HMONITOR monitor=MonitorFromRect(&appbar.rc,MONITOR_DEFAULTTONEAREST);
621+
if (pMonitor) *pMonitor=monitor;
620622
if (pInfo)
621623
{
622624
pInfo->cbSize=sizeof(MONITORINFO);
623-
HMONITOR monitor=MonitorFromRect(&appbar.rc,MONITOR_DEFAULTTONEAREST);
624625
GetMonitorInfo(monitor,pInfo);
625-
if (pMonitor) *pMonitor=monitor;
626626
}
627627
return appbar.uEdge;
628628
}

0 commit comments

Comments
 (0)