diff --git a/src/cascadia/TerminalApp/TerminalPage.cpp b/src/cascadia/TerminalApp/TerminalPage.cpp index e9d5324bcb3..9f0c42cf66f 100644 --- a/src/cascadia/TerminalApp/TerminalPage.cpp +++ b/src/cascadia/TerminalApp/TerminalPage.cpp @@ -4101,24 +4101,27 @@ namespace winrt::TerminalApp::implementation TitlebarBrush(acrylicBrush); } - else if (theme.TabRow() && theme.TabRow().Background()) + else if (theme.TabRow()) { - const auto tabRowBg = theme.TabRow().Background(); - const auto terminalBrush = [this]() -> Media::Brush { - if (const auto& control{ _GetActiveControl() }) - { - return control.BackgroundBrush(); - } - else if (auto settingsTab = _GetFocusedTab().try_as()) - { - return settingsTab.Content().try_as().BackgroundBrush(); - } - return nullptr; - }(); + if (const auto tabRowBg{ _activated ? theme.TabRow().Background() : + theme.TabRow().UnfocusedBackground() }) + { + const auto terminalBrush = [this]() -> Media::Brush { + if (const auto& control{ _GetActiveControl() }) + { + return control.BackgroundBrush(); + } + else if (auto settingsTab = _GetFocusedTab().try_as()) + { + return settingsTab.Content().try_as().BackgroundBrush(); + } + return nullptr; + }(); - const auto themeBrush{ tabRowBg.Evaluate(res, terminalBrush, true) }; - bgColor = ThemeColor::ColorFromBrush(themeBrush); - TitlebarBrush(themeBrush); + const auto themeBrush{ tabRowBg.Evaluate(res, terminalBrush, true) }; + bgColor = ThemeColor::ColorFromBrush(themeBrush); + TitlebarBrush(themeBrush); + } } else { diff --git a/src/cascadia/TerminalSettingsModel/MTSMSettings.h b/src/cascadia/TerminalSettingsModel/MTSMSettings.h index b131cf59ad7..5aded2c6ee5 100644 --- a/src/cascadia/TerminalSettingsModel/MTSMSettings.h +++ b/src/cascadia/TerminalSettingsModel/MTSMSettings.h @@ -124,8 +124,9 @@ Author(s): X(winrt::Windows::UI::Xaml::ElementTheme, RequestedTheme, "applicationTheme", winrt::Windows::UI::Xaml::ElementTheme::Default) \ X(bool, UseMica, "useMica", false) -#define MTSM_THEME_TABROW_SETTINGS(X) \ - X(winrt::Microsoft::Terminal::Settings::Model::ThemeColor, Background, "background", nullptr) +#define MTSM_THEME_TABROW_SETTINGS(X) \ + X(winrt::Microsoft::Terminal::Settings::Model::ThemeColor, Background, "background", nullptr) \ + X(winrt::Microsoft::Terminal::Settings::Model::ThemeColor, UnfocusedBackground, "unfocusedBackground", nullptr) #define MTSM_THEME_TAB_SETTINGS(X) \ X(winrt::Microsoft::Terminal::Settings::Model::ThemeColor, Background, "background", nullptr) diff --git a/src/cascadia/TerminalSettingsModel/Theme.cpp b/src/cascadia/TerminalSettingsModel/Theme.cpp index 27826d6bb4e..46e7b52f71a 100644 --- a/src/cascadia/TerminalSettingsModel/Theme.cpp +++ b/src/cascadia/TerminalSettingsModel/Theme.cpp @@ -104,6 +104,10 @@ winrt::WUX::Media::Brush ThemeColor::Evaluate(const winrt::WUX::ResourceDictiona { case ThemeColorType::Accent: { + // NOTE: There is no canonical way to get the unfocused ACCENT titlebar + // color in Windows. Edge uses it's own heuristic, and in Windows 11, + // much of this logic is rapidly changing. We're not gonna mess with + // that, since it seems there's no good way to reverse engineer that. til::color accentColor = forTitlebar ? _getAccentColorForTitlebar() : til::color{ winrt::unbox_value(res.Lookup(accentColorKey)) }; diff --git a/src/cascadia/TerminalSettingsModel/Theme.idl b/src/cascadia/TerminalSettingsModel/Theme.idl index 5c295f7df6a..45df3c0c4a4 100644 --- a/src/cascadia/TerminalSettingsModel/Theme.idl +++ b/src/cascadia/TerminalSettingsModel/Theme.idl @@ -34,6 +34,7 @@ namespace Microsoft.Terminal.Settings.Model runtimeclass TabRowTheme { ThemeColor Background { get; }; + ThemeColor UnfocusedBackground { get; }; } runtimeclass TabTheme {