Skip to content

Commit

Permalink
Fix persisting the size of a focus mode window (#17068)
Browse files Browse the repository at this point in the history
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

(cherry picked from commit f36d589)
Service-Card-Id: 92410732
Service-Version: 1.20
  • Loading branch information
zadjii-msft authored and DHowett committed Apr 26, 2024
1 parent fb3147f commit 464c0a3
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/cascadia/TerminalApp/TerminalWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<float>(dpi) / static_cast<float>(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();
Expand Down Expand Up @@ -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
Expand All @@ -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.
//
Expand Down

0 comments on commit 464c0a3

Please sign in to comment.