From faf79de4d558f23b0493a96f0b23e83e80d25ee2 Mon Sep 17 00:00:00 2001 From: ge0rdi Date: Sat, 4 Jan 2025 16:10:52 +0100 Subject: [PATCH] Fix custom button position on auto-hiding taskbar Fixes #2067. --- Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp | 22 ++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp b/Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp index 5022f67f0..1a3c64db0 100644 --- a/Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp +++ b/Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp @@ -1216,6 +1216,19 @@ void EnableHotkeys( THotkeys enable ) } } +bool IsTouchTaskbar(void) +{ + if (!IsWin11()) + return false; + + CRegKey regKey; + if (regKey.Open(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer") != ERROR_SUCCESS) + return false; + + DWORD val; + return regKey.QueryDWORDValue(L"TabletPostureTaskbar", val) == ERROR_SUCCESS && val; +} + static void UpdateStartButtonPosition(const TaskbarInfo* taskBar, const WINDOWPOS* pPos) { if (IsStartButtonSmallIcons(taskBar->taskbarId) != IsTaskbarSmallIcons()) @@ -1223,10 +1236,13 @@ static void UpdateStartButtonPosition(const TaskbarInfo* taskBar, const WINDOWPO RECT rcTask; GetWindowRect(taskBar->taskBar, &rcTask); - if (RECT rc; GetWindowRgnBox(taskBar->taskBar, &rc) != ERROR) + if (IsTouchTaskbar()) { - MapWindowPoints(taskBar->taskBar, NULL, (POINT*)&rc, 2); - rcTask = rc; + if (RECT rc; GetWindowRgnBox(taskBar->taskBar, &rc) != ERROR) + { + MapWindowPoints(taskBar->taskBar, NULL, (POINT*)&rc, 2); + rcTask = rc; + } } MONITORINFO info; UINT uEdge = GetTaskbarPosition(taskBar->taskBar, &info, NULL, NULL);