Update the titlebar visibility when we gain/lose focus too (#14708)
We forgot to updateTheme again when we change the titlebar color. That would result in us setting the titlebar visibility only when the settings were reloaded, but if the unfocused BG was opaque, and the focused was transparent, we'd use the current _unfocused_ color to set the titlebar visibility. Also, this fixes a bug with `tabRow.BG: terminalBackground` from teams for brevity > tabRow.BG = terminalBackground might not work, and here's why > > the termcontrol's BG brush might be (r,g,b, 255), with an Opacity of 0 > > so my "use mica when the brush's A is <1.0" doesn't work > closes #14563
This commit is contained in:
parent
79eb9b3d3c
commit
596d0c5155
|
@ -1344,7 +1344,20 @@ winrt::fire_and_forget AppHost::_RenameWindowRequested(const winrt::Windows::Fou
|
|||
}
|
||||
}
|
||||
|
||||
bool _isActuallyDarkTheme(const auto requestedTheme)
|
||||
static double _opacityFromBrush(const winrt::Windows::UI::Xaml::Media::Brush& brush)
|
||||
{
|
||||
if (auto acrylic = brush.try_as<winrt::Windows::UI::Xaml::Media::AcrylicBrush>())
|
||||
{
|
||||
return acrylic.TintOpacity();
|
||||
}
|
||||
else if (auto solidColor = brush.try_as<winrt::Windows::UI::Xaml::Media::SolidColorBrush>())
|
||||
{
|
||||
return solidColor.Opacity();
|
||||
}
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
static bool _isActuallyDarkTheme(const auto requestedTheme)
|
||||
{
|
||||
switch (requestedTheme)
|
||||
{
|
||||
|
@ -1365,7 +1378,10 @@ void AppHost::_updateTheme()
|
|||
_window->OnApplicationThemeChanged(theme.RequestedTheme());
|
||||
|
||||
const auto b = _logic.TitlebarBrush();
|
||||
const auto opacity = b ? ThemeColor::ColorFromBrush(b).A / 255.0 : 0.0;
|
||||
const auto color = ThemeColor::ColorFromBrush(b);
|
||||
const auto colorOpacity = b ? color.A / 255.0 : 0.0;
|
||||
const auto brushOpacity = _opacityFromBrush(b);
|
||||
const auto opacity = std::min(colorOpacity, brushOpacity);
|
||||
_window->UseMica(theme.Window() ? theme.Window().UseMica() : false, opacity);
|
||||
|
||||
// This is a hack to make the window borders dark instead of light.
|
||||
|
@ -1639,6 +1655,7 @@ void AppHost::_PropertyChangedHandler(const winrt::Windows::Foundation::IInspect
|
|||
{
|
||||
auto nonClientWindow{ static_cast<NonClientIslandWindow*>(_window.get()) };
|
||||
nonClientWindow->SetTitlebarBackground(_logic.TitlebarBrush());
|
||||
_updateTheme();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue