Skip to content

Commit b17d08b

Browse files
committed
Fix start button/menu misalignment on touch-screen devices
Windows 11 22H2 introduced new touch-optimized taskbar for devices with touch screen. It seems that in this mode taskbar window size is bigger than actual taskbar on screen. There is region defined for the window that covers actually displayed portion of the window. We should account for that region (if present) when obtaining taskbar window dimensions. More info about how to enable/disable touch taskbar: https://www.elevenforum.com/t/turn-on-or-off-tablet-optimized-taskbar-in-windows-11.5133/
1 parent cc3336e commit b17d08b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,11 @@ UINT GetTaskbarPosition( HWND taskBar, MONITORINFO *pInfo, HMONITOR *pMonitor, R
603603
SHAppBarMessage(ABM_GETTASKBARPOS,&appbar);
604604
if (pRc)
605605
{
606+
if (RECT rc; GetWindowRgnBox(taskBar,&rc)!=ERROR)
607+
{
608+
MapWindowPoints(taskBar,NULL,(POINT*)&rc,2);
609+
appbar.rc=rc;
610+
}
606611
*pRc=appbar.rc;
607612
RECT rc;
608613
GetWindowRect(taskBar,&rc);
@@ -1217,9 +1222,8 @@ static void UpdateStartButtonPosition(const TaskbarInfo* taskBar, const WINDOWPO
12171222
RecreateStartButton(taskBar->taskbarId);
12181223

12191224
RECT rcTask;
1220-
GetWindowRect(taskBar->taskBar, &rcTask);
12211225
MONITORINFO info;
1222-
UINT uEdge = GetTaskbarPosition(taskBar->taskBar, &info, NULL, NULL);
1226+
UINT uEdge = GetTaskbarPosition(taskBar->taskBar, &info, NULL, &rcTask);
12231227
DWORD buttonFlags = SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSIZE;
12241228
if (IsWindowVisible(taskBar->taskBar))
12251229
buttonFlags |= SWP_SHOWWINDOW;

0 commit comments

Comments
 (0)