diff --git a/.github/actions/spelling/allow/allow.txt b/.github/actions/spelling/allow/allow.txt index 085ff6682..6025abf76 100644 --- a/.github/actions/spelling/allow/allow.txt +++ b/.github/actions/spelling/allow/allow.txt @@ -1,12 +1,14 @@ +admins apc +Apc +bsd calt ccmp changelog -cybersecurity -Apc clickable clig copyable +cybersecurity dalet dcs Dcs @@ -34,17 +36,17 @@ It'd kje liga lje -locl -lorem Llast Lmid +locl +lorem Lorigin maxed mkmk mnt mru -noreply nje +noreply ogonek ok'd overlined diff --git a/.github/actions/spelling/allow/apis.txt b/.github/actions/spelling/allow/apis.txt index 45f4e02f1..83ca55178 100644 --- a/.github/actions/spelling/allow/apis.txt +++ b/.github/actions/spelling/allow/apis.txt @@ -1,5 +1,7 @@ ACCEPTFILES ACCESSDENIED +acl +aclapi alignas alignof APPLYTOSUBMENUS @@ -21,6 +23,7 @@ commandlinetoargv cstdint CXICON CYICON +Dacl dataobject dcomp DERR @@ -117,15 +120,19 @@ OSVERSIONINFOEXW otms OUTLINETEXTMETRICW overridable +PACL PAGESCROLL +PEXPLICIT PICKFOLDERS pmr +ptstr rcx REGCLS RETURNCMD rfind roundf RSHIFT +SACL schandle semver serializer diff --git a/.github/actions/spelling/allow/names.txt b/.github/actions/spelling/allow/names.txt index 3635d3723..2a13d67ba 100644 --- a/.github/actions/spelling/allow/names.txt +++ b/.github/actions/spelling/allow/names.txt @@ -9,6 +9,7 @@ Diviness dsafa duhowett ekg +eryksun ethanschoonover Firefox Gatta diff --git a/.github/actions/spelling/excludes.txt b/.github/actions/spelling/excludes.txt index 8d751a187..7d64932c9 100644 --- a/.github/actions/spelling/excludes.txt +++ b/.github/actions/spelling/excludes.txt @@ -61,6 +61,7 @@ SUMS$ ^src/host/runft\.bat$ ^src/host/runut\.bat$ ^src/interactivity/onecore/BgfxEngine\. +^src/renderer/atlas/ ^src/renderer/wddmcon/WddmConRenderer\. ^src/terminal/adapter/ut_adapter/run\.bat$ ^src/terminal/parser/delfuzzpayload\.bat$ diff --git a/OpenConsole.sln b/OpenConsole.sln index 493cba041..d1f99131d 100644 --- a/OpenConsole.sln +++ b/OpenConsole.sln @@ -400,6 +400,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsTerminal.UIA.Tests", EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "api-ms-win-core-synch-l1-2-0", "src\api-ms-win-core-synch-l1-2-0\api-ms-win-core-synch-l1-2-0.vcxproj", "{9CF74355-F018-4C19-81AD-9DC6B7F2C6F5}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RendererAtlas", "src\renderer\atlas\atlas.vcxproj", "{8222900C-8B6C-452A-91AC-BE95DB04B95F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution AuditMode|Any CPU = AuditMode|Any CPU @@ -3339,6 +3341,46 @@ Global {9CF74355-F018-4C19-81AD-9DC6B7F2C6F5}.Release|x64.Build.0 = Release|x64 {9CF74355-F018-4C19-81AD-9DC6B7F2C6F5}.Release|x86.ActiveCfg = Release|Win32 {9CF74355-F018-4C19-81AD-9DC6B7F2C6F5}.Release|x86.Build.0 = Release|Win32 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.AuditMode|Any CPU.ActiveCfg = AuditMode|Win32 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.AuditMode|ARM.ActiveCfg = AuditMode|Win32 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.AuditMode|ARM64.ActiveCfg = AuditMode|ARM64 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.AuditMode|ARM64.Build.0 = AuditMode|ARM64 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.AuditMode|DotNet_x64Test.ActiveCfg = AuditMode|Win32 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.AuditMode|DotNet_x86Test.ActiveCfg = AuditMode|Win32 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.AuditMode|x64.ActiveCfg = AuditMode|x64 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.AuditMode|x64.Build.0 = AuditMode|x64 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.AuditMode|x86.ActiveCfg = AuditMode|Win32 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.AuditMode|x86.Build.0 = AuditMode|Win32 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.Debug|ARM.ActiveCfg = Debug|Win32 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.Debug|ARM64.Build.0 = Debug|ARM64 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.Debug|DotNet_x64Test.ActiveCfg = Debug|Win32 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.Debug|DotNet_x86Test.ActiveCfg = Debug|Win32 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.Debug|x64.ActiveCfg = Debug|x64 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.Debug|x64.Build.0 = Debug|x64 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.Debug|x86.ActiveCfg = Debug|Win32 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.Debug|x86.Build.0 = Debug|Win32 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.Fuzzing|Any CPU.ActiveCfg = Fuzzing|Win32 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.Fuzzing|ARM.ActiveCfg = Fuzzing|Win32 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.Fuzzing|ARM64.ActiveCfg = Fuzzing|ARM64 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.Fuzzing|ARM64.Build.0 = Fuzzing|ARM64 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.Fuzzing|DotNet_x64Test.ActiveCfg = Fuzzing|Win32 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.Fuzzing|DotNet_x86Test.ActiveCfg = Fuzzing|Win32 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.Fuzzing|x64.ActiveCfg = Fuzzing|x64 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.Fuzzing|x64.Build.0 = Fuzzing|x64 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.Fuzzing|x86.ActiveCfg = Fuzzing|Win32 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.Fuzzing|x86.Build.0 = Fuzzing|Win32 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.Release|Any CPU.ActiveCfg = Release|Win32 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.Release|ARM.ActiveCfg = Release|Win32 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.Release|ARM64.ActiveCfg = Release|ARM64 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.Release|ARM64.Build.0 = Release|ARM64 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.Release|DotNet_x64Test.ActiveCfg = Release|Win32 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.Release|DotNet_x86Test.ActiveCfg = Release|Win32 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.Release|x64.ActiveCfg = Release|x64 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.Release|x64.Build.0 = Release|x64 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.Release|x86.ActiveCfg = Release|Win32 + {8222900C-8B6C-452A-91AC-BE95DB04B95F}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -3438,6 +3480,7 @@ Global {C323DAEE-B307-4C7B-ACE5-7293CBEFCB5B} = {BDB237B6-1D1D-400F-84CC-40A58FA59C8E} {F19DACD5-0C6E-40DC-B6E4-767A3200542C} = {BDB237B6-1D1D-400F-84CC-40A58FA59C8E} {9CF74355-F018-4C19-81AD-9DC6B7F2C6F5} = {89CDCC5C-9F53-4054-97A4-639D99F169CD} + {8222900C-8B6C-452A-91AC-BE95DB04B95F} = {05500DEF-2294-41E3-AF9A-24E580B82836} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {3140B1B7-C8EE-43D1-A772-D82A7061A271} diff --git a/src/cascadia/PublicTerminalCore/PublicTerminalCore.vcxproj b/src/cascadia/PublicTerminalCore/PublicTerminalCore.vcxproj index 1665034e1..a7063bb9b 100644 --- a/src/cascadia/PublicTerminalCore/PublicTerminalCore.vcxproj +++ b/src/cascadia/PublicTerminalCore/PublicTerminalCore.vcxproj @@ -29,6 +29,9 @@ {18D09A24-8240-42D6-8CB6-236EEE820263} + + {8222900C-8B6C-452A-91AC-BE95DB04B95F} + {af0a096a-8b3a-4949-81ef-7df8f0fee91f} diff --git a/src/cascadia/TerminalApp/AppLogic.cpp b/src/cascadia/TerminalApp/AppLogic.cpp index 7e5949577..ebc92d505 100644 --- a/src/cascadia/TerminalApp/AppLogic.cpp +++ b/src/cascadia/TerminalApp/AppLogic.cpp @@ -12,6 +12,8 @@ #include #include +#include "../../types/inc/utils.hpp" + using namespace winrt::Windows::ApplicationModel; using namespace winrt::Windows::ApplicationModel::DataTransfer; using namespace winrt::Windows::UI::Xaml; @@ -131,38 +133,6 @@ static Documents::Run _BuildErrorRun(const winrt::hstring& text, const ResourceD return textRun; } -// Method Description: -// - Returns whether the user is either a member of the Administrators group or -// is currently elevated. -// - This will return **FALSE** if the user has UAC disabled entirely, because -// there's no separation of power between the user and an admin in that case. -// Return Value: -// - true if the user is an administrator -static bool _isUserAdmin() noexcept -try -{ - wil::unique_handle processToken{ GetCurrentProcessToken() }; - const auto elevationType = wil::get_token_information(processToken.get()); - const auto elevationState = wil::get_token_information(processToken.get()); - if (elevationType == TokenElevationTypeDefault && elevationState.TokenIsElevated) - { - // In this case, the user has UAC entirely disabled. This is sort of - // weird, we treat this like the user isn't an admin at all. There's no - // separation of powers, so the things we normally want to gate on - // "having special powers" doesn't apply. - // - // See GH#7754, GH#11096 - return false; - } - - return wil::test_token_membership(nullptr, SECURITY_NT_AUTHORITY, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS); -} -catch (...) -{ - LOG_CAUGHT_EXCEPTION(); - return false; -} - namespace winrt::TerminalApp::implementation { // Function Description: @@ -214,7 +184,7 @@ namespace winrt::TerminalApp::implementation // The TerminalPage has to be constructed during our construction, to // make sure that there's a terminal page for callers of // SetTitleBarContent - _isElevated = _isUserAdmin(); + _isElevated = ::Microsoft::Console::Utils::IsElevated(); _root = winrt::make_self(); _reloadSettings = std::make_shared>(winrt::Windows::System::DispatcherQueue::GetForCurrentThread(), std::chrono::milliseconds(100), [weakSelf = get_weak()]() { @@ -910,8 +880,6 @@ namespace winrt::TerminalApp::implementation void AppLogic::_RegisterSettingsChange() { const std::filesystem::path settingsPath{ std::wstring_view{ CascadiaSettings::SettingsPath() } }; - const std::filesystem::path statePath{ std::wstring_view{ ApplicationState::SharedInstance().FilePath() } }; - _reader.create( settingsPath.parent_path().c_str(), false, @@ -920,14 +888,29 @@ namespace winrt::TerminalApp::implementation // editors, who will write a temp file, then rename it to be the // actual file you wrote. So listen for that too. wil::FolderChangeEvents::FileName | wil::FolderChangeEvents::LastWriteTime, - [this, settingsBasename = settingsPath.filename(), stateBasename = statePath.filename()](wil::FolderChangeEvent, PCWSTR fileModified) { - const auto modifiedBasename = std::filesystem::path{ fileModified }.filename(); + [this, settingsBasename = settingsPath.filename()](wil::FolderChangeEvent, PCWSTR fileModified) { + // DO NOT create a static reference to ApplicationState::SharedInstance here. + // + // ApplicationState::SharedInstance already caches its own + // static ref. If _we_ keep a static ref to the member in + // AppState, then our reference will keep ApplicationState alive + // after the `ActionToStringMap` gets cleaned up. Then, when we + // try to persist the actions in the window state, we won't be + // able to. We'll try to look up the action and the map just + // won't exist. We'll explode, even though the Terminal is + // tearing down anyways. So we'll just die, but still invoke + // WinDBG's post-mortem debugger, who won't be able to attach to + // the process that's already exiting. + // + // So DON'T ~give a mouse a cookie~ take a static ref here. + + const winrt::hstring modifiedBasename{ std::filesystem::path{ fileModified }.filename().c_str() }; if (modifiedBasename == settingsBasename) { _reloadSettings->Run(); } - else if (modifiedBasename == stateBasename) + else if (ApplicationState::SharedInstance().IsStatePath(modifiedBasename)) { _reloadState(); } diff --git a/src/cascadia/TerminalApp/TerminalPage.cpp b/src/cascadia/TerminalApp/TerminalPage.cpp index fa443d616..3548291be 100644 --- a/src/cascadia/TerminalApp/TerminalPage.cpp +++ b/src/cascadia/TerminalApp/TerminalPage.cpp @@ -300,10 +300,7 @@ namespace winrt::TerminalApp::implementation // - true if the ApplicationState should be used. bool TerminalPage::ShouldUsePersistedLayout(CascadiaSettings& settings) const { - // GH#5000 Until there is a separate state file for elevated sessions we should just not - // save at all while in an elevated window. return Feature_PersistedWindowLayout::IsEnabled() && - !IsElevated() && settings.GlobalSettings().FirstWindowPreference() == FirstWindowPreference::PersistedWindowLayout; } diff --git a/src/cascadia/TerminalControl/ControlCore.cpp b/src/cascadia/TerminalControl/ControlCore.cpp index c6e916e78..6ec361367 100644 --- a/src/cascadia/TerminalControl/ControlCore.cpp +++ b/src/cascadia/TerminalControl/ControlCore.cpp @@ -3,16 +3,18 @@ #include "pch.h" #include "ControlCore.h" -#include + #include #include #include -#include #include #include + +#include "EventArgs.h" #include "../../types/inc/GlyphWidth.hpp" -#include "../../types/inc/Utils.hpp" #include "../../buffer/out/search.h" +#include "../../renderer/atlas/AtlasEngine.h" +#include "../../renderer/dx/DxRenderer.hpp" #include "ControlCore.g.cpp" @@ -204,6 +206,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation const double actualHeight, const double compositionScale) { + assert(_settings); + _panelWidth = actualWidth; _panelHeight = actualHeight; _compositionScale = compositionScale; @@ -224,10 +228,16 @@ namespace winrt::Microsoft::Terminal::Control::implementation return false; } - // Set up the DX Engine - auto dxEngine = std::make_unique<::Microsoft::Console::Render::DxEngine>(); - _renderer->AddRenderEngine(dxEngine.get()); - _renderEngine = std::move(dxEngine); + if (Feature_AtlasEngine::IsEnabled() && _settings->UseAtlasEngine()) + { + _renderEngine = std::make_unique<::Microsoft::Console::Render::AtlasEngine>(); + } + else + { + _renderEngine = std::make_unique<::Microsoft::Console::Render::DxEngine>(); + } + + _renderer->AddRenderEngine(_renderEngine.get()); // Initialize our font with the renderer // We don't have to care about DPI. We'll get a change message immediately if it's not 96 @@ -273,7 +283,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation _renderEngine->SetSoftwareRendering(_settings->SoftwareRendering()); _renderEngine->SetIntenseIsBold(_settings->IntenseIsBold()); - _updateAntiAliasingMode(_renderEngine.get()); + _updateAntiAliasingMode(); // GH#5098: Inform the engine of the opacity of the default text background. // GH#11315: Always do this, even if they don't have acrylic on. @@ -629,7 +639,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation // Inform the renderer of our opacity _renderEngine->EnableTransparentBackground(_isBackgroundTransparent()); - _updateAntiAliasingMode(_renderEngine.get()); + _updateAntiAliasingMode(); // Refresh our font with the renderer const auto actualFontOldSize = _actualFont.GetSize(); @@ -663,22 +673,24 @@ namespace winrt::Microsoft::Terminal::Control::implementation } } - void ControlCore::_updateAntiAliasingMode(::Microsoft::Console::Render::DxEngine* const dxEngine) + void ControlCore::_updateAntiAliasingMode() { + D2D1_TEXT_ANTIALIAS_MODE mode; // Update DxEngine's AntialiasingMode switch (_settings->AntialiasingMode()) { case TextAntialiasingMode::Cleartype: - dxEngine->SetAntialiasingMode(D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE); + mode = D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE; break; case TextAntialiasingMode::Aliased: - dxEngine->SetAntialiasingMode(D2D1_TEXT_ANTIALIAS_MODE_ALIASED); + mode = D2D1_TEXT_ANTIALIAS_MODE_ALIASED; break; - case TextAntialiasingMode::Grayscale: default: - dxEngine->SetAntialiasingMode(D2D1_TEXT_ANTIALIAS_MODE_GRAYSCALE); + mode = D2D1_TEXT_ANTIALIAS_MODE_GRAYSCALE; break; } + + _renderEngine->SetAntialiasingMode(mode); } // Method Description: @@ -1703,6 +1715,14 @@ namespace winrt::Microsoft::Terminal::Control::implementation bool ControlCore::_isBackgroundTransparent() { + // TODO! I had: return Opacity() < 1.0f || UseAcrylic(); + + // But the Atlas Renderer PR changed this to: + // + // const auto backgroundIsOpaque = _settings.Opacity() == 1.0 && _settings.BackgroundImage().empty();\ + // + // Only one of these is right, right? + // The background image thing might be a } } diff --git a/src/cascadia/TerminalControl/ControlCore.h b/src/cascadia/TerminalControl/ControlCore.h index 2e9c9b6f9..74c29225f 100644 --- a/src/cascadia/TerminalControl/ControlCore.h +++ b/src/cascadia/TerminalControl/ControlCore.h @@ -15,12 +15,9 @@ #pragma once -#include "EventArgs.h" #include "ControlCore.g.h" #include "ControlSettings.h" #include "../../renderer/base/Renderer.hpp" -#include "../../renderer/dx/DxRenderer.hpp" -#include "../../renderer/uia/UiaRenderer.hpp" #include "../../cascadia/TerminalCore/Terminal.hpp" #include "../buffer/out/search.h" #include "cppwinrt_utils.h" @@ -212,7 +209,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation // As _renderer has a dependency on _renderEngine (through a raw pointer) // we must ensure the _renderer is deallocated first. // (C++ class members are destroyed in reverse order.) - std::unique_ptr<::Microsoft::Console::Render::DxEngine> _renderEngine{ nullptr }; + std::unique_ptr<::Microsoft::Console::Render::IRenderEngine> _renderEngine{ nullptr }; std::unique_ptr<::Microsoft::Console::Render::Renderer> _renderer{ nullptr }; FontInfoDesired _desiredFont; @@ -270,7 +267,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation #pragma endregion void _raiseReadOnlyWarning(); - void _updateAntiAliasingMode(::Microsoft::Console::Render::DxEngine* const dxEngine); + void _updateAntiAliasingMode(); void _connectionOutputHandler(const hstring& hstr); void _updateHoveredCell(const std::optional terminalPosition); diff --git a/src/cascadia/TerminalControl/ControlInteractivity.h b/src/cascadia/TerminalControl/ControlInteractivity.h index e212fb650..2c57bf9be 100644 --- a/src/cascadia/TerminalControl/ControlInteractivity.h +++ b/src/cascadia/TerminalControl/ControlInteractivity.h @@ -22,6 +22,7 @@ #include "cppwinrt_utils.h" #include "ControlCore.h" +#include "../../renderer/uia/UiaRenderer.hpp" namespace ControlUnitTests { diff --git a/src/cascadia/TerminalControl/IControlSettings.idl b/src/cascadia/TerminalControl/IControlSettings.idl index f3c2639d2..8f0c31f58 100644 --- a/src/cascadia/TerminalControl/IControlSettings.idl +++ b/src/cascadia/TerminalControl/IControlSettings.idl @@ -33,6 +33,8 @@ namespace Microsoft.Terminal.Control Boolean UseAcrylic { get; }; ScrollbarState ScrollState { get; }; + Boolean UseAtlasEngine { get; }; + String FontFace { get; }; Int32 FontSize { get; }; Windows.UI.Text.FontWeight FontWeight { get; }; diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index b13edaf51..d5defec3d 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -3,17 +3,16 @@ #include "pch.h" #include "TermControl.h" -#include -#include + #include #include -#include #include + +#include "TermControlAutomationPeer.h" #include "../../types/inc/GlyphWidth.hpp" -#include "../../types/inc/Utils.hpp" +#include "../../renderer/atlas/AtlasEngine.h" #include "TermControl.g.cpp" -#include "TermControlAutomationPeer.h" using namespace ::Microsoft::Console::Types; using namespace ::Microsoft::Console::VirtualTerminal; @@ -1853,13 +1852,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation const winrt::Windows::Foundation::Size initialSize{ cols, rows }; - return GetProposedDimensions(initialSize, - settings.FontSize(), - settings.FontWeight(), - settings.FontFace(), - settings.ScrollState(), - settings.Padding(), - dpi); + return GetProposedDimensions(settings, dpi, initialSize); } // Function Description: @@ -1880,16 +1873,15 @@ namespace winrt::Microsoft::Terminal::Control::implementation // caller knows what monitor the control is about to appear on. // Return Value: // - a size containing the requested dimensions in pixels. - winrt::Windows::Foundation::Size TermControl::GetProposedDimensions(const winrt::Windows::Foundation::Size& initialSizeInChars, - const int32_t& fontHeight, - const winrt::Windows::UI::Text::FontWeight& fontWeight, - const winrt::hstring& fontFace, - const ScrollbarState& scrollState, - const winrt::hstring& padding, - const uint32_t dpi) + winrt::Windows::Foundation::Size TermControl::GetProposedDimensions(IControlSettings const& settings, const uint32_t dpi, const winrt::Windows::Foundation::Size& initialSizeInChars) { const auto cols = ::base::saturated_cast(initialSizeInChars.Width); const auto rows = ::base::saturated_cast(initialSizeInChars.Height); + const auto fontSize = settings.FontSize(); + const auto fontWeight = settings.FontWeight(); + const auto fontFace = settings.FontFace(); + const auto scrollState = settings.ScrollState(); + const auto padding = settings.Padding(); // Initialize our font information. // The font width doesn't terribly matter, we'll only be using the @@ -1898,28 +1890,39 @@ namespace winrt::Microsoft::Terminal::Control::implementation // The family is only used to determine if the font is truetype or // not, but DX doesn't use that info at all. // The Codepage is additionally not actually used by the DX engine at all. - FontInfo actualFont = { fontFace, 0, fontWeight.Weight, { 0, gsl::narrow_cast(fontHeight) }, CP_UTF8, false }; + FontInfo actualFont = { fontFace, 0, fontWeight.Weight, { 0, gsl::narrow_cast(fontSize) }, CP_UTF8, false }; FontInfoDesired desiredFont = { actualFont }; // Create a DX engine and initialize it with our font and DPI. We'll // then use it to measure how much space the requested rows and columns // will take up. // TODO: MSFT:21254947 - use a static function to do this instead of - // instantiating a DxEngine + // instantiating a DxEngine/AtlasEngine. // GH#10211 - UNDER NO CIRCUMSTANCE should this fail. If it does, the // whole app will crash instantaneously on launch, which is no good. - auto dxEngine = std::make_unique<::Microsoft::Console::Render::DxEngine>(); - LOG_IF_FAILED(dxEngine->UpdateDpi(dpi)); - LOG_IF_FAILED(dxEngine->UpdateFont(desiredFont, actualFont)); + double scale; + if (Feature_AtlasEngine::IsEnabled() && settings.UseAtlasEngine()) + { + auto engine = std::make_unique<::Microsoft::Console::Render::AtlasEngine>(); + LOG_IF_FAILED(engine->UpdateDpi(dpi)); + LOG_IF_FAILED(engine->UpdateFont(desiredFont, actualFont)); + scale = engine->GetScaling(); + } + else + { + auto engine = std::make_unique<::Microsoft::Console::Render::DxEngine>(); + LOG_IF_FAILED(engine->UpdateDpi(dpi)); + LOG_IF_FAILED(engine->UpdateFont(desiredFont, actualFont)); + scale = engine->GetScaling(); + } - const auto scale = dxEngine->GetScaling(); - const auto fontSize = actualFont.GetSize(); + const auto actualFontSize = actualFont.GetSize(); // UWP XAML scrollbars aren't guaranteed to be the same size as the // ComCtl scrollbars, but it's certainly close enough. const auto scrollbarSize = GetSystemMetricsForDpi(SM_CXVSCROLL, dpi); - double width = cols * fontSize.X; + double width = cols * actualFontSize.X; // Reserve additional space if scrollbar is intended to be visible if (scrollState == ScrollbarState::Visible) @@ -1927,7 +1930,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation width += scrollbarSize; } - double height = rows * fontSize.Y; + double height = rows * actualFontSize.Y; const auto thickness = ParseThicknessFromPadding(padding); // GH#2061 - make sure to account for the size the padding _will be_ scaled to width += scale * (thickness.Left + thickness.Right); @@ -1987,14 +1990,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation const winrt::Windows::Foundation::Size minSize{ 1, 1 }; const double scaleFactor = DisplayInformation::GetForCurrentView().RawPixelsPerViewPixel(); const auto dpi = ::base::saturated_cast(USER_DEFAULT_SCREEN_DPI * scaleFactor); - auto settings{ _core.Settings() }; - return GetProposedDimensions(minSize, - settings.FontSize(), - settings.FontWeight(), - settings.FontFace(), - settings.ScrollState(), - settings.Padding(), - dpi); + + return GetProposedDimensions(_core.Settings(), dpi, minSize); } } diff --git a/src/cascadia/TerminalControl/TermControl.h b/src/cascadia/TerminalControl/TermControl.h index 6afb9c61f..2481949a3 100644 --- a/src/cascadia/TerminalControl/TermControl.h +++ b/src/cascadia/TerminalControl/TermControl.h @@ -92,13 +92,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation const Windows::UI::Xaml::Thickness GetPadding(); static Windows::Foundation::Size GetProposedDimensions(IControlSettings const& settings, const uint32_t dpi); - static Windows::Foundation::Size GetProposedDimensions(const winrt::Windows::Foundation::Size& initialSizeInChars, - const int32_t& fontSize, - const winrt::Windows::UI::Text::FontWeight& fontWeight, - const winrt::hstring& fontFace, - const ScrollbarState& scrollState, - const winrt::hstring& padding, - const uint32_t dpi); + static Windows::Foundation::Size GetProposedDimensions(IControlSettings const& settings, const uint32_t dpi, const winrt::Windows::Foundation::Size& initialSizeInChars); void BellLightOn(); diff --git a/src/cascadia/TerminalControl/TerminalControlLib.vcxproj b/src/cascadia/TerminalControl/TerminalControlLib.vcxproj index 3ce1d8a52..a366650fc 100644 --- a/src/cascadia/TerminalControl/TerminalControlLib.vcxproj +++ b/src/cascadia/TerminalControl/TerminalControlLib.vcxproj @@ -147,6 +147,7 @@ + diff --git a/src/cascadia/TerminalCore/lib/terminalcore-lib.vcxproj b/src/cascadia/TerminalCore/lib/terminalcore-lib.vcxproj index 9ced8ea9f..2f750978b 100644 --- a/src/cascadia/TerminalCore/lib/terminalcore-lib.vcxproj +++ b/src/cascadia/TerminalCore/lib/terminalcore-lib.vcxproj @@ -37,6 +37,9 @@ {3ae13314-1939-4dfa-9c14-38ca0834050c} + + {8222900C-8B6C-452A-91AC-BE95DB04B95F} + {48d21369-3d7b-4431-9967-24e81292cf62} diff --git a/src/cascadia/TerminalSettingsEditor/Profiles.cpp b/src/cascadia/TerminalSettingsEditor/Profiles.cpp index 6741f9125..b42955f60 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles.cpp +++ b/src/cascadia/TerminalSettingsEditor/Profiles.cpp @@ -246,13 +246,9 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation return _profile.HasUnfocusedAppearance(); } - bool ProfileViewModel::EditableUnfocusedAppearance() + bool ProfileViewModel::EditableUnfocusedAppearance() const noexcept { - if constexpr (Feature_EditableUnfocusedAppearance::IsEnabled()) - { - return true; - } - return false; + return Feature_EditableUnfocusedAppearance::IsEnabled(); } bool ProfileViewModel::ShowUnfocusedAppearance() @@ -286,6 +282,11 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation return _unfocusedAppearanceViewModel; } + bool ProfileViewModel::AtlasEngineAvailable() const noexcept + { + return Feature_AtlasEngine::IsEnabled(); + } + bool ProfileViewModel::UseParentProcessDirectory() { return StartingDirectory().empty(); diff --git a/src/cascadia/TerminalSettingsEditor/Profiles.h b/src/cascadia/TerminalSettingsEditor/Profiles.h index 40ecd9c45..7c12d9752 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles.h +++ b/src/cascadia/TerminalSettingsEditor/Profiles.h @@ -61,12 +61,12 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation Editor::AppearanceViewModel DefaultAppearance(); Editor::AppearanceViewModel UnfocusedAppearance(); bool HasUnfocusedAppearance(); - bool EditableUnfocusedAppearance(); + bool EditableUnfocusedAppearance() const noexcept; bool ShowUnfocusedAppearance(); - void CreateUnfocusedAppearance(const Windows::Foundation::Collections::IMapView& schemes, const IHostedInWindow& windowRoot); void DeleteUnfocusedAppearance(); + bool AtlasEngineAvailable() const noexcept; WINRT_PROPERTY(bool, IsBaseLayer, false); @@ -95,6 +95,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation OBSERVABLE_PROJECTED_SETTING(_profile, SnapOnInput); OBSERVABLE_PROJECTED_SETTING(_profile, AltGrAliasing); OBSERVABLE_PROJECTED_SETTING(_profile, BellStyle); + OBSERVABLE_PROJECTED_SETTING(_profile, UseAtlasEngine); private: Model::Profile _profile; diff --git a/src/cascadia/TerminalSettingsEditor/Profiles.idl b/src/cascadia/TerminalSettingsEditor/Profiles.idl index 5d45a612c..a4746d560 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles.idl +++ b/src/cascadia/TerminalSettingsEditor/Profiles.idl @@ -32,6 +32,7 @@ namespace Microsoft.Terminal.Settings.Editor Boolean EditableUnfocusedAppearance { get; }; Boolean ShowUnfocusedAppearance { get; }; AppearanceViewModel UnfocusedAppearance { get; }; + Boolean AtlasEngineAvailable { get; }; void CreateUnfocusedAppearance(Windows.Foundation.Collections.IMapView Schemes, IHostedInWindow WindowRoot); void DeleteUnfocusedAppearance(); @@ -61,6 +62,7 @@ namespace Microsoft.Terminal.Settings.Editor OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, SnapOnInput); OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, AltGrAliasing); OBSERVABLE_PROJECTED_PROFILE_SETTING(Microsoft.Terminal.Settings.Model.BellStyle, BellStyle); + OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, UseAtlasEngine); } runtimeclass DeleteProfileEventArgs diff --git a/src/cascadia/TerminalSettingsEditor/Profiles.xaml b/src/cascadia/TerminalSettingsEditor/Profiles.xaml index 230cfc2e8..c860578aa 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles.xaml +++ b/src/cascadia/TerminalSettingsEditor/Profiles.xaml @@ -319,7 +319,7 @@ + Visibility="{x:Bind State.Profile.EditableUnfocusedAppearance}">