From b17d08b7a6f9688a80cd993b88a04a6ca257c09b Mon Sep 17 00:00:00 2001 From: ge0rdi Date: Tue, 19 Nov 2024 07:12:20 +0100 Subject: [PATCH] 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/ --- Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp b/Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp index d8da25b..ce80cee 100644 --- a/Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp +++ b/Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp @@ -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;