Repository: microsoft/terminal
File: src/cascadia/TerminalApp/TerminalPage.cpp (C++)

Code before:
                        rootPane->UpdateResources(_paneResources);
                    }
                }
            }
        }

        const auto res = Application::Current().Resources();

        // Use our helper to lookup the theme-aware version of the resource.
        const auto tabViewBackgroundKey = winrt::box_value(L"TabViewBackground");
        const auto backgroundSolidBrush = ThemeLookup(res, requestedTheme, tabViewBackgroundKey).as<Media::SolidColorBrush>();

        til::color bgColor = backgroundSolidBrush.Color();

        const auto getTerminalBrush = [this]() -> Media::Brush {
            if (const auto& control{ _GetActiveControl() })
            {
                return control.BackgroundBrush();
            }
            else if (auto settingsTab = _GetFocusedTab().try_as<TerminalApp::SettingsTab>())
            {
                return settingsTab.Content().try_as<Settings::Editor::MainPage>().BackgroundBrush();
            }
            return nullptr;
        };
        const auto terminalBrush = getTerminalBrush();

        if (_settings.GlobalSettings().UseAcrylicInTabRow())
        {
            const auto acrylicBrush = Media::AcrylicBrush();
            acrylicBrush.BackgroundSource(Media::AcrylicBackgroundSource::HostBackdrop);
            acrylicBrush.FallbackColor(bgColor);
            acrylicBrush.TintColor(bgColor);
            acrylicBrush.TintOpacity(0.5);

            TitlebarBrush(acrylicBrush);
        }
        else if (auto tabRowBg{ theme.TabRow() ? (_activated ? theme.TabRow().Background() :
                                                               theme.TabRow().UnfocusedBackground()) :
                                                 ThemeColor{ nullptr } })
        {
            const auto themeBrush{ tabRowBg.Evaluate(res, terminalBrush, true) };
            bgColor = ThemeColor::ColorFromBrush(themeBrush);
            TitlebarBrush(themeBrush);
        }
        else
        {
            // Nothing was set in the theme - fall back to our original `TabViewBackground` color.
            TitlebarBrush(backgroundSolidBrush);
        }


Review comment (bug):
I was about to comment asking why this lambda is needed, when you can also just do this:
```cpp
Brush terminalBrush{ nullptr };
if (const auto& control{ _GetActiveControl() })
{
    terminalBrush = control.BackgroundBrush();
}
else if (auto settingsTab = _GetFocusedTab().try_as<TerminalApp::SettingsTab>())
{
    terminalBrush = settingsTab.Content().try_as<Settings::Editor::MainPage>().BackgroundBrush();
}
```

but then I realized the code only moved. Still, you could consider making this change since it got changed anyways.

Code after:
                        rootPane->UpdateResources(_paneResources);
                    }
                }
            }
        }

        const auto res = Application::Current().Resources();

        // Use our helper to lookup the theme-aware version of the resource.
        const auto tabViewBackgroundKey = winrt::box_value(L"TabViewBackground");
        const auto backgroundSolidBrush = ThemeLookup(res, requestedTheme, tabViewBackgroundKey).as<Media::SolidColorBrush>();

        til::color bgColor = backgroundSolidBrush.Color();

        Media::Brush terminalBrush{ nullptr };
        if (const auto& control{ _GetActiveControl() })
        {
            terminalBrush = control.BackgroundBrush();
        }
        else if (const auto& settingsTab{ _GetFocusedTab().try_as<TerminalApp::SettingsTab>() })
        {
            terminalBrush = settingsTab.Content().try_as<Settings::Editor::MainPage>().BackgroundBrush();
        }

        if (_settings.GlobalSettings().UseAcrylicInTabRow())
        {
            const auto acrylicBrush = Media::AcrylicBrush();
            acrylicBrush.BackgroundSource(Media::AcrylicBackgroundSource::HostBackdrop);
            acrylicBrush.FallbackColor(bgColor);
            acrylicBrush.TintColor(bgColor);
            acrylicBrush.TintOpacity(0.5);

            TitlebarBrush(acrylicBrush);
        }
        else if (auto tabRowBg{ theme.TabRow() ? (_activated ? theme.TabRow().Background() :
                                                               theme.TabRow().UnfocusedBackground()) :
                                                 ThemeColor{ nullptr } })
        {
            const auto themeBrush{ tabRowBg.Evaluate(res, terminalBrush, true) };
            bgColor = ThemeColor::ColorFromBrush(themeBrush);
            TitlebarBrush(themeBrush);
        }
        else
        {
            // Nothing was set in the theme - fall back to our original `TabViewBackground` color.
            TitlebarBrush(backgroundSolidBrush);
        }

        if (!_settings.GlobalSettings().ShowTabsInTitlebar())
        {
            _tabRow.Background(TitlebarBrush());