From e74692815f517b8fab594d552d101d819b768416 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Fri, 27 Feb 2026 12:22:02 -0600 Subject: [PATCH] Dock: deal with multiple appbars on the same side (#45831) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit notes inline with code. Need to adjust the opposite side of the appbar for our size. These APIs are documented so well, it's no wonder more folks don't use them 🙃 related to #45824 tracked in #45584 --------- Co-authored-by: Niels Laute --- .../Dock/DockWindow.xaml.cs | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Dock/DockWindow.xaml.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/Dock/DockWindow.xaml.cs index 6471980810..7933134191 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Dock/DockWindow.xaml.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Dock/DockWindow.xaml.cs @@ -288,10 +288,34 @@ public sealed partial class DockWindow : WindowEx, var edgeWidth = PInvoke.GetSystemMetrics(SYSTEM_METRICS_INDEX.SM_CXEDGE); var frameWidth = PInvoke.GetSystemMetrics(SYSTEM_METRICS_INDEX.SM_CXFRAME); - UpdateAppBarDataForEdge(_settings.Side, _settings.DockSize, dpi / 96.0); + var scaleFactor = dpi / 96.0; + UpdateAppBarDataForEdge(_settings.Side, _settings.DockSize, scaleFactor); // Query and set position PInvoke.SHAppBarMessage(PInvoke.ABM_QUERYPOS, ref _appBarData); + + // ABM_QUERYPOS adjusts our rect so we don't overlap other app bars, + // but it may have shifted our anchored edge without updating the + // opposite edge. We need to re-apply our desired thickness so the + // bar keeps its correct size. Without this, a second bar docked to + // the same side would get a zero-height/width rect and fail to + // reserve work-area space. + switch (_settings.Side) + { + case DockSide.Top: + _appBarData.rc.bottom = _appBarData.rc.top + (int)(DockSettingsToViews.HeightForSize(_settings.DockSize) * scaleFactor); + break; + case DockSide.Bottom: + _appBarData.rc.top = _appBarData.rc.bottom - (int)(DockSettingsToViews.HeightForSize(_settings.DockSize) * scaleFactor); + break; + case DockSide.Left: + _appBarData.rc.right = _appBarData.rc.left + (int)(DockSettingsToViews.WidthForSize(_settings.DockSize) * scaleFactor); + break; + case DockSide.Right: + _appBarData.rc.left = _appBarData.rc.right - (int)(DockSettingsToViews.WidthForSize(_settings.DockSize) * scaleFactor); + break; + } + PInvoke.SHAppBarMessage(PInvoke.ABM_SETPOS, ref _appBarData); // TODO: investigate ABS_AUTOHIDE and auto hide bars.