From f36d589a8eb60fe9ff4c8efaad8eac088647e8a8 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Thu, 25 Apr 2024 04:55:28 -0700 Subject: [PATCH] Fix persisting the size of a focus mode window (#17068) While I was fixing the initial position thing, I figured I'd fix this too. We were mistakenly accounting for the size of the titlebar when we should launch into focus mode (without one) Closes #10730 --- src/cascadia/TerminalApp/TerminalWindow.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/cascadia/TerminalApp/TerminalWindow.cpp b/src/cascadia/TerminalApp/TerminalWindow.cpp index bd246bb53d..749fd2e842 100644 --- a/src/cascadia/TerminalApp/TerminalWindow.cpp +++ b/src/cascadia/TerminalApp/TerminalWindow.cpp @@ -562,9 +562,21 @@ namespace winrt::TerminalApp::implementation { winrt::Windows::Foundation::Size proposedSize{}; + // In focus mode, we don't want to include our own tab row in the size + // of the window that we hand back. So we account for passing + // --focusMode on the commandline here, and the mode in the settings. + // Below, we'll also account for if focus mode was persisted into the + // session for restoration. + bool focusMode = _appArgs.GetLaunchMode().value_or(_settings.GlobalSettings().LaunchMode()) == LaunchMode::FocusMode; + const auto scale = static_cast(dpi) / static_cast(USER_DEFAULT_SCREEN_DPI); if (const auto layout = LoadPersistedLayout()) { + if (layout.LaunchMode()) + { + focusMode = layout.LaunchMode().Value() == LaunchMode::FocusMode; + } + if (layout.InitialSize()) { proposedSize = layout.InitialSize().Value(); @@ -602,7 +614,7 @@ namespace winrt::TerminalApp::implementation // GH#2061 - If the global setting "Always show tab bar" is // set or if "Show tabs in title bar" is set, then we'll need to add // the height of the tab bar here. - if (_settings.GlobalSettings().ShowTabsInTitlebar()) + if (_settings.GlobalSettings().ShowTabsInTitlebar() && !focusMode) { // In the past, we used to actually instantiate a TitlebarControl // and use Measure() to determine the DesiredSize of the control, to @@ -620,7 +632,7 @@ namespace winrt::TerminalApp::implementation static constexpr auto titlebarHeight = 40; proposedSize.Height += (titlebarHeight)*scale; } - else if (_settings.GlobalSettings().AlwaysShowTabs()) + else if (_settings.GlobalSettings().AlwaysShowTabs() && !focusMode) { // Same comment as above, but with a TabRowControl. //