diff --git a/src/cascadia/LocalTests_TerminalApp/TabTests.cpp b/src/cascadia/LocalTests_TerminalApp/TabTests.cpp index 8036acd5942..1794ad63c72 100644 --- a/src/cascadia/LocalTests_TerminalApp/TabTests.cpp +++ b/src/cascadia/LocalTests_TerminalApp/TabTests.cpp @@ -86,6 +86,7 @@ namespace TerminalAppLocalTests TEST_METHOD(SwapPanes); TEST_METHOD(NextMRUTab); + TEST_METHOD(TabRowVisibilityReflectsTabCount); TEST_METHOD(VerifyCommandPaletteTabSwitcherOrder); TEST_METHOD(TestWindowRenameSuccessful); @@ -1144,6 +1145,24 @@ namespace TerminalAppLocalTests }); } + void TabTests::TabRowVisibilityReflectsTabCount() + { + auto page = _commonSetup(); + + TestOnUIThread([&page]() { + VERIFY_IS_FALSE(page->IsTabRowVisible(), L"Single tab with tabs hidden in title bar should not show the tab row."); + }); + + TestOnUIThread([&page]() { + NewTerminalArgs newTerminalArgs{ 1 }; + page->_OpenNewTab(newTerminalArgs); + }); + + TestOnUIThread([&page]() { + VERIFY_IS_TRUE(page->IsTabRowVisible(), L"Multiple tabs should make the tab row visible when tabs are outside the title bar."); + }); + } + void TabTests::VerifyCommandPaletteTabSwitcherOrder() { // This is a test for GH#8188 - we want to make sure that the order of tabs diff --git a/src/cascadia/TerminalApp/TabManagement.cpp b/src/cascadia/TerminalApp/TabManagement.cpp index ed57887cdd9..71e25ad87d9 100644 --- a/src/cascadia/TerminalApp/TabManagement.cpp +++ b/src/cascadia/TerminalApp/TabManagement.cpp @@ -244,11 +244,7 @@ namespace winrt::TerminalApp::implementation // - we're not in focus mode // - we're not in full screen, or the user has enabled fullscreen tabs // - there is more than one tab, or the user has chosen to always show tabs - const auto isVisible = !_isInFocusMode && - (!_isFullscreen || _showTabsFullscreen) && - (_settings.GlobalSettings().ShowTabsInTitlebar() || - (_tabs.Size() > 1) || - _settings.GlobalSettings().AlwaysShowTabs()); + const auto isVisible = IsTabRowVisible(); if (_tabView) { diff --git a/src/cascadia/TerminalApp/TerminalPage.cpp b/src/cascadia/TerminalApp/TerminalPage.cpp index f0043e5db77..e3b4086c4d9 100644 --- a/src/cascadia/TerminalApp/TerminalPage.cpp +++ b/src/cascadia/TerminalApp/TerminalPage.cpp @@ -4210,6 +4210,20 @@ namespace winrt::TerminalApp::implementation return _isAlwaysOnTop; } + bool TerminalPage::IsTabRowVisible() const + { + if (!_settings) + { + return false; + } + + return !_isInFocusMode && + (!_isFullscreen || _showTabsFullscreen) && + (_settings.GlobalSettings().ShowTabsInTitlebar() || + NumberOfTabs() > 1 || + _settings.GlobalSettings().AlwaysShowTabs()); + } + // Method Description: // - Returns true if the tab row should be visible when we're in full screen // state. diff --git a/src/cascadia/TerminalApp/TerminalPage.h b/src/cascadia/TerminalApp/TerminalPage.h index 81367851343..53a0848f337 100644 --- a/src/cascadia/TerminalApp/TerminalPage.h +++ b/src/cascadia/TerminalApp/TerminalPage.h @@ -130,6 +130,7 @@ namespace winrt::TerminalApp::implementation bool FocusMode() const; bool Fullscreen() const; bool AlwaysOnTop() const; + bool IsTabRowVisible() const; bool ShowTabsFullscreen() const; void SetShowTabsFullscreen(bool newShowTabsFullscreen); void SetFullscreen(bool); diff --git a/src/cascadia/TerminalApp/TerminalPage.idl b/src/cascadia/TerminalApp/TerminalPage.idl index ce15059864b..34349df1fb9 100644 --- a/src/cascadia/TerminalApp/TerminalPage.idl +++ b/src/cascadia/TerminalApp/TerminalPage.idl @@ -62,6 +62,8 @@ namespace TerminalApp Boolean Fullscreen { get; }; Boolean AlwaysOnTop { get; }; + Boolean IsTabRowVisible(); + WindowProperties WindowProperties { get; }; void IdentifyWindow(); diff --git a/src/cascadia/TerminalApp/TerminalWindow.cpp b/src/cascadia/TerminalApp/TerminalWindow.cpp index 2bb8cca2cf5..7528789db15 100644 --- a/src/cascadia/TerminalApp/TerminalWindow.cpp +++ b/src/cascadia/TerminalApp/TerminalWindow.cpp @@ -1314,29 +1314,27 @@ namespace winrt::TerminalApp::implementation winrt::Windows::Foundation::Size pixelSize = { static_cast(args.Width()), static_cast(args.Height()) }; const auto scale = static_cast(DisplayInformation::GetForCurrentView().RawPixelsPerViewPixel()); - if (!FocusMode()) - { - if (!_settings.GlobalSettings().AlwaysShowTabs()) - { - // Hide the title bar = off, Always show tabs = off. - static constexpr auto titlebarHeight = 10; - pixelSize.Height += (titlebarHeight)*scale; - } - else if (!_settings.GlobalSettings().ShowTabsInTitlebar()) - { - // Hide the title bar = off, Always show tabs = on. - static constexpr auto titlebarAndTabBarHeight = 40; - pixelSize.Height += (titlebarAndTabBarHeight)*scale; - } - // Hide the title bar = on, Always show tabs = on. - // In this case, we don't add any height because - // NonClientIslandWindow::GetTotalNonClientExclusiveSize() gets - // called in AppHost::_resizeWindow and it already takes title bar - // height into account. In other cases above - // IslandWindow::GetTotalNonClientExclusiveSize() is called, and it - // doesn't take the title bar height into account, so we have to do - // the calculation manually. - } + if (!FocusMode()) + { + const auto tabsInTitlebar = _settings.GlobalSettings().ShowTabsInTitlebar(); + const auto tabRowVisible = _root ? _root->IsTabRowVisible() : + (_settings.GlobalSettings().AlwaysShowTabs() || tabsInTitlebar); + + static constexpr auto titlebarHeight = 10; + static constexpr auto titlebarAndTabBarHeight = 40; + + if (tabRowVisible) + { + pixelSize.Height += titlebarAndTabBarHeight * scale; + } + else if (!tabsInTitlebar) + { + pixelSize.Height += titlebarHeight * scale; + } + // When tabs are hosted in the title bar but not visible we don't + // need to adjust the size – the non-client window chrome already + // accounts for it. + } args.Width(static_cast(pixelSize.Width)); args.Height(static_cast(pixelSize.Height));