From e1fccd89054ae0370bb53514f29009cb5d55ecd3 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Fri, 9 Dec 2022 12:50:56 -0800 Subject: [PATCH] Enable vintage opacity on Windows 10 (#14481) This reverts #11372 and #11285, and brings #11180 to everyone, now that MSFT:37879806 has been serviced to everyone in [KB5011831](https://support.microsoft.com/en-gb/topic/april-25-2022-kb5011831-os-builds-19042-1682-19043-1682-and-19044-1682-preview-fe4ff411-d25a-4185-aabb-8bc66e9dbb6c)[1]. I tested this on my home Win10 laptop that's super old and doesn't have a functioning clock, but it does have that update at the very least. I don't think we had an issue tracking this? [1]: I'm pretty sure about this at least (cherry picked from commit a5c5b8a50e6918667cbd41a5f57faaf9a645b40e) Service-Card-Id: 87176746 Service-Version: 1.16 --- src/cascadia/TerminalControl/ControlCore.cpp | 33 +++---------------- .../ProfileViewModel.cpp | 16 --------- .../TerminalSettingsEditor/ProfileViewModel.h | 15 --------- .../UnitTests_Control/ControlCoreTests.cpp | 2 +- .../ControlInteractivityTests.cpp | 2 +- 5 files changed, 7 insertions(+), 61 deletions(-) diff --git a/src/cascadia/TerminalControl/ControlCore.cpp b/src/cascadia/TerminalControl/ControlCore.cpp index d8b51468ccb..40cb7afc6e9 100644 --- a/src/cascadia/TerminalControl/ControlCore.cpp +++ b/src/cascadia/TerminalControl/ControlCore.cpp @@ -604,13 +604,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation // Update our runtime opacity value _runtimeOpacity = newOpacity; - // GH#11285 - If the user is on Windows 10, and they changed the - // transparency of the control s.t. it should be partially opaque, then - // opt them in to acrylic. It's the only way to have transparency on - // Windows 10. - // We'll also turn the acrylic back off when they're fully opaque, which - // is what the Terminal did prior to 1.12. - _runtimeUseAcrylic = newOpacity < 1.0 && (!IsVintageOpacityAvailable() || _settings->UseAcrylic()); + // Manually turn off acrylic if they turn off transparency. + _runtimeUseAcrylic = newOpacity < 1.0 && _settings->UseAcrylic(); // Update the renderer as well. It might need to fall back from // cleartype -> grayscale if the BG is transparent / acrylic. @@ -736,13 +731,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation auto lock = _terminal->LockForWriting(); - // GH#11285 - If the user is on Windows 10, and they wanted opacity, but - // didn't explicitly request acrylic, then opt them in to acrylic. - // On Windows 11+, this isn't needed, because we can have vintage opacity. - // Instead, disable acrylic while the opacity is 100% - _runtimeUseAcrylic = _settings->Opacity() < 1.0 && (!IsVintageOpacityAvailable() || _settings->UseAcrylic()); _runtimeOpacity = std::nullopt; + // Manually turn off acrylic if they turn off transparency. + _runtimeUseAcrylic = _settings->Opacity() < 1.0 && _settings->UseAcrylic(); + const auto sizeChanged = _setFontSizeUnderLock(_settings->FontSize()); // Update the terminal core with its new Core settings @@ -1759,22 +1752,6 @@ namespace winrt::Microsoft::Terminal::Control::implementation return hstring(ss.str()); } - // Helper to check if we're on Windows 11 or not. This is used to check if - // we need to use acrylic to achieve transparency, because vintage opacity - // doesn't work in islands on win10. - // Remove when we can remove the rest of GH#11285 - bool ControlCore::IsVintageOpacityAvailable() noexcept - { - OSVERSIONINFOEXW osver{}; - osver.dwOSVersionInfoSize = sizeof(osver); - osver.dwBuildNumber = 22000; - - DWORDLONG dwlConditionMask = 0; - VER_SET_CONDITION(dwlConditionMask, VER_BUILDNUMBER, VER_GREATER_EQUAL); - - return VerifyVersionInfoW(&osver, VER_BUILDNUMBER, dwlConditionMask) != FALSE; - } - Core::Scheme ControlCore::ColorScheme() const noexcept { Core::Scheme s; diff --git a/src/cascadia/TerminalSettingsEditor/ProfileViewModel.cpp b/src/cascadia/TerminalSettingsEditor/ProfileViewModel.cpp index fadf3d0a6b6..1cae80224e1 100644 --- a/src/cascadia/TerminalSettingsEditor/ProfileViewModel.cpp +++ b/src/cascadia/TerminalSettingsEditor/ProfileViewModel.cpp @@ -51,22 +51,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation // NOTE: this is similar to what is done with BackgroundImagePath above _NotifyChanges(L"UseParentProcessDirectory", L"UseCustomStartingDirectory"); } - else if (viewModelProperty == L"UseAcrylic") - { - // GH#11372: If we're on Windows 10, and someone turns off - // acrylic, we're going to disable opacity for them. Opacity - // doesn't work without acrylic on Windows 10. - // - // BODGY: CascadiaSettings's function IsDefaultTerminalAvailable - // is basically a "are we on Windows 11" check, because defterm - // only works on Win11. So we'll use that. - // - // Remove when we can remove the rest of GH#11285 - if (!UseAcrylic() && !CascadiaSettings::IsDefaultTerminalAvailable()) - { - Opacity(1.0); - } - } else if (viewModelProperty == L"AntialiasingMode") { _NotifyChanges(L"CurrentAntiAliasingMode"); diff --git a/src/cascadia/TerminalSettingsEditor/ProfileViewModel.h b/src/cascadia/TerminalSettingsEditor/ProfileViewModel.h index 1b61c7062c7..81c8cf4d00e 100644 --- a/src/cascadia/TerminalSettingsEditor/ProfileViewModel.h +++ b/src/cascadia/TerminalSettingsEditor/ProfileViewModel.h @@ -35,21 +35,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation void SetAcrylicOpacityPercentageValue(double value) { Opacity(winrt::Microsoft::Terminal::Settings::Editor::Converters::PercentageValueToPercentage(value)); - - // GH#11372: If we're on Windows 10, and someone wants opacity, then - // we'll turn acrylic on for them. Opacity doesn't work without - // acrylic on Windows 10. - // - // BODGY: CascadiaSettings's function IsDefaultTerminalAvailable - // is basically a "are we on Windows 11" check, because defterm - // only works on Win11. So we'll use that. - // - // Remove when we can remove the rest of GH#11285 - if (value < 100.0 && - !winrt::Microsoft::Terminal::Settings::Model::CascadiaSettings::IsDefaultTerminalAvailable()) - { - UseAcrylic(true); - } }; void SetPadding(double value) diff --git a/src/cascadia/UnitTests_Control/ControlCoreTests.cpp b/src/cascadia/UnitTests_Control/ControlCoreTests.cpp index 658d4ca623c..a1bc11c74ba 100644 --- a/src/cascadia/UnitTests_Control/ControlCoreTests.cpp +++ b/src/cascadia/UnitTests_Control/ControlCoreTests.cpp @@ -142,8 +142,8 @@ namespace ControlUnitTests // requested acrylic. auto expectedUseAcrylic = expectedOpacity < 1.0; + VERIFY_IS_TRUE(core->_settings->UseAcrylic()); VERIFY_ARE_EQUAL(expectedUseAcrylic, core->UseAcrylic()); - VERIFY_ARE_EQUAL(true, core->_settings->UseAcrylic()); }; core->TransparencyChanged(opacityCallback); diff --git a/src/cascadia/UnitTests_Control/ControlInteractivityTests.cpp b/src/cascadia/UnitTests_Control/ControlInteractivityTests.cpp index d73b7b122cc..2d573290ad0 100644 --- a/src/cascadia/UnitTests_Control/ControlInteractivityTests.cpp +++ b/src/cascadia/UnitTests_Control/ControlInteractivityTests.cpp @@ -145,7 +145,7 @@ namespace ControlUnitTests VERIFY_ARE_EQUAL(0.5, settings->Opacity()); auto expectedUseAcrylic = expectedOpacity < 1.0 && - (!winrt::Microsoft::Terminal::Control::implementation::ControlCore::IsVintageOpacityAvailable() || useAcrylic); + (useAcrylic); VERIFY_ARE_EQUAL(useAcrylic, settings->UseAcrylic()); VERIFY_ARE_EQUAL(expectedUseAcrylic, core->UseAcrylic()); };