mirror of
https://github.com/microsoft/terminal.git
synced 2025-12-10 18:43:54 -06:00
Fix a couple issues with experimental.useBackgroundImageForWindow (#14456)
This fixes two issues with `experimental.useBackgroundImageForWindow` I discovered while looking at #14260 * It looks like the opacity of the whole-window BG image wouldn't hot reload if the path didn't. * > set useBGForWindow:true, focus a pane with an image, then set it to useBGForWindow:false, and observe a pane with <100 opacity. You'll be able to see the BG image left behind! These are pretty easy to miss, so I can see how it happened. I don't think this _technically_ closes that thread, though. Ultimately, I think OP's settings were just wrong (and possible didn't hot-reload). There's another, trickier bit I'm discussing in that thread, that might deserve its own separate follow-up for discussion.
This commit is contained in:
parent
b6b1ff8b2c
commit
f2eed92345
@ -2615,6 +2615,12 @@ namespace winrt::TerminalApp::implementation
|
||||
// - <none>
|
||||
void TerminalPage::_SetBackgroundImage(const winrt::Microsoft::Terminal::Settings::Model::IAppearanceConfig& newAppearance)
|
||||
{
|
||||
if (!_settings.GlobalSettings().UseBackgroundImageForWindow())
|
||||
{
|
||||
_tabContent.Background(nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
const auto path = newAppearance.ExpandedBackgroundImagePath();
|
||||
if (path.empty())
|
||||
{
|
||||
@ -2652,9 +2658,14 @@ namespace winrt::TerminalApp::implementation
|
||||
Media::Imaging::BitmapImage image(imageUri);
|
||||
b.ImageSource(image);
|
||||
_tabContent.Background(b);
|
||||
}
|
||||
|
||||
b.Stretch(newAppearance.BackgroundImageStretchMode());
|
||||
b.Opacity(newAppearance.BackgroundImageOpacity());
|
||||
// Pull this into a separate block. If the image didn't change, but the
|
||||
// properties of the image did, we should still update them.
|
||||
if (const auto newBrush{ _tabContent.Background().try_as<Media::ImageBrush>() })
|
||||
{
|
||||
newBrush.Stretch(newAppearance.BackgroundImageStretchMode());
|
||||
newBrush.Opacity(newAppearance.BackgroundImageOpacity());
|
||||
}
|
||||
}
|
||||
|
||||
@ -2688,18 +2699,6 @@ namespace winrt::TerminalApp::implementation
|
||||
profileGuidSettingsMap.insert_or_assign(newProfile.Guid(), std::pair{ newProfile, nullptr });
|
||||
}
|
||||
|
||||
if (_settings.GlobalSettings().UseBackgroundImageForWindow())
|
||||
{
|
||||
const auto focusedTab{ _GetFocusedTabImpl() };
|
||||
if (focusedTab)
|
||||
{
|
||||
auto profile = focusedTab->GetFocusedProfile();
|
||||
if (profile)
|
||||
{
|
||||
_SetBackgroundImage(profile.DefaultAppearance());
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const auto& tab : _tabs)
|
||||
{
|
||||
if (auto terminalTab{ _GetTerminalTabImpl(tab) })
|
||||
@ -2745,6 +2744,14 @@ namespace winrt::TerminalApp::implementation
|
||||
tabImpl->SetActionMap(_settings.ActionMap());
|
||||
}
|
||||
|
||||
if (const auto focusedTab{ _GetFocusedTabImpl() })
|
||||
{
|
||||
if (const auto profile{ focusedTab->GetFocusedProfile() })
|
||||
{
|
||||
_SetBackgroundImage(profile.DefaultAppearance());
|
||||
}
|
||||
}
|
||||
|
||||
// repopulate the new tab button's flyout with entries for each
|
||||
// profile, which might have changed
|
||||
_UpdateTabWidthMode();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user