This is the start of fixing the opacity roundtripping weirdness

This commit is contained in:
Mike Griese 2021-10-20 10:47:12 -05:00
parent a9de82e4ee
commit 70b9f8ce5f
3 changed files with 28 additions and 9 deletions

View file

@ -441,8 +441,16 @@ namespace winrt::Microsoft::Terminal::Control::implementation
1.0);
// GH#5098: Inform the engine of the new opacity of the default text background.
SetBackgroundOpacity(::base::saturated_cast<float>(newOpacity));
// TODO! This doesn't work when (aa:cleartype && useAcrylic:true &&
// opacity<1.0 -> 1.0) We end up forcing the solid BG, but the padding
// around the terminal is still acrylic. I think we only need to tell
// the engine to do the solid BG trick for useAcrylic:true, not for
// vintage opacity. Lets find out.
//
// SetBackgroundOpacity(newOpacity);
// Update our runtime opacity value
Opacity(newOpacity);
// GH#11285 - If the user is on Windows 10, and they changed the
@ -580,6 +588,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// - INVARIANT: This method can only be called if the caller DOES NOT HAVE writing lock on the terminal.
void ControlCore::UpdateSettings(const IControlSettings& settings, const IControlAppearance& newAppearance)
{
std::unique_lock l{ _settingsLock };
_settings = winrt::make_self<implementation::ControlSettings>(settings, newAppearance);
auto lock = _terminal->LockForWriting();
@ -620,6 +629,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
_renderEngine->SetForceFullRepaintRendering(_settings->ForceFullRepaintRendering());
_renderEngine->SetSoftwareRendering(_settings->SoftwareRendering());
// Inform the renderer of our opacity
_renderEngine->SetDefaultTextBackgroundOpacity(::base::saturated_cast<float>(Opacity()));
_updateAntiAliasingMode(_renderEngine.get());

View file

@ -25,6 +25,8 @@
#include "../buffer/out/search.h"
#include "cppwinrt_utils.h"
#include <til/ticket_lock.h>
namespace ControlUnitTests
{
class ControlCoreTests;
@ -57,7 +59,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation
void UpdateSettings(const Control::IControlSettings& settings, const IControlAppearance& newAppearance);
void ApplyAppearance(const bool& focused);
// void UpdateAppearance(const Control::IControlAppearance& newAppearance);
Control::IControlSettings Settings() const { return *_settings; };
Control::IControlSettings Settings()
{
auto l = std::unique_lock<til::ticket_lock>{ _settingsLock };
return *_settings;
};
Control::IControlAppearance FocusedAppearance() const { return *_settings->FocusedAppearance(); };
Control::IControlAppearance UnfocusedAppearance() const { return *_settings->UnfocusedAppearance(); };
@ -200,6 +206,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
TerminalConnection::ITerminalConnection::StateChanged_revoker _connectionStateChangedRevoker;
winrt::com_ptr<ControlSettings> _settings{ nullptr };
til::ticket_lock _settingsLock;
std::unique_ptr<::Microsoft::Terminal::Core::Terminal> _terminal{ nullptr };

View file

@ -464,11 +464,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation
RootGrid().Background(acrylic);
}
// GH#5098: Inform the engine of the new opacity of the default text background.
//
// TODO! This sure seems contrived, shouldn't the core... already
// know this?
_core.SetBackgroundOpacity(_core.Opacity());
// // GH#5098: Inform the engine of the new opacity of the default text background.
// //
// // TODO! This sure seems contrived, shouldn't the core... already
// // know this?
// _core.SetBackgroundOpacity(_core.Opacity());
}
else
{
@ -476,8 +476,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
solidColor.Opacity(_core.Opacity());
RootGrid().Background(solidColor);
// GH#5098: Inform the engine of the new opacity of the default text background.
_core.SetBackgroundOpacity(_core.Opacity());
// // GH#5098: Inform the engine of the new opacity of the default text background.
// // TODO! here too
// _core.SetBackgroundOpacity(_core.Opacity());
}
}