Skip to content

Commit

Permalink
Fix start button/menu misalignment on touch-screen devices
Browse files Browse the repository at this point in the history
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/
  • Loading branch information
ge0rdi committed Apr 5, 2024
1 parent 7770e3b commit 5d1970b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,11 @@ UINT GetTaskbarPosition( HWND taskBar, MONITORINFO *pInfo, HMONITOR *pMonitor, R
SHAppBarMessage(ABM_GETTASKBARPOS,&appbar);
if (pRc)
{
if (RECT rc; GetWindowRgnBox(taskBar,&rc)!=ERROR)
{
MapWindowPoints(taskBar,NULL,(POINT*)&rc,2);
appbar.rc=rc;
}
*pRc=appbar.rc;
RECT rc;
GetWindowRect(taskBar,&rc);
Expand Down Expand Up @@ -1217,9 +1222,8 @@ static void UpdateStartButtonPosition(const TaskbarInfo* taskBar, const WINDOWPO
RecreateStartButton(taskBar->taskbarId);

RECT rcTask;
GetWindowRect(taskBar->taskBar, &rcTask);
MONITORINFO info;
UINT uEdge = GetTaskbarPosition(taskBar->taskBar, &info, NULL, NULL);
UINT uEdge = GetTaskbarPosition(taskBar->taskBar, &info, NULL, &rcTask);
DWORD buttonFlags = SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSIZE;
if (IsWindowVisible(taskBar->taskBar))
buttonFlags |= SWP_SHOWWINDOW;
Expand Down

0 comments on commit 5d1970b

Please sign in to comment.