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/
This commit is contained in:
ge0rdi
2024-11-19 07:12:20 +01:00
parent cc3336ea26
commit b17d08b7a6

View File

@@ -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);
@@ -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;