Skip to content

Commit f36d589

Browse files
authored
Fix persisting the size of a focus mode window (microsoft#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 microsoft#10730
1 parent 0c3c747 commit f36d589

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/cascadia/TerminalApp/TerminalWindow.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,9 +562,21 @@ namespace winrt::TerminalApp::implementation
562562
{
563563
winrt::Windows::Foundation::Size proposedSize{};
564564

565+
// In focus mode, we don't want to include our own tab row in the size
566+
// of the window that we hand back. So we account for passing
567+
// --focusMode on the commandline here, and the mode in the settings.
568+
// Below, we'll also account for if focus mode was persisted into the
569+
// session for restoration.
570+
bool focusMode = _appArgs.GetLaunchMode().value_or(_settings.GlobalSettings().LaunchMode()) == LaunchMode::FocusMode;
571+
565572
const auto scale = static_cast<float>(dpi) / static_cast<float>(USER_DEFAULT_SCREEN_DPI);
566573
if (const auto layout = LoadPersistedLayout())
567574
{
575+
if (layout.LaunchMode())
576+
{
577+
focusMode = layout.LaunchMode().Value() == LaunchMode::FocusMode;
578+
}
579+
568580
if (layout.InitialSize())
569581
{
570582
proposedSize = layout.InitialSize().Value();
@@ -602,7 +614,7 @@ namespace winrt::TerminalApp::implementation
602614
// GH#2061 - If the global setting "Always show tab bar" is
603615
// set or if "Show tabs in title bar" is set, then we'll need to add
604616
// the height of the tab bar here.
605-
if (_settings.GlobalSettings().ShowTabsInTitlebar())
617+
if (_settings.GlobalSettings().ShowTabsInTitlebar() && !focusMode)
606618
{
607619
// In the past, we used to actually instantiate a TitlebarControl
608620
// and use Measure() to determine the DesiredSize of the control, to
@@ -620,7 +632,7 @@ namespace winrt::TerminalApp::implementation
620632
static constexpr auto titlebarHeight = 40;
621633
proposedSize.Height += (titlebarHeight)*scale;
622634
}
623-
else if (_settings.GlobalSettings().AlwaysShowTabs())
635+
else if (_settings.GlobalSettings().AlwaysShowTabs() && !focusMode)
624636
{
625637
// Same comment as above, but with a TabRowControl.
626638
//

0 commit comments

Comments
 (0)