From 59eb86a4bd468a3a0727d9a34d63245fa2ac52d7 Mon Sep 17 00:00:00 2001 From: "Dustin L. Howett" Date: Thu, 24 Sep 2026 18:32:32 -0500 Subject: [PATCH 1/8] Undo most of 7f3bc3cb047b66644ab --- .../TerminalControl/ControlInteractivity.cpp | 14 +- .../TerminalControl/ControlInteractivity.h | 2 +- .../TerminalControl/ControlInteractivity.idl | 4 - .../InteractivityAutomationPeer.cpp | 223 --------- .../InteractivityAutomationPeer.h | 90 ---- .../InteractivityAutomationPeer.idl | 19 - src/cascadia/TerminalControl/TermControl.cpp | 472 ++++++++---------- src/cascadia/TerminalControl/TermControl.h | 18 +- .../TermControlAutomationPeer.cpp | 144 ++++-- .../TermControlAutomationPeer.h | 27 +- .../TerminalControlLib.vcxproj | 9 +- .../TerminalSettingsModel/IInheritable.h | 4 +- 12 files changed, 357 insertions(+), 669 deletions(-) delete mode 100644 src/cascadia/TerminalControl/InteractivityAutomationPeer.cpp delete mode 100644 src/cascadia/TerminalControl/InteractivityAutomationPeer.h delete mode 100644 src/cascadia/TerminalControl/InteractivityAutomationPeer.idl diff --git a/src/cascadia/TerminalControl/ControlInteractivity.cpp b/src/cascadia/TerminalControl/ControlInteractivity.cpp index 84d263271c..c4b5b8b0a6 100644 --- a/src/cascadia/TerminalControl/ControlInteractivity.cpp +++ b/src/cascadia/TerminalControl/ControlInteractivity.cpp @@ -10,8 +10,6 @@ #include "../../types/inc/Utils.hpp" #include "../../buffer/out/search.h" -#include "InteractivityAutomationPeer.h" - #include "ControlInteractivity.g.cpp" using namespace ::Microsoft::Console::Types; @@ -778,23 +776,17 @@ namespace winrt::Microsoft::Terminal::Control::implementation // - None // Return Value: // - The automation peer for our control - Control::InteractivityAutomationPeer ControlInteractivity::OnCreateAutomationPeer() + void ControlInteractivity::SetUiaEventDispatcher(IUiaEventDispatcher* uiaEventDispatcher) try { - const auto autoPeer = winrt::make_self(this); if (_uiaEngine) { _core->DetachUiaEngine(_uiaEngine.get()); } - _uiaEngine = std::make_unique<::Microsoft::Console::Render::UiaEngine>(autoPeer.get()); + _uiaEngine = std::make_unique<::Microsoft::Console::Render::UiaEngine>(uiaEventDispatcher); _core->AttachUiaEngine(_uiaEngine.get()); - return *autoPeer; - } - catch (...) - { - LOG_CAUGHT_EXCEPTION(); - return nullptr; } + CATCH_LOG() ::Microsoft::Console::Render::IRenderData* ControlInteractivity::GetRenderData() const { diff --git a/src/cascadia/TerminalControl/ControlInteractivity.h b/src/cascadia/TerminalControl/ControlInteractivity.h index 79dfd33126..ee633e46ec 100644 --- a/src/cascadia/TerminalControl/ControlInteractivity.h +++ b/src/cascadia/TerminalControl/ControlInteractivity.h @@ -48,7 +48,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation void Close(); void Detach(); - Control::InteractivityAutomationPeer OnCreateAutomationPeer(); + void SetUiaEventDispatcher(::Microsoft::Console::Types::IUiaEventDispatcher* uiaEventDispatcher); ::Microsoft::Console::Render::IRenderData* GetRenderData() const; #pragma region Input Methods diff --git a/src/cascadia/TerminalControl/ControlInteractivity.idl b/src/cascadia/TerminalControl/ControlInteractivity.idl index 33d89722f8..272876d8c6 100644 --- a/src/cascadia/TerminalControl/ControlInteractivity.idl +++ b/src/cascadia/TerminalControl/ControlInteractivity.idl @@ -5,8 +5,6 @@ import "ICoreState.idl"; import "IControlSettings.idl"; import "ControlCore.idl"; import "EventArgs.idl"; -import "InteractivityAutomationPeer.idl"; - namespace Microsoft.Terminal.Control { @@ -30,8 +28,6 @@ namespace Microsoft.Terminal.Control void Close(); - InteractivityAutomationPeer OnCreateAutomationPeer(); - Boolean CopySelectionToClipboard(Boolean singleLine, Boolean withControlSequences, CopyFormat formats); void RequestPasteTextFromClipboard(); void SetEndSelectionPoint(Microsoft.Terminal.Core.Point point); diff --git a/src/cascadia/TerminalControl/InteractivityAutomationPeer.cpp b/src/cascadia/TerminalControl/InteractivityAutomationPeer.cpp deleted file mode 100644 index 9967c5ac2b..0000000000 --- a/src/cascadia/TerminalControl/InteractivityAutomationPeer.cpp +++ /dev/null @@ -1,223 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -#include "pch.h" -#include -#include "InteractivityAutomationPeer.h" -#include "InteractivityAutomationPeer.g.cpp" - -#include "XamlUiaTextRange.h" -#include "../types/UiaTracing.h" - -using namespace Microsoft::Console::Types; -using namespace winrt::Windows::UI::Xaml::Automation::Peers; -using namespace winrt::Windows::Graphics::Display; - -namespace UIA -{ - using ::ITextRangeProvider; - using ::SupportedTextSelection; -} - -namespace XamlAutomation -{ - using winrt::Windows::UI::Xaml::Automation::SupportedTextSelection; - using winrt::Windows::UI::Xaml::Automation::Provider::IRawElementProviderSimple; - using winrt::Windows::UI::Xaml::Automation::Provider::ITextRangeProvider; -} - -namespace winrt::Microsoft::Terminal::Control::implementation -{ - InteractivityAutomationPeer::InteractivityAutomationPeer(Control::implementation::ControlInteractivity* owner) : - _interactivity{ owner } - { - THROW_IF_FAILED(::Microsoft::WRL::MakeAndInitialize<::Microsoft::Terminal::TermControlUiaProvider>(&_uiaProvider, _interactivity->GetRenderData(), this)); - }; - - // Bounds is expected to be in pixels. - void InteractivityAutomationPeer::SetControlBounds(const Windows::Foundation::Rect bounds) - { - _controlBounds = { til::math::rounding, bounds }; - } - - // Padding is expected to be in DIPs. - void InteractivityAutomationPeer::SetControlPadding(const Core::Padding padding) - { - const auto scale = static_cast(DisplayInformation::GetForCurrentView().RawPixelsPerViewPixel()); - _controlPadding = { til::math::rounding, padding.Left * scale, padding.Top * scale, padding.Right * scale, padding.Bottom * scale }; - } - - void InteractivityAutomationPeer::ParentProvider(AutomationPeer parentProvider) - { - // LOAD-BEARING: use _parentProvider->ProviderFromPeer(_parentProvider) instead of this->ProviderFromPeer(*this). - // Since we split the automation peer into TermControlAutomationPeer and InteractivityAutomationPeer, - // using "this" returns null. This can cause issues with some UIA Client scenarios like any navigation in Narrator. - _parentProvider = parentProvider ? parentProvider.as().ProviderFromPeer(parentProvider) : nullptr; - } - - // Method Description: - // - Signals the ui automation client that the terminal's selection has - // changed and should be updated - // - We will raise a new event, for out embedding control to be able to - // raise the event. AutomationPeer by itself doesn't hook up to the - // eventing mechanism, we need the FrameworkAutomationPeer to do that. - // Arguments: - // - - // Return Value: - // - - void InteractivityAutomationPeer::SignalSelectionChanged() - { - SelectionChanged.raise(*this, nullptr); - } - - // Method Description: - // - Signals the ui automation client that the terminal's output has changed - // and should be updated - // - We will raise a new event, for out embedding control to be able to - // raise the event. AutomationPeer by itself doesn't hook up to the - // eventing mechanism, we need the FrameworkAutomationPeer to do that. - // Arguments: - // - - // Return Value: - // - - void InteractivityAutomationPeer::SignalTextChanged() - { - TextChanged.raise(*this, nullptr); - } - - // Method Description: - // - Signals the ui automation client that the cursor's state has changed - // and should be updated - // - We will raise a new event, for out embedding control to be able to - // raise the event. AutomationPeer by itself doesn't hook up to the - // eventing mechanism, we need the FrameworkAutomationPeer to do that. - // Arguments: - // - - // Return Value: - // - - void InteractivityAutomationPeer::SignalCursorChanged() - { - CursorChanged.raise(*this, nullptr); - } - - void InteractivityAutomationPeer::NotifyNewOutput(std::wstring_view newOutput) - { - NewOutput.raise(*this, hstring{ newOutput }); - } - -#pragma region ITextProvider - com_array InteractivityAutomationPeer::GetSelection() - { - SAFEARRAY* pReturnVal; - THROW_IF_FAILED(_uiaProvider->GetSelection(&pReturnVal)); - return WrapArrayOfTextRangeProviders(pReturnVal); - } - - com_array InteractivityAutomationPeer::GetVisibleRanges() - { - SAFEARRAY* pReturnVal; - THROW_IF_FAILED(_uiaProvider->GetVisibleRanges(&pReturnVal)); - return WrapArrayOfTextRangeProviders(pReturnVal); - } - - XamlAutomation::ITextRangeProvider InteractivityAutomationPeer::RangeFromChild(XamlAutomation::IRawElementProviderSimple /*childElement*/) - { - UIA::ITextRangeProvider* returnVal; - // ScreenInfoUiaProvider doesn't actually use parameter, so just pass in nullptr - THROW_IF_FAILED(_uiaProvider->RangeFromChild(/* IRawElementProviderSimple */ nullptr, - &returnVal)); - return _CreateXamlUiaTextRange(returnVal); - } - - XamlAutomation::ITextRangeProvider InteractivityAutomationPeer::RangeFromPoint(Windows::Foundation::Point screenLocation) - { - UIA::ITextRangeProvider* returnVal; - THROW_IF_FAILED(_uiaProvider->RangeFromPoint({ screenLocation.X, screenLocation.Y }, &returnVal)); - return _CreateXamlUiaTextRange(returnVal); - } - - XamlAutomation::ITextRangeProvider InteractivityAutomationPeer::DocumentRange() - { - UIA::ITextRangeProvider* returnVal; - THROW_IF_FAILED(_uiaProvider->get_DocumentRange(&returnVal)); - return _CreateXamlUiaTextRange(returnVal); - } - - XamlAutomation::SupportedTextSelection InteractivityAutomationPeer::SupportedTextSelection() - { - UIA::SupportedTextSelection returnVal; - THROW_IF_FAILED(_uiaProvider->get_SupportedTextSelection(&returnVal)); - return static_cast(returnVal); - } - -#pragma endregion - -#pragma region IControlAccessibilityInfo - til::size InteractivityAutomationPeer::GetFontSize() const noexcept - { - return { til::math::rounding, _interactivity->Core().FontSize() }; - } - - til::rect InteractivityAutomationPeer::GetBounds() const noexcept - { - return _controlBounds; - } - - HRESULT InteractivityAutomationPeer::GetHostUiaProvider(IRawElementProviderSimple** provider) - { - RETURN_HR_IF(E_INVALIDARG, provider == nullptr); - *provider = nullptr; - - return S_OK; - } - - til::rect InteractivityAutomationPeer::GetPadding() const noexcept - { - return _controlPadding; - } - - void InteractivityAutomationPeer::ChangeViewport(const til::inclusive_rect& NewWindow) - { - _interactivity->UpdateScrollbar(static_cast(NewWindow.top)); - } -#pragma endregion - - XamlAutomation::ITextRangeProvider InteractivityAutomationPeer::_CreateXamlUiaTextRange(UIA::ITextRangeProvider* returnVal) const - { - if (!_parentProvider) - { - return nullptr; - } - const auto xutr = winrt::make_self(returnVal, _parentProvider); - return xutr.as(); - }; - - // Method Description: - // - extracts the UiaTextRanges from the SAFEARRAY and converts them to Xaml ITextRangeProviders - // Arguments: - // - SAFEARRAY of UIA::UiaTextRange (ITextRangeProviders) - // Return Value: - // - com_array of Xaml Wrapped UiaTextRange (ITextRangeProviders) - com_array InteractivityAutomationPeer::WrapArrayOfTextRangeProviders(SAFEARRAY* textRanges) - { - if (!_parentProvider) - { - return {}; - } - - // transfer ownership of UiaTextRanges to this new vector - auto providers = SafeArrayToOwningVector<::Microsoft::Terminal::TermControlUiaTextRange>(textRanges); - const auto len = gsl::narrow(providers.size()); - com_array result{ len }; - - for (uint32_t i = 0; i < len; ++i) - { - if (auto xutr = _CreateXamlUiaTextRange(providers[i].detach())) - { - result[i] = std::move(xutr); - } - } - - return result; - } -} diff --git a/src/cascadia/TerminalControl/InteractivityAutomationPeer.h b/src/cascadia/TerminalControl/InteractivityAutomationPeer.h deleted file mode 100644 index d69d19d16e..0000000000 --- a/src/cascadia/TerminalControl/InteractivityAutomationPeer.h +++ /dev/null @@ -1,90 +0,0 @@ -/*++ -Copyright (c) Microsoft Corporation -Licensed under the MIT license. - -Module Name: -- InteractivityAutomationPeer.h - -Abstract: -- This module provides UI Automation access to the ControlInteractivity, - to support both automation tests and accessibility (screen - reading) applications. -- See TermControlAutomationPeer for more details on how UIA is implemented. -- This is the primary implementation of the ITextProvider interface, for the - TermControlAutomationPeer. The TermControlAutomationPeer will be attached to - the actual UI tree, via FrameworkElementAutomationPeer. However, the - ControlInteractivity is totally oblivious to the UI tree that might be hosting - it. So this class implements the actual text pattern for the buffer, because - it has access to the buffer. TermControlAutomationPeer can then call the - methods on this class to expose the implementation in the actual UI tree. - -Author(s): -- Mike Griese (migrie), May 2021 - ---*/ - -#pragma once - -#include "ControlInteractivity.h" -#include "InteractivityAutomationPeer.g.h" -#include "../types/TermControlUiaProvider.hpp" -#include "../types/IUiaEventDispatcher.h" -#include "../types/IControlAccessibilityInfo.h" - -namespace winrt::Microsoft::Terminal::Control::implementation -{ - struct InteractivityAutomationPeer : - public InteractivityAutomationPeerT, - ::Microsoft::Console::Types::IUiaEventDispatcher, - ::Microsoft::Console::Types::IControlAccessibilityInfo - { - public: - InteractivityAutomationPeer(Microsoft::Terminal::Control::implementation::ControlInteractivity* owner); - - void SetControlBounds(const Windows::Foundation::Rect bounds); - void SetControlPadding(const Core::Padding padding); - void ParentProvider(Windows::UI::Xaml::Automation::Peers::AutomationPeer parentProvider); - -#pragma region IUiaEventDispatcher - void SignalSelectionChanged() override; - void SignalTextChanged() override; - void SignalCursorChanged() override; - void NotifyNewOutput(std::wstring_view newOutput) override; -#pragma endregion - -#pragma region ITextProvider Pattern - Windows::UI::Xaml::Automation::Provider::ITextRangeProvider RangeFromPoint(Windows::Foundation::Point screenLocation); - Windows::UI::Xaml::Automation::Provider::ITextRangeProvider RangeFromChild(Windows::UI::Xaml::Automation::Provider::IRawElementProviderSimple childElement); - com_array GetVisibleRanges(); - com_array GetSelection(); - Windows::UI::Xaml::Automation::SupportedTextSelection SupportedTextSelection(); - Windows::UI::Xaml::Automation::Provider::ITextRangeProvider DocumentRange(); -#pragma endregion - -#pragma region IControlAccessibilityInfo Pattern - // Inherited via IControlAccessibilityInfo - virtual til::size GetFontSize() const noexcept override; - virtual til::rect GetBounds() const noexcept override; - virtual til::rect GetPadding() const noexcept override; - virtual void ChangeViewport(const til::inclusive_rect& NewWindow) override; - virtual HRESULT GetHostUiaProvider(IRawElementProviderSimple** provider) override; -#pragma endregion - - til::typed_event SelectionChanged; - til::typed_event TextChanged; - til::typed_event CursorChanged; - til::typed_event NewOutput; - - private: - Windows::UI::Xaml::Automation::Provider::ITextRangeProvider _CreateXamlUiaTextRange(::ITextRangeProvider* returnVal) const; - - ::Microsoft::WRL::ComPtr<::Microsoft::Terminal::TermControlUiaProvider> _uiaProvider; - winrt::Microsoft::Terminal::Control::implementation::ControlInteractivity* _interactivity; - winrt::Windows::UI::Xaml::Automation::Provider::IRawElementProviderSimple _parentProvider{ nullptr }; - - til::rect _controlBounds{}; - til::rect _controlPadding{}; - - winrt::com_array WrapArrayOfTextRangeProviders(SAFEARRAY* textRanges); - }; -} diff --git a/src/cascadia/TerminalControl/InteractivityAutomationPeer.idl b/src/cascadia/TerminalControl/InteractivityAutomationPeer.idl deleted file mode 100644 index e99a79c5ad..0000000000 --- a/src/cascadia/TerminalControl/InteractivityAutomationPeer.idl +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. -namespace Microsoft.Terminal.Control -{ - [default_interface] runtimeclass InteractivityAutomationPeer : - Windows.UI.Xaml.Automation.Peers.FrameworkElementAutomationPeer, - Windows.UI.Xaml.Automation.Provider.ITextProvider - { - - void SetControlBounds(Windows.Foundation.Rect bounds); - void SetControlPadding(Microsoft.Terminal.Core.Padding padding); - void ParentProvider(Windows.UI.Xaml.Automation.Peers.AutomationPeer parentProvider); - - event Windows.Foundation.TypedEventHandler SelectionChanged; - event Windows.Foundation.TypedEventHandler TextChanged; - event Windows.Foundation.TypedEventHandler CursorChanged; - event Windows.Foundation.TypedEventHandler NewOutput; - } -} diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index 20740a16ec..cba99200aa 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -285,62 +285,62 @@ namespace winrt::Microsoft::Terminal::Control::implementation { InitializeComponent(); - _core = _interactivity.Core(); + _core = _interactivity->Core(); // If high contrast mode was changed, update the appearance appropriately. - _core.SetHighContrastMode(_GetAccessibilitySettings().HighContrast()); + _core->SetHighContrastMode(_GetAccessibilitySettings().HighContrast()); _revokers.HighContrastChanged = _GetAccessibilitySettings().HighContrastChanged(winrt::auto_revoke, [weakThis{ get_weak() }](const Windows::UI::ViewManagement::AccessibilitySettings& a11ySettings, auto&&) { if (auto termControl = weakThis.get()) { - termControl->_core.SetHighContrastMode(a11ySettings.HighContrast()); - termControl->_core.ApplyAppearance(termControl->_focused); + termControl->_core->SetHighContrastMode(a11ySettings.HighContrast()); + termControl->_core->ApplyAppearance(termControl->_focused); } }); // This event is specifically triggered by the renderer thread, a BG thread. Use a weak ref here. - _revokers.RendererEnteredErrorState = _core.RendererEnteredErrorState(winrt::auto_revoke, { get_weak(), &TermControl::_RendererEnteredErrorState }); + _revokers.RendererEnteredErrorState = _core->RendererEnteredErrorState(winrt::auto_revoke, { get_weak(), &TermControl::_RendererEnteredErrorState }); // IMPORTANT! Set this callback up sooner rather than later. If we do it // after Enable, then it'll be possible to paint the frame once // _before_ the warning handler is set up, and then warnings from // the first paint will be ignored! - _revokers.RendererWarning = _core.RendererWarning(winrt::auto_revoke, { get_weak(), &TermControl::_RendererWarning }); + _revokers.RendererWarning = _core->RendererWarning(winrt::auto_revoke, { get_weak(), &TermControl::_RendererWarning }); // ALSO IMPORTANT: Make sure to set this callback up in the ctor, so // that we won't miss any swap chain changes. - _revokers.SwapChainChanged = _core.SwapChainChanged(winrt::auto_revoke, { get_weak(), &TermControl::RenderEngineSwapChainChanged }); + _revokers.SwapChainChanged = _core->SwapChainChanged(winrt::auto_revoke, { get_weak(), &TermControl::RenderEngineSwapChainChanged }); // These callbacks can only really be triggered by UI interactions. So // they don't need weak refs - they can't be triggered unless we're // alive. - _revokers.BackgroundColorChanged = _core.BackgroundColorChanged(winrt::auto_revoke, { get_weak(), &TermControl::_coreBackgroundColorChanged }); - _revokers.FontSizeChanged = _core.FontSizeChanged(winrt::auto_revoke, { get_weak(), &TermControl::_coreFontSizeChanged }); - _revokers.TransparencyChanged = _core.TransparencyChanged(winrt::auto_revoke, { get_weak(), &TermControl::_coreTransparencyChanged }); - _revokers.RaiseNotice = _core.RaiseNotice(winrt::auto_revoke, { get_weak(), &TermControl::_coreRaisedNotice }); - _revokers.HoveredHyperlinkChanged = _core.HoveredHyperlinkChanged(winrt::auto_revoke, { get_weak(), &TermControl::_hoveredHyperlinkChanged }); - _revokers.OutputIdle = _core.OutputIdle(winrt::auto_revoke, { get_weak(), &TermControl::_coreOutputIdle }); - _revokers.UpdateSelectionMarkers = _core.UpdateSelectionMarkers(winrt::auto_revoke, { get_weak(), &TermControl::_updateSelectionMarkers }); - _revokers.coreOpenHyperlink = _core.OpenHyperlink(winrt::auto_revoke, { get_weak(), &TermControl::_HyperlinkHandler }); - _revokers.interactivityOpenHyperlink = _interactivity.OpenHyperlink(winrt::auto_revoke, { get_weak(), &TermControl::_HyperlinkHandler }); - _revokers.interactivityScrollPositionChanged = _interactivity.ScrollPositionChanged(winrt::auto_revoke, { get_weak(), &TermControl::_ScrollPositionChanged }); - _revokers.ContextMenuRequested = _interactivity.ContextMenuRequested(winrt::auto_revoke, { get_weak(), &TermControl::_contextMenuHandler }); + _revokers.BackgroundColorChanged = _core->BackgroundColorChanged(winrt::auto_revoke, { get_weak(), &TermControl::_coreBackgroundColorChanged }); + _revokers.FontSizeChanged = _core->FontSizeChanged(winrt::auto_revoke, { get_weak(), &TermControl::_coreFontSizeChanged }); + _revokers.TransparencyChanged = _core->TransparencyChanged(winrt::auto_revoke, { get_weak(), &TermControl::_coreTransparencyChanged }); + _revokers.RaiseNotice = _core->RaiseNotice(winrt::auto_revoke, { get_weak(), &TermControl::_coreRaisedNotice }); + _revokers.HoveredHyperlinkChanged = _core->HoveredHyperlinkChanged(winrt::auto_revoke, { get_weak(), &TermControl::_hoveredHyperlinkChanged }); + _revokers.OutputIdle = _core->OutputIdle(winrt::auto_revoke, { get_weak(), &TermControl::_coreOutputIdle }); + _revokers.UpdateSelectionMarkers = _core->UpdateSelectionMarkers(winrt::auto_revoke, { get_weak(), &TermControl::_updateSelectionMarkers }); + _revokers.coreOpenHyperlink = _core->OpenHyperlink(winrt::auto_revoke, { get_weak(), &TermControl::_HyperlinkHandler }); + _revokers.interactivityOpenHyperlink = _interactivity->OpenHyperlink(winrt::auto_revoke, { get_weak(), &TermControl::_HyperlinkHandler }); + _revokers.interactivityScrollPositionChanged = _interactivity->ScrollPositionChanged(winrt::auto_revoke, { get_weak(), &TermControl::_ScrollPositionChanged }); + _revokers.ContextMenuRequested = _interactivity->ContextMenuRequested(winrt::auto_revoke, { get_weak(), &TermControl::_contextMenuHandler }); // "Bubbled" events - ones we want to handle, by raising our own event. - _revokers.TitleChanged = _core.TitleChanged(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleTitleChanged }); - _revokers.TabColorChanged = _core.TabColorChanged(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleTabColorChanged }); - _revokers.TaskbarProgressChanged = _core.TaskbarProgressChanged(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleSetTaskbarProgress }); - _revokers.ConnectionStateChanged = _core.ConnectionStateChanged(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleConnectionStateChanged }); - _revokers.ShowWindowChanged = _core.ShowWindowChanged(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleShowWindowChanged }); - _revokers.CloseTerminalRequested = _core.CloseTerminalRequested(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleCloseTerminalRequested }); - _revokers.CompletionsChanged = _core.CompletionsChanged(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleCompletionsChanged }); - _revokers.RestartTerminalRequested = _core.RestartTerminalRequested(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleRestartTerminalRequested }); - _revokers.SearchMissingCommand = _core.SearchMissingCommand(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleSearchMissingCommand }); - _revokers.ShowNotification = _core.ShowNotification(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleShowNotification }); - _revokers.WindowSizeChanged = _core.WindowSizeChanged(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleWindowSizeChanged }); - _revokers.WriteToClipboard = _core.WriteToClipboard(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleWriteToClipboard }); + _revokers.TitleChanged = _core->TitleChanged(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleTitleChanged }); + _revokers.TabColorChanged = _core->TabColorChanged(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleTabColorChanged }); + _revokers.TaskbarProgressChanged = _core->TaskbarProgressChanged(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleSetTaskbarProgress }); + _revokers.ConnectionStateChanged = _core->ConnectionStateChanged(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleConnectionStateChanged }); + _revokers.ShowWindowChanged = _core->ShowWindowChanged(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleShowWindowChanged }); + _revokers.CloseTerminalRequested = _core->CloseTerminalRequested(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleCloseTerminalRequested }); + _revokers.CompletionsChanged = _core->CompletionsChanged(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleCompletionsChanged }); + _revokers.RestartTerminalRequested = _core->RestartTerminalRequested(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleRestartTerminalRequested }); + _revokers.SearchMissingCommand = _core->SearchMissingCommand(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleSearchMissingCommand }); + _revokers.ShowNotification = _core->ShowNotification(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleShowNotification }); + _revokers.WindowSizeChanged = _core->WindowSizeChanged(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleWindowSizeChanged }); + _revokers.WriteToClipboard = _core->WriteToClipboard(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleWriteToClipboard }); - _revokers.PasteFromClipboard = _interactivity.PasteFromClipboard(winrt::auto_revoke, { get_weak(), &TermControl::_bubblePasteFromClipboard }); + _revokers.PasteFromClipboard = _interactivity->PasteFromClipboard(winrt::auto_revoke, { get_weak(), &TermControl::_bubblePasteFromClipboard }); - _revokers.RefreshQuickFixUI = _core.RefreshQuickFixUI(winrt::auto_revoke, [this](auto /*s*/, auto /*e*/) { + _revokers.RefreshQuickFixUI = _core->RefreshQuickFixUI(winrt::auto_revoke, [this](auto /*s*/, auto /*e*/) { RefreshQuickFixMenu(); }); @@ -398,8 +398,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation // NOTE: _ScrollPositionChanged has to be registered after we set up the // _updateScrollBar func. Otherwise, we could get a callback from an // attached content before we set up the throttled func, and that'll A/V - _revokers.coreScrollPositionChanged = _core.ScrollPositionChanged(winrt::auto_revoke, { get_weak(), &TermControl::_ScrollPositionChanged }); - _revokers.WarningBell = _core.WarningBell(winrt::auto_revoke, { get_weak(), &TermControl::_coreWarningBell }); + _revokers.coreScrollPositionChanged = _core->ScrollPositionChanged(winrt::auto_revoke, { get_weak(), &TermControl::_ScrollPositionChanged }); + _revokers.WarningBell = _core->WarningBell(winrt::auto_revoke, { get_weak(), &TermControl::_coreWarningBell }); static constexpr auto AutoScrollUpdateInterval = std::chrono::microseconds(static_cast(1.0 / 30.0 * 1000000)); _autoScrollTimer.Interval(AutoScrollUpdateInterval); @@ -507,8 +507,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation void TermControl::_initializeForAttach() { - _AttachDxgiSwapChainToXaml(reinterpret_cast(_core.SwapChainHandle())); - _interactivity.AttachToNewControl(); + _AttachDxgiSwapChainToXaml(reinterpret_cast(_core->SwapChainHandle())); + _interactivity->AttachToNewControl(); // Initialize the terminal only once the swapchainpanel is loaded - that // way, we'll be able to query the real pixel size it got on layout @@ -527,21 +527,21 @@ namespace winrt::Microsoft::Terminal::Control::implementation uint64_t TermControl::ContentId() const { - return _interactivity.Id(); + return _interactivity->Id(); } TerminalConnection::ITerminalConnection TermControl::Connection() { - return _core.Connection(); + return _core->Connection(); } void TermControl::Connection(const TerminalConnection::ITerminalConnection& newConnection) { - _core.Connection(newConnection); + _core->Connection(newConnection); } void TermControl::HardResetWithoutErase() { - _core.HardResetWithoutErase(); + _core->HardResetWithoutErase(); } void TermControl::_throttledUpdateScrollbar(const ScrollBarUpdate& update) @@ -640,7 +640,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation memset(data, 0, buffer.Length()); - if (const auto marks = _core.ScrollMarks()) + if (const auto marks = _core->ScrollMarks()) { for (const auto& m : marks) { @@ -689,14 +689,14 @@ namespace winrt::Microsoft::Terminal::Control::implementation // If a text is selected inside terminal, use it to populate the search box. // If the search box already contains a value, it will be overridden. - if (_core.HasSelection()) + if (_core->HasSelection()) { // Currently we populate the search box only if a single line is selected. // Empirically, multi-line selection works as well on sample scenarios, // but since code paths differ, extra work is required to ensure correctness. - if (!_core.HasMultiLineSelection()) + if (!_core->HasMultiLineSelection()) { - const auto selectedLine{ _core.SelectedText(true) }; + const auto selectedLine{ _core->SelectedText(true) }; _searchBox->PopulateTextbox(selectedLine); } } @@ -726,7 +726,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation } else { - _handleSearchResults(_core.Search(SearchRequest{ + _handleSearchResults(_core->Search(SearchRequest{ .Text = _searchBox->Text(), .GoForward = goForward, .CaseSensitive = _searchBox->CaseSensitive(), @@ -768,7 +768,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation { if (_searchBox && _searchBox->IsOpen()) { - _handleSearchResults(_core.Search(SearchRequest{ + _handleSearchResults(_core->Search(SearchRequest{ .Text = text, .GoForward = goForward, .CaseSensitive = caseSensitive, @@ -795,7 +795,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation { if (_searchBox && _searchBox->IsOpen()) { - _handleSearchResults(_core.Search(SearchRequest{ + _handleSearchResults(_core->Search(SearchRequest{ .Text = text, .GoForward = goForward, .CaseSensitive = caseSensitive, @@ -819,7 +819,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation const RoutedEventArgs& /*args*/) { _searchBox->Close(); - _core.ClearSearch(); + _core->ClearSearch(); // Clear search highlights scroll marks (by triggering an update after closing the search box) if (_showMarksInScrollbar) @@ -840,7 +840,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation void TermControl::UpdateControlSettings(IControlSettings settings) { - UpdateControlSettings(settings, _core.UnfocusedAppearance()); + UpdateControlSettings(settings, _core->UnfocusedAppearance()); } // Method Description: // - Given Settings having been updated, applies the settings to the current terminal. @@ -848,11 +848,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation // - void TermControl::UpdateControlSettings(IControlSettings settings, IControlAppearance unfocusedAppearance) { - _core.UpdateSettings(settings, unfocusedAppearance); + _core->UpdateSettings(settings, unfocusedAppearance); _UpdateSettingsFromUIThread(); - _UpdateAppearanceFromUIThread(_focused ? _core.FocusedAppearance() : _core.UnfocusedAppearance()); + _UpdateAppearanceFromUIThread(_focused ? _core->FocusedAppearance() : _core->UnfocusedAppearance()); } // Method Description: @@ -910,7 +910,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation SelectionStartMarker().Fill(cursorColorBrush); SelectionEndMarker().Fill(cursorColorBrush); - _core.ApplyAppearance(_focused); + _core->ApplyAppearance(_focused); } // Method Description: @@ -934,12 +934,12 @@ namespace winrt::Microsoft::Terminal::Control::implementation } void TermControl::ClearBuffer(Control::ClearBufferType clearType) { - _core.ClearBuffer(clearType); + _core->ClearBuffer(clearType); } void TermControl::ToggleShaderEffects() { - _core.ToggleShaderEffects(); + _core->ToggleShaderEffects(); } // Method Description: @@ -959,7 +959,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation _InitializeBackgroundBrush(); // settings might be out-of-proc in the future - auto settings{ _core.Settings() }; + auto settings{ _core->Settings() }; // Apply padding as swapChainPanel's margin const auto newMargin = StringToXamlThickness(settings.Padding()); @@ -981,21 +981,12 @@ namespace winrt::Microsoft::Terminal::Control::implementation ScrollBar().Visibility(Visibility::Visible); } - _interactivity.UpdateSettings(); + _interactivity->UpdateSettings(); { const auto inputScope = settings.DefaultInputScope(); const auto alpha = inputScope == DefaultInputScope::AlphanumericHalfWidth; ::Microsoft::Console::TSF::Handle::SetDefaultScopeAlphanumericHalfWidth(alpha); } - if (_automationPeer) - { - _automationPeer.SetControlPadding(Core::Padding{ - static_cast(newMargin.Left), - static_cast(newMargin.Top), - static_cast(newMargin.Right), - static_cast(newMargin.Bottom), - }); - } _showMarksInScrollbar = settings.ShowMarks(); // Hide all scrollbar marks since they might be disabled now. @@ -1020,7 +1011,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation // - void TermControl::_SetBackgroundImage(const IControlAppearance& newAppearance) { - if (newAppearance.BackgroundImage().empty() || _core.Settings().UseBackgroundImageForWindow()) + if (newAppearance.BackgroundImage().empty() || _core->Settings().UseBackgroundImageForWindow()) { BackgroundImage().Source(nullptr); return; @@ -1076,8 +1067,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation // - void TermControl::_InitializeBackgroundBrush() { - auto settings{ _core.Settings() }; - auto bgColor = til::color{ _core.FocusedAppearance().DefaultBackground() }; + auto settings{ _core->Settings() }; + auto bgColor = til::color{ _core->FocusedAppearance().DefaultBackground() }; auto transparentBg = settings.UseBackgroundImageForWindow(); if (transparentBg) @@ -1087,7 +1078,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation // GH#11743: Make sure to use the Core's current UseAcrylic value, not // the one from the settings. The Core's runtime UseAcrylic may have // changed from what was in the original settings. - if (_core.UseAcrylic() && !transparentBg) + if (_core->UseAcrylic() && !transparentBg) { // See if we've already got an acrylic background brush // to avoid the flicker when setting up a new one @@ -1100,7 +1091,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation } const auto backdropStyle = - _core.Settings().EnableUnfocusedAcrylic() ? Media::AcrylicBackgroundSource::Backdrop : Media::AcrylicBackgroundSource::HostBackdrop; + _core->Settings().EnableUnfocusedAcrylic() ? Media::AcrylicBackgroundSource::Backdrop : Media::AcrylicBackgroundSource::HostBackdrop; acrylic.BackgroundSource(backdropStyle); // see GH#1082: Initialize background color so we don't get a @@ -1109,7 +1100,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation acrylic.TintColor(bgColor); // Apply brush settings - acrylic.TintOpacity(_core.Opacity()); + acrylic.TintOpacity(_core->Opacity()); // Apply brush to control if it's not already there if (RootGrid().Background() != acrylic) @@ -1120,7 +1111,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation else { Media::SolidColorBrush solidColor{}; - solidColor.Opacity(_core.Opacity()); + solidColor.Opacity(_core->Opacity()); solidColor.Color(bgColor); RootGrid().Background(solidColor); @@ -1144,7 +1135,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation co_await wil::resume_foreground(Dispatcher()); if (auto control{ weakThis.get() }) { - til::color newBgColor{ _core.BackgroundColor() }; + til::color newBgColor{ _core->BackgroundColor() }; _changeBackgroundColor(newBgColor); } } @@ -1157,7 +1148,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation // - bg: the new color to use as the background color. void TermControl::_changeBackgroundColor(til::color bg) { - auto transparent_bg = _core.Settings().UseBackgroundImageForWindow(); + auto transparent_bg = _core->Settings().UseBackgroundImageForWindow(); if (transparent_bg) { bg = Windows::UI::Colors::Transparent(); @@ -1205,8 +1196,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation // - INVARIANT: This needs to be called on the UI thread. void TermControl::_changeBackgroundOpacity() { - const auto opacity{ _core.Opacity() }; - const auto useAcrylic{ _core.UseAcrylic() }; + const auto opacity{ _core->Opacity() }; + const auto useAcrylic{ _core->UseAcrylic() }; auto changed = false; // GH#11743, #11619: If we're changing whether or not acrylic is used, // then just entirely reinitialize the brush. The primary way that this @@ -1265,18 +1256,16 @@ namespace winrt::Microsoft::Terminal::Control::implementation // create a custom automation peer with this code pattern: // (https://docs.microsoft.com/en-us/windows/uwp/design/accessibility/custom-automation-peers) - if (const auto& interactivityAutoPeer{ _interactivity.OnCreateAutomationPeer() }) - { - const auto margins{ SwapChainPanel().Margin() }; - const Core::Padding padding{ - static_cast(margins.Left), - static_cast(margins.Top), - static_cast(margins.Right), - static_cast(margins.Bottom), - }; - _automationPeer = winrt::make(get_strong(), padding, interactivityAutoPeer); - return _automationPeer; - } + const auto margins{ SwapChainPanel().Margin() }; + const Core::Padding padding{ + static_cast(margins.Left), + static_cast(margins.Top), + static_cast(margins.Right), + static_cast(margins.Bottom), + }; + _automationPeer = winrt::make_self(get_strong(), padding); + _interactivity->SetUiaEventDispatcher(_automationPeer.get()); + return *_automationPeer; } return nullptr; } @@ -1285,7 +1274,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation // clever way around asking the core for this. winrt::Windows::Foundation::Size TermControl::GetFontSize() const { - return _core.FontSize(); + return _core->FontSize(); } const Windows::UI::Xaml::Thickness TermControl::GetPadding() @@ -1295,7 +1284,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation TerminalConnection::ConnectionState TermControl::ConnectionState() const { - return _core.ConnectionState(); + return _core->ConnectionState(); } void TermControl::RenderEngineSwapChainChanged(IInspectable /*sender*/, IInspectable args) @@ -1396,15 +1385,15 @@ namespace winrt::Microsoft::Terminal::Control::implementation // If we're re-attaching an existing content, then we want to proceed even though the Terminal was already initialized. if (reason == InitializeReason::Create) { - const auto coreInitialized = _core.Initialize(panelWidth, - panelHeight, - panelScaleX); + const auto coreInitialized = _core->Initialize(panelWidth, + panelHeight, + panelScaleX); if (!coreInitialized) { return false; } - _interactivity.Initialize(); + _interactivity->Initialize(); if (!_restorePath.empty()) { @@ -1412,17 +1401,17 @@ namespace winrt::Microsoft::Terminal::Control::implementation } else { - _core.Connection().Start(); + _core->Connection().Start(); } } else { - _core.SizeOrScaleChanged(panelWidth, panelHeight, panelScaleX); + _core->SizeOrScaleChanged(panelWidth, panelHeight, panelScaleX); } - _core.EnablePainting(); + _core->EnablePainting(); - auto bufferHeight = _core.BufferHeight(); + auto bufferHeight = _core->BufferHeight(); ScrollBar().Maximum(0); ScrollBar().Minimum(0); @@ -1431,24 +1420,10 @@ namespace winrt::Microsoft::Terminal::Control::implementation ScrollBar().LargeChange(bufferHeight); // scroll one "screenful" at a time when the scroll bar is clicked // Now that the renderer is set up, update the appearance for initialization - _UpdateAppearanceFromUIThread(_core.FocusedAppearance()); + _UpdateAppearanceFromUIThread(_core->FocusedAppearance()); _initializedTerminal = true; - // MSFT 33353327: If the AutomationPeer was created before we were done initializing, - // make sure it's properly set up now. - if (_automationPeer) - { - _automationPeer.UpdateControlBounds(); - const auto margins{ GetPadding() }; - _automationPeer.SetControlPadding(Core::Padding{ - static_cast(margins.Left), - static_cast(margins.Top), - static_cast(margins.Right), - static_cast(margins.Bottom), - }); - } - // Likewise, run the event handlers outside of lock (they could // be reentrant) Initialized.raise(*this, nullptr); @@ -1485,7 +1460,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation co_return; } - if (const auto connection = _core.Connection()) + if (const auto connection = _core->Connection()) { connection.Start(); } @@ -1528,12 +1503,12 @@ namespace winrt::Microsoft::Terminal::Control::implementation const WORD scanCode, const winrt::Microsoft::Terminal::Core::ControlKeyStates modifiers) { - return _core.SendCharEvent(character, scanCode, modifiers); + return _core->SendCharEvent(character, scanCode, modifiers); } void TermControl::RawWriteString(const winrt::hstring& text) { - _core.SendInput(text); + _core->SendInput(text); } // Method Description: @@ -1608,7 +1583,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation } // Short-circuit isReadOnly check to avoid warning dialog - if (_core.IsInReadOnlyMode()) + if (_core->IsInReadOnlyMode()) { return !keyDown || _TryHandleKeyBinding(vkey, scanCode, modifiers); } @@ -1682,7 +1657,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation // If it encounters a string that isn't, cppwinrt will abort(). // It should already be null-terminated, but let's make sure to not crash. buf[buf_len] = L'\0'; - _core.SendInput(std::wstring_view{ &buf[0], buf_len }); + _core->SendInput(std::wstring_view{ &buf[0], buf_len }); } s = {}; @@ -1840,7 +1815,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation // Mark mode has a specific set of pre-defined key bindings. // If we're in mark mode, we should be prioritizing those over // the custom defined key bindings. - if (_core.TryMarkModeKeybinding(vkey, modifiers)) + if (_core->TryMarkModeKeybinding(vkey, modifiers)) { return true; } @@ -1927,10 +1902,10 @@ namespace winrt::Microsoft::Terminal::Control::implementation // This will prevent the system from trying to get the character out // of it and sending us a CharacterReceived event. const auto handled = vkey ? - _core.TrySendKeyEvent(vkey, - scanCode, - modifiers, - keyDown) : + _core->TrySendKeyEvent(vkey, + scanCode, + modifiers, + keyDown) : true; if (vkey && keyDown && _automationPeer) @@ -2002,17 +1977,17 @@ namespace winrt::Microsoft::Terminal::Control::implementation // I suspect the point.Position() would be correct. const auto contactRect = point.Properties().ContactRect(); til::point newTouchPoint{ til::math::rounding, contactRect.X, contactRect.Y }; - _interactivity.TouchPressed(newTouchPoint.to_core_point()); + _interactivity->TouchPressed(newTouchPoint.to_core_point()); } else { const auto cursorPosition = point.Position(); - _interactivity.PointerPressed(point.PointerId(), - TermControl::GetPressedMouseButtons(point), - TermControl::GetPointerUpdateKind(point), - point.Timestamp(), - ControlKeyStates{ args.KeyModifiers() }, - _toTerminalOrigin(cursorPosition)); + _interactivity->PointerPressed(point.PointerId(), + TermControl::GetPressedMouseButtons(point), + TermControl::GetPointerUpdateKind(point), + point.Timestamp(), + ControlKeyStates{ args.KeyModifiers() }, + _toTerminalOrigin(cursorPosition)); } args.Handled(true); @@ -2039,7 +2014,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation const auto pixelPosition = _toTerminalOrigin(cursorPosition); const auto type = ptr.PointerDeviceType(); - if (!_focused && _core.Settings().FocusFollowMouse()) + if (!_focused && _core->Settings().FocusFollowMouse()) { FocusFollowMouseRequested.raise(*this, nullptr); } @@ -2047,11 +2022,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation if (type == Windows::Devices::Input::PointerDeviceType::Mouse || type == Windows::Devices::Input::PointerDeviceType::Pen) { - auto suppressFurtherHandling = _interactivity.PointerMoved(point.PointerId(), - TermControl::GetPressedMouseButtons(point), - TermControl::GetPointerUpdateKind(point), - ControlKeyStates(args.KeyModifiers()), - pixelPosition); + auto suppressFurtherHandling = _interactivity->PointerMoved(point.PointerId(), + TermControl::GetPressedMouseButtons(point), + TermControl::GetPointerUpdateKind(point), + ControlKeyStates(args.KeyModifiers()), + pixelPosition); // GH#9109 - Only start an auto-scroll when the drag actually // started within our bounds. Otherwise, someone could start a drag @@ -2092,7 +2067,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation const auto contactRect = point.Properties().ContactRect(); til::point newTouchPoint{ til::math::rounding, contactRect.X, contactRect.Y }; - _interactivity.TouchMoved(newTouchPoint.to_core_point()); + _interactivity->TouchMoved(newTouchPoint.to_core_point()); } args.Handled(true); @@ -2125,15 +2100,15 @@ namespace winrt::Microsoft::Terminal::Control::implementation if (type == Windows::Devices::Input::PointerDeviceType::Mouse || type == Windows::Devices::Input::PointerDeviceType::Pen) { - _interactivity.PointerReleased(point.PointerId(), - TermControl::GetPressedMouseButtons(point), - TermControl::GetPointerUpdateKind(point), - ControlKeyStates(args.KeyModifiers()), - pixelPosition); + _interactivity->PointerReleased(point.PointerId(), + TermControl::GetPressedMouseButtons(point), + TermControl::GetPointerUpdateKind(point), + ControlKeyStates(args.KeyModifiers()), + pixelPosition); } else if (type == Windows::Devices::Input::PointerDeviceType::Touch) { - _interactivity.TouchReleased(); + _interactivity->TouchReleased(); } _TryStopAutoScroll(ptr.PointerId()); @@ -2161,12 +2136,12 @@ namespace winrt::Microsoft::Terminal::Control::implementation const auto point = args.GetCurrentPoint(*this); auto delta = point.Properties().MouseWheelDelta(); - auto result = _interactivity.MouseWheel(ControlKeyStates{ args.KeyModifiers() }, - point.Properties().IsHorizontalMouseWheel() ? - Core::Point{ delta, 0 } : - Core::Point{ 0, delta }, - _toTerminalOrigin(point.Position()), - TermControl::GetPressedMouseButtons(point)); + auto result = _interactivity->MouseWheel(ControlKeyStates{ args.KeyModifiers() }, + point.Properties().IsHorizontalMouseWheel() ? + Core::Point{ delta, 0 } : + Core::Point{ 0, delta }, + _toTerminalOrigin(point.Position()), + TermControl::GetPressedMouseButtons(point)); if (result) { args.Handled(true); @@ -2196,7 +2171,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation WI_SetFlagIf(state, Control::MouseButtonState::IsMiddleButtonDown, midButtonDown); WI_SetFlagIf(state, Control::MouseButtonState::IsRightButtonDown, rightButtonDown); - return _interactivity.MouseWheel(modifiers, delta, _toTerminalOrigin(location), state); + return _interactivity->MouseWheel(modifiers, delta, _toTerminalOrigin(location), state); } // Method Description: @@ -2223,7 +2198,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation // - none void TermControl::ResetFontSize() { - _core.ResetFontSize(); + _core->ResetFontSize(); } // Method Description: @@ -2232,7 +2207,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation // - fontSizeDelta: The amount to increase or decrease the font size by. void TermControl::AdjustFontSize(float fontSizeDelta) { - _core.AdjustFontSize(fontSizeDelta); + _core->AdjustFontSize(fontSizeDelta); } void TermControl::_ScrollbarChangeHandler(const Windows::Foundation::IInspectable& /*sender*/, @@ -2247,7 +2222,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation } const auto newValue = args.NewValue(); - _interactivity.UpdateScrollbar(static_cast(newValue)); + _interactivity->UpdateScrollbar(static_cast(newValue)); // User input takes priority over terminal events so cancel // any pending scroll bar update if the user scrolls. @@ -2393,7 +2368,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation if (_interactivity) { - _interactivity.GotFocus(); + _interactivity->GotFocus(); } // If the searchbox is focused, we don't want TSFInputControl to think @@ -2408,9 +2383,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation // unfocused config does not exist then we never would have switched // appearances anyway so there's no need to switch back upon gaining // focus - if (_core.HasUnfocusedAppearance()) + if (_core->HasUnfocusedAppearance()) { - UpdateAppearance(_core.FocusedAppearance()); + UpdateAppearance(_core->FocusedAppearance()); } GetTSFHandle().Focus(&_tsfDataProvider); @@ -2436,14 +2411,14 @@ namespace winrt::Microsoft::Terminal::Control::implementation // UiaEngine lives in ControlInteractivity if (_interactivity) { - _interactivity.LostFocus(); + _interactivity->LostFocus(); } // Check if there is an unfocused config we should set the appearance to // upon losing focus - if (_core.HasUnfocusedAppearance()) + if (_core->HasUnfocusedAppearance()) { - UpdateAppearance(_core.UnfocusedAppearance()); + UpdateAppearance(_core->UnfocusedAppearance()); } GetTSFHandle().Unfocus(&_tsfDataProvider); @@ -2468,13 +2443,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation return; } - _core.SizeChanged(newSize.Width, newSize.Height); + _core->SizeChanged(newSize.Width, newSize.Height); _ShowResizeOverlay(); - - if (_automationPeer) - { - _automationPeer.UpdateControlBounds(); - } } // Shows an overlay with the current terminal dimensions (columns x rows). @@ -2554,7 +2524,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation { const auto scaleX = sender.CompositionScaleX(); - _core.ScaleChanged(scaleX); + _core->ScaleChanged(scaleX); } // Method Description: @@ -2563,7 +2533,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation // - cursorPosition: in pixels, relative to the origin of the control void TermControl::_SetEndSelectionPointAtCursor(const Windows::Foundation::Point& cursorPosition) { - _interactivity.SetEndSelectionPoint(_toTerminalOrigin(cursorPosition)); + _interactivity->SetEndSelectionPoint(_toTerminalOrigin(cursorPosition)); } // Method Description: @@ -2590,7 +2560,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation // If we have a selection with markers (exposed via selection mode), // update the position of the markers - if (_core.HasSelection() && _core.SelectionMode() >= SelectionInteractionMode::Keyboard) + if (_core->HasSelection() && _core->SelectionMode() >= SelectionInteractionMode::Keyboard) { _updateSelectionMarkers(nullptr, winrt::make(false)); } @@ -2600,22 +2570,22 @@ namespace winrt::Microsoft::Terminal::Control::implementation hstring TermControl::Title() { - return _core.Title(); + return _core->Title(); } hstring TermControl::GetStartingTitle() const { - return _core.Settings().StartingTitle(); + return _core->Settings().StartingTitle(); } hstring TermControl::WorkingDirectory() const { - return _core.WorkingDirectory(); + return _core->WorkingDirectory(); } bool TermControl::BracketedPasteEnabled() const noexcept { - return _core.BracketedPasteEnabled(); + return _core->BracketedPasteEnabled(); } // Method Description: @@ -2635,11 +2605,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation return false; } - const auto successfulCopy = _interactivity.CopySelectionToClipboard(singleLine, withControlSequences, formats); + const auto successfulCopy = _interactivity->CopySelectionToClipboard(singleLine, withControlSequences, formats); if (dismissSelection) { - _core.ClearSelection(); + _core->ClearSelection(); } return successfulCopy; @@ -2649,32 +2619,32 @@ namespace winrt::Microsoft::Terminal::Control::implementation // - Initiate a paste operation. void TermControl::PasteTextFromClipboard() { - _interactivity.RequestPasteTextFromClipboard(); + _interactivity->RequestPasteTextFromClipboard(); } void TermControl::SelectAll() { - _core.SelectAll(); + _core->SelectAll(); } bool TermControl::ToggleBlockSelection() { - return _core.ToggleBlockSelection(); + return _core->ToggleBlockSelection(); } void TermControl::ToggleMarkMode() { - _core.ToggleMarkMode(); + _core->ToggleMarkMode(); } bool TermControl::SwitchSelectionEndpoint() { - return _core.SwitchSelectionEndpoint(); + return _core->SwitchSelectionEndpoint(); } bool TermControl::ExpandSelectionToWord() { - return _core.ExpandSelectionToWord(); + return _core->ExpandSelectionToWord(); } void TermControl::RestoreFromPath(winrt::hstring path) @@ -2700,7 +2670,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation void TermControl::OpenCWD() { - _core.OpenCWD(); + _core->OpenCWD(); } void TermControl::Close() @@ -2733,7 +2703,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation if (!_detached) { - _interactivity.Close(); + _interactivity->Close(); } } } @@ -2742,9 +2712,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation { _revokers = {}; - Control::ControlInteractivity old{ nullptr }; + decltype(_interactivity) old{ nullptr }; std::swap(old, _interactivity); - old.Detach(); + old->Detach(); _detached = true; } @@ -2760,18 +2730,18 @@ namespace winrt::Microsoft::Terminal::Control::implementation int TermControl::ScrollOffset() const { - return _core.ScrollOffset(); + return _core->ScrollOffset(); } // Gets the size of the terminal in cells. Core::Size TermControl::ViewportSize() const { - return _core.ViewportSize(); + return _core->ViewportSize(); } int TermControl::BufferHeight() const { - return _core.BufferHeight(); + return _core->BufferHeight(); } // Function Description: @@ -2900,9 +2870,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation { const auto cols = std::max(::base::saturated_cast(sizeInChars.Width), MINIMUM_VISIBLE_CELLS); const auto rows = std::max(::base::saturated_cast(sizeInChars.Height), MINIMUM_VISIBLE_CELLS); - const auto fontSize = _core.FontSize(); - const auto scrollState = _core.Settings().ScrollState(); - const auto padding = _core.Settings().Padding(); + const auto fontSize = _core->FontSize(); + const auto scrollState = _core->Settings().ScrollState(); + const auto padding = _core->Settings().Padding(); const auto scale = static_cast(DisplayInformation::GetForCurrentView().RawPixelsPerViewPixel()); float width = cols * static_cast(fontSize.Width); float height = rows * static_cast(fontSize.Height); @@ -2935,7 +2905,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation // - The dimensions of a single character of this control, in DIPs winrt::Windows::Foundation::Size TermControl::CharacterDimensions() const { - return _core.FontSizeInDips(); + return _core->FontSizeInDips(); } // Method Description: @@ -2953,11 +2923,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation { if (_initializedTerminal) { - const auto fontSize = _core.FontSizeInDips(); + const auto fontSize = _core->FontSizeInDips(); auto width = fontSize.Width * MINIMUM_VISIBLE_CELLS; auto height = fontSize.Height * MINIMUM_VISIBLE_CELLS; // Reserve additional space if scrollbar is intended to be visible - if (_core.Settings().ScrollState() != ScrollbarState::Hidden) + if (_core->Settings().ScrollState() != ScrollbarState::Hidden) { width += static_cast(ScrollBar().ActualWidth()); } @@ -2985,7 +2955,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation // - A dimension that would be aligned to the character grid. float TermControl::SnapDimensionToGrid(const bool widthOrHeight, const float dimension) { - const auto fontSize = _core.FontSizeInDips(); + const auto fontSize = _core->FontSizeInDips(); const auto fontDimension = widthOrHeight ? fontSize.Width : fontSize.Height; const auto padding = GetPadding(); @@ -2993,7 +2963,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation padding.Left + padding.Right : padding.Top + padding.Bottom); - if (widthOrHeight && _core.Settings().ScrollState() != ScrollbarState::Hidden) + if (widthOrHeight && _core->Settings().ScrollState() != ScrollbarState::Hidden) { nonTerminalArea += gsl::narrow_cast(ScrollBar().ActualWidth()); } @@ -3013,7 +2983,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation // - void TermControl::WindowVisibilityChanged(const bool showOrHide) { - _core.WindowVisibilityChanged(showOrHide); + _core->WindowVisibilityChanged(showOrHide); } // Method Description: @@ -3261,7 +3231,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation } std::wstring allPathsString; - const auto delimiter{ _core.Settings().DragDropDelimiter() }; + const auto delimiter{ _core->Settings().DragDropDelimiter() }; for (auto& fullPath : fullPaths) { // Join the paths with the delimiter @@ -3270,7 +3240,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation allPathsString += delimiter; } - const auto translationStyle{ _core.Settings().PathTranslationStyle() }; + const auto translationStyle{ _core->Settings().PathTranslationStyle() }; _translatePathInPlace(fullPath, translationStyle); // All translated paths get quotes, and all strings spaces get quotes; all translated paths get single quotes @@ -3307,7 +3277,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation { StringSent.raise(*this, winrt::make(text)); } - _core.PasteText(text); + _core->PasteText(text); } // Method Description: @@ -3400,12 +3370,12 @@ namespace winrt::Microsoft::Terminal::Control::implementation { // It's already loaded if we get here, so just hide it. RendererFailedNotice().Visibility(Visibility::Collapsed); - _core.ResumeRendering(); + _core->ResumeRendering(); } IControlSettings TermControl::Settings() const { - return _core.Settings(); + return _core->Settings(); } Windows::Foundation::IReference TermControl::TabColor() noexcept @@ -3414,7 +3384,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation // hypothetical future where we allow an application to set the tab // color with VT sequences like they're currently allowed to with the // title. - return _core.TabColor(); + return _core->TabColor(); } // Method Description: @@ -3423,7 +3393,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation // - The taskbar state of this control const uint64_t TermControl::TaskbarState() const noexcept { - return _core.TaskbarState(); + return _core->TaskbarState(); } // Method Description: @@ -3432,7 +3402,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation // - The taskbar progress of this control const uint64_t TermControl::TaskbarProgress() const noexcept { - return _core.TaskbarProgress(); + return _core->TaskbarProgress(); } void TermControl::BellLightOn() @@ -3501,23 +3471,23 @@ namespace winrt::Microsoft::Terminal::Control::implementation // - True if the mode is read-only bool TermControl::ReadOnly() const noexcept { - return _core.IsInReadOnlyMode(); + return _core->IsInReadOnlyMode(); } // Method Description: // - Toggles the read-only flag, raises event describing the value change void TermControl::ToggleReadOnly() { - _core.ToggleReadOnlyMode(); - ReadOnlyChanged.raise(*this, winrt::box_value(_core.IsInReadOnlyMode())); + _core->ToggleReadOnlyMode(); + ReadOnlyChanged.raise(*this, winrt::box_value(_core->IsInReadOnlyMode())); } // Method Description: // - Sets the read-only flag, raises event describing the value change void TermControl::SetReadOnly(const bool readOnlyState) { - _core.SetReadOnlyMode(readOnlyState); - ReadOnlyChanged.raise(*this, winrt::box_value(_core.IsInReadOnlyMode())); + _core->SetReadOnlyMode(readOnlyState); + ReadOnlyChanged.raise(*this, winrt::box_value(_core->IsInReadOnlyMode())); } // Method Description: @@ -3529,18 +3499,18 @@ namespace winrt::Microsoft::Terminal::Control::implementation void TermControl::_PointerExitedHandler(const Windows::Foundation::IInspectable& /*sender*/, const Windows::UI::Xaml::Input::PointerRoutedEventArgs& /*e*/) { - _core.ClearHoveredCell(); + _core->ClearHoveredCell(); } void TermControl::_hoveredHyperlinkChanged(const IInspectable& /*sender*/, const IInspectable& /*args*/) { - const auto lastHoveredCell = _core.HoveredCell(); + const auto lastHoveredCell = _core->HoveredCell(); if (!lastHoveredCell) { return; } - auto uriText = _core.HoveredUriText(); + auto uriText = _core->HoveredUriText(); if (uriText.empty()) { return; @@ -3612,11 +3582,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation co_await resume_foreground(Dispatcher()); if (const auto strong = weakThis.get()) { - if (_core.HasSelection() && !args.ClearMarkers()) + if (_core->HasSelection() && !args.ClearMarkers()) { // retrieve all of the necessary selection marker data // from the TerminalCore layer under one lock to improve performance - const auto markerData{ _core.SelectionInfo() }; + const auto markerData{ _core->SelectionInfo() }; // lambda helper function that can be used to display a selection marker // - targetEnd: if true, target the "end" selection marker. Otherwise, target "start". @@ -3661,7 +3631,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation const auto selectionAnchor{ movingEnd ? markerData.EndPos : markerData.StartPos }; const auto& marker{ movingEnd ? SelectionEndMarker() : SelectionStartMarker() }; const auto& otherMarker{ movingEnd ? SelectionStartMarker() : SelectionEndMarker() }; - if (selectionAnchor.Y < 0 || selectionAnchor.Y >= _core.ViewportSize().Height) + if (selectionAnchor.Y < 0 || selectionAnchor.Y >= _core->ViewportSize().Height) { // if the endpoint is outside of the viewport, // just hide the markers @@ -3695,7 +3665,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation winrt::Windows::Foundation::Point TermControl::_toPosInDips(const Core::Point terminalCellPos) { const auto marginsInDips{ GetPadding() }; - const auto fontSize{ _core.FontSizeInDips() }; + const auto fontSize{ _core->FontSizeInDips() }; return { terminalCellPos.X * fontSize.Width + static_cast(marginsInDips.Left), terminalCellPos.Y * fontSize.Height + static_cast(marginsInDips.Top), @@ -3798,11 +3768,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation hstring TermControl::ReadEntireBuffer() const { - return _core.ReadEntireBuffer(); + return _core->ReadEntireBuffer(); } Control::CommandHistoryContext TermControl::CommandHistory() const { - return _core.CommandHistory(); + return _core->CommandHistory(); } void TermControl::UpdateWinGetSuggestions(Windows::Foundation::Collections::IVector suggestions) @@ -3812,7 +3782,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation void TermControl::AdjustOpacity(const float opacity, const bool relative) { - _core.AdjustOpacity(opacity, relative); + _core->AdjustOpacity(opacity, relative); } // - You'd think this should just be "Opacity", but UIElement already @@ -3821,20 +3791,20 @@ namespace winrt::Microsoft::Terminal::Control::implementation // set by the settings should call this instead. float TermControl::BackgroundOpacity() const { - return _core.Opacity(); + return _core->Opacity(); } bool TermControl::HasSelection() const { - return _core.HasSelection(); + return _core->HasSelection(); } bool TermControl::HasMultiLineSelection() const { - return _core.HasMultiLineSelection(); + return _core->HasMultiLineSelection(); } winrt::hstring TermControl::SelectedText(bool trimTrailingWhitespace) const { - return _core.SelectedText(trimTrailingWhitespace); + return _core->SelectedText(trimTrailingWhitespace); } void TermControl::_refreshSearch() @@ -3853,7 +3823,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation const auto goForward = _searchBox->GoForward(); const auto caseSensitive = _searchBox->CaseSensitive(); const auto regularExpression = _searchBox->RegularExpression(); - _handleSearchResults(_core.Search(SearchRequest{ + _handleSearchResults(_core->Search(SearchRequest{ .Text = text, .GoForward = goForward, .CaseSensitive = caseSensitive, @@ -3917,12 +3887,12 @@ namespace winrt::Microsoft::Terminal::Control::implementation void TermControl::OwningHwnd(uint64_t owner) { - _core.OwningHwnd(owner); + _core->OwningHwnd(owner); } uint64_t TermControl::OwningHwnd() { - return _core.OwningHwnd(); + return _core->OwningHwnd(); } void TermControl::PreviewInput(const winrt::hstring& text) @@ -3944,36 +3914,36 @@ namespace winrt::Microsoft::Terminal::Control::implementation void TermControl::AddMark(const Control::ScrollMark& mark) { - _core.AddMark(mark); + _core->AddMark(mark); } - void TermControl::ClearMark() { _core.ClearMark(); } - void TermControl::ClearAllMarks() { _core.ClearAllMarks(); } - void TermControl::ScrollToMark(const Control::ScrollToMarkDirection& direction) { _core.ScrollToMark(direction); } + void TermControl::ClearMark() { _core->ClearMark(); } + void TermControl::ClearAllMarks() { _core->ClearAllMarks(); } + void TermControl::ScrollToMark(const Control::ScrollToMarkDirection& direction) { _core->ScrollToMark(direction); } Windows::Foundation::Collections::IVector TermControl::ScrollMarks() const { - return _core.ScrollMarks(); + return _core->ScrollMarks(); } void TermControl::SelectCommand(const bool goUp) { - _core.SelectCommand(goUp); + _core->SelectCommand(goUp); } void TermControl::SelectOutput(const bool goUp) { - _core.SelectOutput(goUp); + _core->SelectOutput(goUp); } void TermControl::ColorSelection(Control::SelectionColor fg, Control::SelectionColor bg, Core::MatchMode matchMode) { - _core.ColorSelection(fg, bg, matchMode); + _core->ColorSelection(fg, bg, matchMode); } // Returns the text cursor's position relative to our origin, in DIPs. Windows::Foundation::Point TermControl::CursorPositionInDips() { - const auto cursorPos{ _core.CursorPosition() }; + const auto cursorPos{ _core->CursorPosition() }; // CharacterDimensions returns a font size in pixels. const auto fontSize{ CharacterDimensions() }; @@ -4010,24 +3980,24 @@ namespace winrt::Microsoft::Terminal::Control::implementation // The "Select command" and "Select output" buttons should only be // visible if shell integration is actually turned on. - const auto shouldShowSelectCommand{ _core.ShouldShowSelectCommand() }; - const auto shouldShowSelectOutput{ _core.ShouldShowSelectOutput() }; + const auto shouldShowSelectCommand{ _core->ShouldShowSelectCommand() }; + const auto shouldShowSelectOutput{ _core->ShouldShowSelectOutput() }; SelectCommandButton().Visibility(shouldShowSelectCommand ? Visibility::Visible : Visibility::Collapsed); SelectOutputButton().Visibility(shouldShowSelectOutput ? Visibility::Visible : Visibility::Collapsed); SelectCommandWithSelectionButton().Visibility(shouldShowSelectCommand ? Visibility::Visible : Visibility::Collapsed); SelectOutputWithSelectionButton().Visibility(shouldShowSelectOutput ? Visibility::Visible : Visibility::Collapsed); - (_core.HasSelection() ? SelectionContextMenu() : - ContextMenu()) + (_core->HasSelection() ? SelectionContextMenu() : + ContextMenu()) .ShowAt(*this, myOption); } void TermControl::ShowContextMenu() { - const bool hasSelection = _core.HasSelection(); + const bool hasSelection = _core->HasSelection(); til::point cursorPos{ - hasSelection ? _core.SelectionInfo().EndPos : - _core.CursorPosition() + hasSelection ? _core->SelectionInfo().EndPos : + _core->CursorPosition() }; // Offset this position a bit: // * {+0,+1} if there's a selection. The selection endpoint is already @@ -4062,7 +4032,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation { if constexpr (Feature_QuickFix::IsEnabled()) { - if (_core.QuickFixesAvailable()) + if (_core->QuickFixesAvailable()) { // Expand the quick fix button if it's collapsed (looks nicer) if (_quickFixButtonCollapsible) @@ -4085,7 +4055,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation } auto quickFixBtn = QuickFixButton(); - if (!_core.QuickFixesAvailable()) + if (!_core->QuickFixesAvailable()) { quickFixBtn.Visibility(Visibility::Collapsed); return; @@ -4152,7 +4122,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation if (_searchBox) { const auto displayInfo = DisplayInformation::GetForCurrentView(); - const auto scaleFactor = _core.FontSize().Height / displayInfo.RawPixelsPerViewPixel(); + const auto scaleFactor = _core->FontSize().Height / displayInfo.RawPixelsPerViewPixel(); const auto searchBoxRows = _searchBox->ActualHeight() / scaleFactor; result = static_cast(std::ceil(searchBoxRows)); } @@ -4161,13 +4131,13 @@ namespace winrt::Microsoft::Terminal::Control::implementation void TermControl::ClearQuickFix() { - _core.ClearQuickFix(); + _core->ClearQuickFix(); } void TermControl::_PasteCommandHandler(const IInspectable& /*sender*/, const IInspectable& /*args*/) { - _interactivity.RequestPasteTextFromClipboard(); + _interactivity->RequestPasteTextFromClipboard(); ContextMenu().Hide(); SelectionContextMenu().Hide(); } @@ -4175,7 +4145,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation const IInspectable& /*args*/) { // formats = nullptr -> copy all formats - _interactivity.CopySelectionToClipboard(false, false, _core.Settings().CopyFormatting()); + _interactivity->CopySelectionToClipboard(false, false, _core->Settings().CopyFormatting()); ContextMenu().Hide(); SelectionContextMenu().Hide(); } @@ -4195,7 +4165,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation { ContextMenu().Hide(); SelectionContextMenu().Hide(); - _core.ContextMenuSelectCommand(); + _core->ContextMenuSelectCommand(); } void TermControl::_SelectOutputHandler(const IInspectable& /*sender*/, @@ -4203,7 +4173,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation { ContextMenu().Hide(); SelectionContextMenu().Hide(); - _core.ContextMenuSelectOutput(); + _core->ContextMenuSelectOutput(); } Control::CursorDisplayState TermControl::CursorVisibility() const noexcept @@ -4220,7 +4190,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation // allowing us to truly say "yeah these two controls both have focus". if (_core) { - _core.ForceCursorVisible(cursorVisibility == CursorDisplayState::Shown); + _core->ForceCursorVisible(cursorVisibility == CursorDisplayState::Shown); } } } diff --git a/src/cascadia/TerminalControl/TermControl.h b/src/cascadia/TerminalControl/TermControl.h index 9da026e542..6ea24c73e8 100644 --- a/src/cascadia/TerminalControl/TermControl.h +++ b/src/cascadia/TerminalControl/TermControl.h @@ -10,8 +10,6 @@ #include "../../renderer/uia/UiaRenderer.hpp" #include "../../tsf/Handle.h" -#include "ControlInteractivity.h" - namespace Microsoft::Console::VirtualTerminal { struct MouseButtonState; @@ -19,7 +17,10 @@ namespace Microsoft::Console::VirtualTerminal namespace winrt::Microsoft::Terminal::Control::implementation { + struct ControlCore; + struct ControlInteractivity; struct TermControl; + struct TermControlAutomationPeer; struct TsfDataProvider : ::Microsoft::Console::TSF::IDataProvider { @@ -195,9 +196,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation Control::CursorDisplayState CursorVisibility() const noexcept; void CursorVisibility(Control::CursorDisplayState cursorVisibility); - void ApplyPreviewColorScheme(const Core::ICoreScheme& scheme) { _core.ApplyPreviewColorScheme(scheme); } - void ResetPreviewColorScheme() { _core.ResetPreviewColorScheme(); } - void SetOverrideColorScheme(const Core::ICoreScheme& scheme) { _core.SetOverrideColorScheme(scheme); } + void ApplyPreviewColorScheme(const Core::ICoreScheme& scheme) { _core->ApplyPreviewColorScheme(scheme); } + void ResetPreviewColorScheme() { _core->ResetPreviewColorScheme(); } + void SetOverrideColorScheme(const Core::ICoreScheme& scheme) { _core->SetOverrideColorScheme(scheme); } // -------------------------------- WinRT Events --------------------------------- // clang-format off @@ -238,6 +239,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation private: friend struct TermControlT; // friend our parent so it can bind private event handlers + friend struct TermControlAutomationPeer; friend struct TsfDataProvider; // NOTE: _uiaEngine must be ordered before _core. @@ -248,9 +250,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation // IRenderEngine is accessed when ControlCore calls Renderer::TriggerTeardown. // (C++ class members are destroyed in reverse order.) // Further, the TermControlAutomationPeer must be destructed after _uiaEngine! - Control::TermControlAutomationPeer _automationPeer{ nullptr }; - Control::ControlInteractivity _interactivity{ nullptr }; - Control::ControlCore _core{ nullptr }; + winrt::com_ptr _automationPeer{ nullptr }; + winrt::com_ptr _interactivity{ nullptr }; + winrt::com_ptr _core{ nullptr }; Control::IKeyBindings _keyBindings{ nullptr }; TsfDataProvider _tsfDataProvider{ this }; winrt::com_ptr _searchBox; diff --git a/src/cascadia/TerminalControl/TermControlAutomationPeer.cpp b/src/cascadia/TerminalControl/TermControlAutomationPeer.cpp index 4ed8fc524f..29ed74e82e 100644 --- a/src/cascadia/TerminalControl/TermControlAutomationPeer.cpp +++ b/src/cascadia/TerminalControl/TermControlAutomationPeer.cpp @@ -67,44 +67,14 @@ static constexpr bool IsReadable(std::wstring_view text) namespace winrt::Microsoft::Terminal::Control::implementation { TermControlAutomationPeer::TermControlAutomationPeer(winrt::com_ptr owner, - const Core::Padding padding, - Control::InteractivityAutomationPeer impl) : + const Core::Padding padding) : TermControlAutomationPeerT(*owner.get()), // pass owner to FrameworkElementAutomationPeer - _termControl{ owner }, - _contentAutomationPeer{ impl } + _termControl{ owner } { - UpdateControlBounds(); + THROW_IF_FAILED(::Microsoft::WRL::MakeAndInitialize<::Microsoft::Terminal::TermControlUiaProvider>(&_uiaProvider, owner->_core->GetRenderData(), this)); SetControlPadding(padding); - // Listen for UIA signalling events from the implementation. We need to - // be the one to actually raise these automation events, so they go - // through the UI tree correctly. - _contentAutomationPeer.SelectionChanged([this](auto&&, auto&&) { SignalSelectionChanged(); }); - _contentAutomationPeer.TextChanged([this](auto&&, auto&&) { SignalTextChanged(); }); - _contentAutomationPeer.CursorChanged([this](auto&&, auto&&) { SignalCursorChanged(); }); - _contentAutomationPeer.NewOutput([this](auto&&, hstring newOutput) { NotifyNewOutput(newOutput); }); - _contentAutomationPeer.ParentProvider(*this); }; - // Method Description: - // - Inform the interactivity layer about the bounds of the control. - // IControlAccessibilityInfo needs to know this information, but it cannot - // ask us directly. - // Arguments: - // - - // Return Value: - // - - void TermControlAutomationPeer::UpdateControlBounds() - { - // FrameworkElementAutomationPeer has this great GetBoundingRectangle - // method that's seemingly impossible to recreate just from the - // UserControl itself. Weird. But we can use it handily here! - _contentAutomationPeer.SetControlBounds(GetBoundingRectangle()); - } - void TermControlAutomationPeer::SetControlPadding(const Core::Padding padding) - { - _contentAutomationPeer.SetControlPadding(padding); - } - void TermControlAutomationPeer::RecordKeyEvent(const WORD vkey) { if (const auto charCode{ MapVirtualKey(vkey, MAPVK_VK_TO_CHAR) }) @@ -121,9 +91,6 @@ namespace winrt::Microsoft::Terminal::Control::implementation // GH#13978: If the TermControl has already been removed from the UI tree, XAML might run into weird bugs. // This will prevent the `dispatcher.RunAsync` calls below from raising UIA events on the main thread. _termControl = {}; - - // Solve the circular reference between us and the content automation peer. - _contentAutomationPeer.ParentProvider(nullptr); } // Method Description: @@ -341,33 +308,124 @@ namespace winrt::Microsoft::Terminal::Control::implementation #pragma region ITextProvider com_array TermControlAutomationPeer::GetSelection() { - return _contentAutomationPeer.GetSelection(); + SAFEARRAY* pReturnVal; + THROW_IF_FAILED(_uiaProvider->GetSelection(&pReturnVal)); + return WrapArrayOfTextRangeProviders(pReturnVal); } com_array TermControlAutomationPeer::GetVisibleRanges() { - return _contentAutomationPeer.GetVisibleRanges(); + SAFEARRAY* pReturnVal; + THROW_IF_FAILED(_uiaProvider->GetVisibleRanges(&pReturnVal)); + return WrapArrayOfTextRangeProviders(pReturnVal); } - XamlAutomation::ITextRangeProvider TermControlAutomationPeer::RangeFromChild(XamlAutomation::IRawElementProviderSimple childElement) + XamlAutomation::ITextRangeProvider TermControlAutomationPeer::RangeFromChild(XamlAutomation::IRawElementProviderSimple /*childElement*/) { - return _contentAutomationPeer.RangeFromChild(childElement); + UIA::ITextRangeProvider* returnVal; + // ScreenInfoUiaProvider doesn't actually use parameter, so just pass in nullptr + THROW_IF_FAILED(_uiaProvider->RangeFromChild(/* IRawElementProviderSimple */ nullptr, + &returnVal)); + return _CreateXamlUiaTextRange(returnVal); } XamlAutomation::ITextRangeProvider TermControlAutomationPeer::RangeFromPoint(Windows::Foundation::Point screenLocation) { - return _contentAutomationPeer.RangeFromPoint(screenLocation); + UIA::ITextRangeProvider* returnVal; + THROW_IF_FAILED(_uiaProvider->RangeFromPoint({ screenLocation.X, screenLocation.Y }, &returnVal)); + return _CreateXamlUiaTextRange(returnVal); } XamlAutomation::ITextRangeProvider TermControlAutomationPeer::DocumentRange() { - return _contentAutomationPeer.DocumentRange(); + UIA::ITextRangeProvider* returnVal; + THROW_IF_FAILED(_uiaProvider->get_DocumentRange(&returnVal)); + return _CreateXamlUiaTextRange(returnVal); } XamlAutomation::SupportedTextSelection TermControlAutomationPeer::SupportedTextSelection() { - return _contentAutomationPeer.SupportedTextSelection(); + UIA::SupportedTextSelection returnVal; + THROW_IF_FAILED(_uiaProvider->get_SupportedTextSelection(&returnVal)); + return static_cast(returnVal); } #pragma endregion + +#pragma region IControlAccessibilityInfo + til::size TermControlAutomationPeer::GetFontSize() const noexcept + { + if (const auto control{ _termControl.get() }) + { + return { til::math::rounding, control->_core->FontSize() }; + } + return {}; + } + + til::rect TermControlAutomationPeer::GetBounds() const noexcept + { + return { til::math::rounding, GetBoundingRectangle() }; + } + + HRESULT TermControlAutomationPeer::GetHostUiaProvider(IRawElementProviderSimple** provider) + { + RETURN_HR_IF(E_INVALIDARG, provider == nullptr); + *provider = nullptr; + + return S_OK; + } + + til::rect TermControlAutomationPeer::GetPadding() const noexcept + { + if (const auto control{ _termControl.get() }) + { + const auto padding{ control->GetPadding() }; + return { + static_cast(padding.Left), + static_cast(padding.Top), + static_cast(padding.Right), + static_cast(padding.Bottom), + }; + } + return {}; + } + + void TermControlAutomationPeer::ChangeViewport(const til::inclusive_rect& NewWindow) + { + if (const auto control{ _termControl.get() }) + { + control->_interactivity->UpdateScrollbar(static_cast(NewWindow.top)); + } + } +#pragma endregion + + XamlAutomation::ITextRangeProvider TermControlAutomationPeer::_CreateXamlUiaTextRange(UIA::ITextRangeProvider* returnVal) const + { + const auto xutr = winrt::make_self(returnVal, *this); + return xutr.as(); + }; + + // Method Description: + // - extracts the UiaTextRanges from the SAFEARRAY and converts them to Xaml ITextRangeProviders + // Arguments: + // - SAFEARRAY of UIA::UiaTextRange (ITextRangeProviders) + // Return Value: + // - com_array of Xaml Wrapped UiaTextRange (ITextRangeProviders) + com_array TermControlAutomationPeer::WrapArrayOfTextRangeProviders(SAFEARRAY* textRanges) + { + // transfer ownership of UiaTextRanges to this new vector + auto providers = SafeArrayToOwningVector<::Microsoft::Terminal::TermControlUiaTextRange>(textRanges); + const auto len = gsl::narrow(providers.size()); + com_array result{ len }; + + for (uint32_t i = 0; i < len; ++i) + { + if (auto xutr = _CreateXamlUiaTextRange(providers[i].detach())) + { + result[i] = std::move(xutr); + } + } + + return result; + } } diff --git a/src/cascadia/TerminalControl/TermControlAutomationPeer.h b/src/cascadia/TerminalControl/TermControlAutomationPeer.h index 3d65b756d5..297ecb45db 100644 --- a/src/cascadia/TerminalControl/TermControlAutomationPeer.h +++ b/src/cascadia/TerminalControl/TermControlAutomationPeer.h @@ -20,10 +20,6 @@ Abstract: Author(s): - Carlos Zamora (CaZamor) 2019 - -Modifications: -- May 2021: Pulled the core logic of ITextProvider implementation into the - InteractivityAutomationPeer, to support tab tear out. --*/ #pragma once @@ -40,14 +36,13 @@ namespace winrt::Microsoft::Terminal::Control::implementation struct TermControlAutomationPeer : public TermControlAutomationPeerT, - ::Microsoft::Console::Types::IUiaEventDispatcher + ::Microsoft::Console::Types::IUiaEventDispatcher, + ::Microsoft::Console::Types::IControlAccessibilityInfo { public: TermControlAutomationPeer(winrt::com_ptr owner, - const Core::Padding padding, - Control::InteractivityAutomationPeer implementation); + const Core::Padding padding); - void UpdateControlBounds(); void SetControlPadding(const Core::Padding padding); void RecordKeyEvent(const WORD vkey); void Close(); @@ -79,9 +74,23 @@ namespace winrt::Microsoft::Terminal::Control::implementation Windows::UI::Xaml::Automation::Provider::ITextRangeProvider DocumentRange(); #pragma endregion +#pragma region IControlAccessibilityInfo Pattern + // Inherited via IControlAccessibilityInfo + virtual til::size GetFontSize() const noexcept override; + virtual til::rect GetBounds() const noexcept override; + virtual til::rect GetPadding() const noexcept override; + virtual void ChangeViewport(const til::inclusive_rect& NewWindow) override; + virtual HRESULT GetHostUiaProvider(IRawElementProviderSimple** provider) override; +#pragma endregion + private: + Windows::UI::Xaml::Automation::Provider::ITextRangeProvider _CreateXamlUiaTextRange(::ITextRangeProvider* returnVal) const; + winrt::com_array WrapArrayOfTextRangeProviders(SAFEARRAY* textRanges); + winrt::weak_ref _termControl; - Control::InteractivityAutomationPeer _contentAutomationPeer; + ::Microsoft::WRL::ComPtr<::Microsoft::Terminal::TermControlUiaProvider> _uiaProvider; + + til::rect _controlPadding{}; til::shared_mutex> _keyEvents; }; } diff --git a/src/cascadia/TerminalControl/TerminalControlLib.vcxproj b/src/cascadia/TerminalControl/TerminalControlLib.vcxproj index 90d053424f..13986e400e 100644 --- a/src/cascadia/TerminalControl/TerminalControlLib.vcxproj +++ b/src/cascadia/TerminalControl/TerminalControlLib.vcxproj @@ -57,9 +57,6 @@ TermControlAutomationPeer.idl - - InteractivityAutomationPeer.idl - @@ -98,9 +95,6 @@ TermControlAutomationPeer.idl - - InteractivityAutomationPeer.idl - @@ -124,7 +118,6 @@ TermControl.xaml - @@ -183,4 +176,4 @@ - \ No newline at end of file + diff --git a/src/cascadia/TerminalSettingsModel/IInheritable.h b/src/cascadia/TerminalSettingsModel/IInheritable.h index aae47f61db..f25e3e81bb 100644 --- a/src/cascadia/TerminalSettingsModel/IInheritable.h +++ b/src/cascadia/TerminalSettingsModel/IInheritable.h @@ -136,7 +136,7 @@ private: \ return std::nullopt; \ } \ \ - auto _get##name##OverrideSourceImpl()->decltype(get_strong()) \ + auto _get##name##OverrideSourceImpl() -> decltype(get_strong()) \ { \ /*we have a value*/ \ if (_##name) \ @@ -159,7 +159,7 @@ private: \ } \ \ auto _get##name##OverrideSourceAndValueImpl() \ - ->std::pair \ + -> std::pair \ { \ /*we have a value*/ \ if (_##name) \ From eb9d6113eb2e3649ca3619aac67f9d05a4b05add Mon Sep 17 00:00:00 2001 From: "Dustin L. Howett" Date: Thu, 24 Sep 2026 18:32:42 -0500 Subject: [PATCH 2/8] Undo the HANDLE<->uint64 stuff from 7f3bc3cb047b66644ab --- src/cascadia/TerminalControl/ControlCore.cpp | 6 +++--- src/cascadia/TerminalControl/ControlCore.h | 2 +- src/cascadia/TerminalControl/ControlCore.idl | 2 -- src/cascadia/TerminalControl/TermControl.cpp | 7 +++---- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/cascadia/TerminalControl/ControlCore.cpp b/src/cascadia/TerminalControl/ControlCore.cpp index 534752b729..5211922f88 100644 --- a/src/cascadia/TerminalControl/ControlCore.cpp +++ b/src/cascadia/TerminalControl/ControlCore.cpp @@ -2025,7 +2025,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation _lastSwapChainHandle = std::move(duplicatedHandle); // Now bubble the event up to the control. - SwapChainChanged.raise(*this, winrt::box_value(reinterpret_cast(_lastSwapChainHandle.get()))); + SwapChainChanged.raise(*this, nullptr); } } @@ -2322,13 +2322,13 @@ namespace winrt::Microsoft::Terminal::Control::implementation return _renderer.get(); } - uint64_t ControlCore::SwapChainHandle() const + HANDLE ControlCore::SwapChainHandle() const { // This is only ever called by TermControl::AttachContent, which occurs // when we're taking an existing core and moving it to a new control. // Otherwise, we only ever use the value from the SwapChainChanged // event. - return reinterpret_cast(_lastSwapChainHandle.get()); + return _lastSwapChainHandle.get(); } // Method Description: diff --git a/src/cascadia/TerminalControl/ControlCore.h b/src/cascadia/TerminalControl/ControlCore.h index d3bfc00488..6cc75ee889 100644 --- a/src/cascadia/TerminalControl/ControlCore.h +++ b/src/cascadia/TerminalControl/ControlCore.h @@ -105,7 +105,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation void SetOverrideColorScheme(const Core::ICoreScheme&); ::Microsoft::Console::Render::Renderer* GetRenderer() const noexcept; - uint64_t SwapChainHandle() const; + HANDLE SwapChainHandle() const; void AttachToNewControl(); void SizeChanged(const float width, const float height); diff --git a/src/cascadia/TerminalControl/ControlCore.idl b/src/cascadia/TerminalControl/ControlCore.idl index d0ecdb7895..5584eba0d9 100644 --- a/src/cascadia/TerminalControl/ControlCore.idl +++ b/src/cascadia/TerminalControl/ControlCore.idl @@ -111,8 +111,6 @@ namespace Microsoft.Terminal.Control void SetOverrideColorScheme(Microsoft.Terminal.Core.ICoreScheme scheme); - UInt64 SwapChainHandle { get; }; - Windows.Foundation.Size FontSize { get; }; Windows.Foundation.Size FontSizeInDips { get; }; UInt16 FontWeight { get; }; diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index cba99200aa..bffc4de7f7 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -507,7 +507,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation void TermControl::_initializeForAttach() { - _AttachDxgiSwapChainToXaml(reinterpret_cast(_core->SwapChainHandle())); + _AttachDxgiSwapChainToXaml(_core->SwapChainHandle()); _interactivity->AttachToNewControl(); // Initialize the terminal only once the swapchainpanel is loaded - that @@ -1287,11 +1287,10 @@ namespace winrt::Microsoft::Terminal::Control::implementation return _core->ConnectionState(); } - void TermControl::RenderEngineSwapChainChanged(IInspectable /*sender*/, IInspectable args) + void TermControl::RenderEngineSwapChainChanged(IInspectable /*sender*/, IInspectable /*args*/) { // This event comes in on the UI thread - HANDLE h = reinterpret_cast(winrt::unbox_value(args)); - _AttachDxgiSwapChainToXaml(h); + _AttachDxgiSwapChainToXaml(_core->SwapChainHandle()); } // Method Description: From 3effb10aee11f0b7d0bed6df36eabba6fedeb04a Mon Sep 17 00:00:00 2001 From: "Dustin L. Howett" Date: Fri, 25 Sep 2026 13:34:09 -0500 Subject: [PATCH 3/8] Fixes, plus remove TermControlAutoPeer from idl --- src/cascadia/TerminalControl/TermControl.cpp | 15 +++++++++++++++ src/cascadia/TerminalControl/TermControl.h | 6 +++--- .../TermControlAutomationPeer.cpp | 15 ++++++++------- .../TerminalControl/TermControlAutomationPeer.h | 4 ++-- .../TermControlAutomationPeer.idl | 16 ---------------- .../TerminalControl/TerminalControlLib.vcxproj | 9 ++------- src/cascadia/TerminalControl/pch.h | 1 + 7 files changed, 31 insertions(+), 35 deletions(-) delete mode 100644 src/cascadia/TerminalControl/TermControlAutomationPeer.idl diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index bffc4de7f7..badb93008d 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -4180,6 +4180,21 @@ namespace winrt::Microsoft::Terminal::Control::implementation return _cursorVisibility; } + void TermControl::ApplyPreviewColorScheme(const Core::ICoreScheme& scheme) + { + _core->ApplyPreviewColorScheme(scheme); + } + + void TermControl::ResetPreviewColorScheme() + { + _core->ResetPreviewColorScheme(); + } + + void TermControl::SetOverrideColorScheme(const Core::ICoreScheme& scheme) + { + _core->SetOverrideColorScheme(scheme); + } + void TermControl::CursorVisibility(Control::CursorDisplayState cursorVisibility) { _cursorVisibility = cursorVisibility; diff --git a/src/cascadia/TerminalControl/TermControl.h b/src/cascadia/TerminalControl/TermControl.h index 6ea24c73e8..6489110312 100644 --- a/src/cascadia/TerminalControl/TermControl.h +++ b/src/cascadia/TerminalControl/TermControl.h @@ -196,9 +196,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation Control::CursorDisplayState CursorVisibility() const noexcept; void CursorVisibility(Control::CursorDisplayState cursorVisibility); - void ApplyPreviewColorScheme(const Core::ICoreScheme& scheme) { _core->ApplyPreviewColorScheme(scheme); } - void ResetPreviewColorScheme() { _core->ResetPreviewColorScheme(); } - void SetOverrideColorScheme(const Core::ICoreScheme& scheme) { _core->SetOverrideColorScheme(scheme); } + void ApplyPreviewColorScheme(const Core::ICoreScheme& scheme); + void ResetPreviewColorScheme(); + void SetOverrideColorScheme(const Core::ICoreScheme& scheme); // -------------------------------- WinRT Events --------------------------------- // clang-format off diff --git a/src/cascadia/TerminalControl/TermControlAutomationPeer.cpp b/src/cascadia/TerminalControl/TermControlAutomationPeer.cpp index 29ed74e82e..1a6f6f0576 100644 --- a/src/cascadia/TerminalControl/TermControlAutomationPeer.cpp +++ b/src/cascadia/TerminalControl/TermControlAutomationPeer.cpp @@ -5,7 +5,6 @@ #include #include "TermControlAutomationPeer.h" #include "TermControl.h" -#include "TermControlAutomationPeer.g.cpp" #include "XamlUiaTextRange.h" #include "../types/UiaTracing.h" @@ -68,7 +67,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation { TermControlAutomationPeer::TermControlAutomationPeer(winrt::com_ptr owner, const Core::Padding padding) : - TermControlAutomationPeerT(*owner.get()), // pass owner to FrameworkElementAutomationPeer + FrameworkElementAutomationPeerT(*owner.get()), // pass owner to FrameworkElementAutomationPeer _termControl{ owner } { THROW_IF_FAILED(::Microsoft::WRL::MakeAndInitialize<::Microsoft::Terminal::TermControlUiaProvider>(&_uiaProvider, owner->_core->GetRenderData(), this)); @@ -381,10 +380,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation { const auto padding{ control->GetPadding() }; return { - static_cast(padding.Left), - static_cast(padding.Top), - static_cast(padding.Right), - static_cast(padding.Bottom), + til::math::rounding, + padding.Left, + padding.Top, + padding.Right, + padding.Bottom, }; } return {}; @@ -401,7 +401,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation XamlAutomation::ITextRangeProvider TermControlAutomationPeer::_CreateXamlUiaTextRange(UIA::ITextRangeProvider* returnVal) const { - const auto xutr = winrt::make_self(returnVal, *this); + const auto provider = ProviderFromPeer(*this); + const auto xutr = winrt::make_self(returnVal, provider); return xutr.as(); }; diff --git a/src/cascadia/TerminalControl/TermControlAutomationPeer.h b/src/cascadia/TerminalControl/TermControlAutomationPeer.h index 297ecb45db..4e89643839 100644 --- a/src/cascadia/TerminalControl/TermControlAutomationPeer.h +++ b/src/cascadia/TerminalControl/TermControlAutomationPeer.h @@ -25,7 +25,6 @@ Author(s): #pragma once #include "ControlInteractivity.h" -#include "TermControlAutomationPeer.g.h" #include "../types/TermControlUiaProvider.hpp" #include "../types/IUiaEventDispatcher.h" #include "../types/IControlAccessibilityInfo.h" @@ -35,7 +34,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation struct TermControl; struct TermControlAutomationPeer : - public TermControlAutomationPeerT, + public winrt::Windows::UI::Xaml::Automation::Peers::FrameworkElementAutomationPeerT, ::Microsoft::Console::Types::IUiaEventDispatcher, ::Microsoft::Console::Types::IControlAccessibilityInfo { diff --git a/src/cascadia/TerminalControl/TermControlAutomationPeer.idl b/src/cascadia/TerminalControl/TermControlAutomationPeer.idl deleted file mode 100644 index 4ca83f0d9c..0000000000 --- a/src/cascadia/TerminalControl/TermControlAutomationPeer.idl +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import "TermControl.idl"; - -namespace Microsoft.Terminal.Control -{ - [default_interface] runtimeclass TermControlAutomationPeer : - Windows.UI.Xaml.Automation.Peers.FrameworkElementAutomationPeer, - Windows.UI.Xaml.Automation.Provider.ITextProvider - { - - void UpdateControlBounds(); - void SetControlPadding(Microsoft.Terminal.Core.Padding padding); - } -} diff --git a/src/cascadia/TerminalControl/TerminalControlLib.vcxproj b/src/cascadia/TerminalControl/TerminalControlLib.vcxproj index 13986e400e..70d8865817 100644 --- a/src/cascadia/TerminalControl/TerminalControlLib.vcxproj +++ b/src/cascadia/TerminalControl/TerminalControlLib.vcxproj @@ -54,9 +54,7 @@ TermControl.xaml - - TermControlAutomationPeer.idl - + @@ -92,9 +90,7 @@ TermControl.xaml - - TermControlAutomationPeer.idl - + @@ -117,7 +113,6 @@ TermControl.xaml - diff --git a/src/cascadia/TerminalControl/pch.h b/src/cascadia/TerminalControl/pch.h index 5baf84a359..2aeaa47e4f 100644 --- a/src/cascadia/TerminalControl/pch.h +++ b/src/cascadia/TerminalControl/pch.h @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include From 9ad9c0b6ba3c56c6a8b8a6d3c6eba47db38a8b8c Mon Sep 17 00:00:00 2001 From: "Dustin L. Howett" Date: Fri, 25 Sep 2026 13:48:56 -0500 Subject: [PATCH 4/8] everything but the event handlers --- src/cascadia/TerminalControl/TermControl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index badb93008d..6a43365d6e 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -276,7 +276,6 @@ namespace winrt::Microsoft::Terminal::Control::implementation } TermControl::TermControl(Control::ControlInteractivity content) : - _interactivity{ content }, _isInternalScrollBarUpdate{ false }, _autoScrollVelocity{ 0 }, _autoScrollingPointerPoint{ std::nullopt }, @@ -285,7 +284,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation { InitializeComponent(); - _core = _interactivity->Core(); + _interactivity.copy_from(winrt::get_self(content)); + _core.copy_from(winrt::get_self(_interactivity->Core())); // If high contrast mode was changed, update the appearance appropriately. _core->SetHighContrastMode(_GetAccessibilitySettings().HighContrast()); From e18bff7d37c5923ae2509b46fdbd659042884a01 Mon Sep 17 00:00:00 2001 From: "Dustin L. Howett" Date: Fri, 25 Sep 2026 13:55:01 -0500 Subject: [PATCH 5/8] remove all get_self on com_ptr types --- src/cascadia/TerminalControl/TermControl.cpp | 25 +++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index 6a43365d6e..25ecd07465 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -259,7 +259,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation ControlCore* TsfDataProvider::_getCore() const noexcept { - return get_self(_termControl->_core); + return _termControl->_core.get(); } static Windows::UI::ViewManagement::AccessibilitySettings& _GetAccessibilitySettings() @@ -653,9 +653,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation if (_searchBox && _searchBox->IsOpen()) { - const auto core = winrt::get_self(_core); - const auto& searchMatches = core->SearchResultRows(); - const auto color = core->ForegroundColor(); + const auto& searchMatches = _core->SearchResultRows(); + const auto color = _core->ForegroundColor(); const auto rightAlignedOffset = (scrollBarWidthInPx - pipWidth) * sizeof(til::color); til::CoordType lastRow = til::CoordTypeMin; @@ -1445,7 +1444,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation co_return; } - winrt::get_self(_core)->RestoreFromPath(path.c_str()); + _core->RestoreFromPath(path.c_str()); } CATCH_LOG(); @@ -1909,7 +1908,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation if (vkey && keyDown && _automationPeer) { - get_self(_automationPeer)->RecordKeyEvent(vkey); + _automationPeer->RecordKeyEvent(vkey); } return handled; @@ -2455,8 +2454,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation return; } - const auto coreImpl = winrt::get_self(_core); - const auto size = coreImpl->ViewportSize(); + const auto size = _core->ViewportSize(); // Sometimes _SwapChainSizeChanged is called despite no actual size change. // This happens, e.g., when switching tabs. Ignore such "updates". @@ -2663,7 +2661,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation // file then. if (_initializedTerminal) { - winrt::get_self(_core)->PersistTo(reinterpret_cast(handle)); + _core->PersistTo(reinterpret_cast(handle)); } } @@ -2679,8 +2677,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation _closing = true; if (_automationPeer) { - auto autoPeerImpl{ winrt::get_self(_automationPeer) }; - autoPeerImpl->Close(); + _automationPeer->Close(); } RestorePointerCursor.raise(*this, nullptr); @@ -3776,7 +3773,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation void TermControl::UpdateWinGetSuggestions(Windows::Foundation::Collections::IVector suggestions) { - get_self(_core)->UpdateQuickFixes(suggestions); + _core->UpdateQuickFixes(suggestions); } void TermControl::AdjustOpacity(const float opacity, const bool relative) @@ -3896,7 +3893,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation void TermControl::PreviewInput(const winrt::hstring& text) { - get_self(_core)->PreviewInput(text); + _core->PreviewInput(text); if (!text.empty()) { @@ -4069,7 +4066,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation PropertyChanged.raise(*this, Windows::UI::Xaml::Data::PropertyChangedEventArgs{ L"QuickFixButtonCollapsedWidth" }); VisualStateManager::GoToState(*this, !_quickFixButtonCollapsible ? StateNormal : StateCollapsed, false); - const auto rd = get_self(_core)->GetRenderData(); + const auto rd = _core->GetRenderData(); rd->LockConsole(); const auto viewportBufferPosition = rd->GetViewport(); rd->UnlockConsole(); From 01f4fc394e475a4739c3ac47a6db601edccd0208 Mon Sep 17 00:00:00 2001 From: "Dustin L. Howett" Date: Fri, 25 Sep 2026 14:11:59 -0500 Subject: [PATCH 6/8] begone padding --- src/cascadia/TerminalControl/TermControl.cpp | 9 +-------- .../TerminalControl/TermControlAutomationPeer.cpp | 4 +--- src/cascadia/TerminalControl/TermControlAutomationPeer.h | 4 +--- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index 25ecd07465..22d88297fb 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -1255,14 +1255,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation // create a custom automation peer with this code pattern: // (https://docs.microsoft.com/en-us/windows/uwp/design/accessibility/custom-automation-peers) - const auto margins{ SwapChainPanel().Margin() }; - const Core::Padding padding{ - static_cast(margins.Left), - static_cast(margins.Top), - static_cast(margins.Right), - static_cast(margins.Bottom), - }; - _automationPeer = winrt::make_self(get_strong(), padding); + _automationPeer = winrt::make_self(get_strong()); _interactivity->SetUiaEventDispatcher(_automationPeer.get()); return *_automationPeer; } diff --git a/src/cascadia/TerminalControl/TermControlAutomationPeer.cpp b/src/cascadia/TerminalControl/TermControlAutomationPeer.cpp index 1a6f6f0576..fc8e389f2f 100644 --- a/src/cascadia/TerminalControl/TermControlAutomationPeer.cpp +++ b/src/cascadia/TerminalControl/TermControlAutomationPeer.cpp @@ -65,13 +65,11 @@ static constexpr bool IsReadable(std::wstring_view text) namespace winrt::Microsoft::Terminal::Control::implementation { - TermControlAutomationPeer::TermControlAutomationPeer(winrt::com_ptr owner, - const Core::Padding padding) : + TermControlAutomationPeer::TermControlAutomationPeer(winrt::com_ptr owner) : FrameworkElementAutomationPeerT(*owner.get()), // pass owner to FrameworkElementAutomationPeer _termControl{ owner } { THROW_IF_FAILED(::Microsoft::WRL::MakeAndInitialize<::Microsoft::Terminal::TermControlUiaProvider>(&_uiaProvider, owner->_core->GetRenderData(), this)); - SetControlPadding(padding); }; void TermControlAutomationPeer::RecordKeyEvent(const WORD vkey) diff --git a/src/cascadia/TerminalControl/TermControlAutomationPeer.h b/src/cascadia/TerminalControl/TermControlAutomationPeer.h index 4e89643839..36c1335e63 100644 --- a/src/cascadia/TerminalControl/TermControlAutomationPeer.h +++ b/src/cascadia/TerminalControl/TermControlAutomationPeer.h @@ -40,10 +40,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation ::Microsoft::Console::Types::IControlAccessibilityInfo { public: - TermControlAutomationPeer(winrt::com_ptr owner, - const Core::Padding padding); + TermControlAutomationPeer(winrt::com_ptr owner); - void SetControlPadding(const Core::Padding padding); void RecordKeyEvent(const WORD vkey); void Close(); From 13a7acaa62406c9327772f19df0c6e6af77e0bf0 Mon Sep 17 00:00:00 2001 From: "Dustin L. Howett" Date: Fri, 25 Sep 2026 14:15:55 -0500 Subject: [PATCH 7/8] for now, hook event callbacks up to the projected side --- src/cascadia/TerminalControl/TermControl.cpp | 63 ++++++++++---------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index 22d88297fb..ec41c74ebc 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -285,7 +285,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation InitializeComponent(); _interactivity.copy_from(winrt::get_self(content)); - _core.copy_from(winrt::get_self(_interactivity->Core())); + auto projectedCore{ _interactivity->Core() }; + _core.copy_from(winrt::get_self(projectedCore)); // If high contrast mode was changed, update the appearance appropriately. _core->SetHighContrastMode(_GetAccessibilitySettings().HighContrast()); @@ -298,49 +299,49 @@ namespace winrt::Microsoft::Terminal::Control::implementation }); // This event is specifically triggered by the renderer thread, a BG thread. Use a weak ref here. - _revokers.RendererEnteredErrorState = _core->RendererEnteredErrorState(winrt::auto_revoke, { get_weak(), &TermControl::_RendererEnteredErrorState }); + _revokers.RendererEnteredErrorState = projectedCore.RendererEnteredErrorState(winrt::auto_revoke, { get_weak(), &TermControl::_RendererEnteredErrorState }); // IMPORTANT! Set this callback up sooner rather than later. If we do it // after Enable, then it'll be possible to paint the frame once // _before_ the warning handler is set up, and then warnings from // the first paint will be ignored! - _revokers.RendererWarning = _core->RendererWarning(winrt::auto_revoke, { get_weak(), &TermControl::_RendererWarning }); + _revokers.RendererWarning = projectedCore.RendererWarning(winrt::auto_revoke, { get_weak(), &TermControl::_RendererWarning }); // ALSO IMPORTANT: Make sure to set this callback up in the ctor, so // that we won't miss any swap chain changes. - _revokers.SwapChainChanged = _core->SwapChainChanged(winrt::auto_revoke, { get_weak(), &TermControl::RenderEngineSwapChainChanged }); + _revokers.SwapChainChanged = projectedCore.SwapChainChanged(winrt::auto_revoke, { get_weak(), &TermControl::RenderEngineSwapChainChanged }); // These callbacks can only really be triggered by UI interactions. So // they don't need weak refs - they can't be triggered unless we're // alive. - _revokers.BackgroundColorChanged = _core->BackgroundColorChanged(winrt::auto_revoke, { get_weak(), &TermControl::_coreBackgroundColorChanged }); - _revokers.FontSizeChanged = _core->FontSizeChanged(winrt::auto_revoke, { get_weak(), &TermControl::_coreFontSizeChanged }); - _revokers.TransparencyChanged = _core->TransparencyChanged(winrt::auto_revoke, { get_weak(), &TermControl::_coreTransparencyChanged }); - _revokers.RaiseNotice = _core->RaiseNotice(winrt::auto_revoke, { get_weak(), &TermControl::_coreRaisedNotice }); - _revokers.HoveredHyperlinkChanged = _core->HoveredHyperlinkChanged(winrt::auto_revoke, { get_weak(), &TermControl::_hoveredHyperlinkChanged }); - _revokers.OutputIdle = _core->OutputIdle(winrt::auto_revoke, { get_weak(), &TermControl::_coreOutputIdle }); - _revokers.UpdateSelectionMarkers = _core->UpdateSelectionMarkers(winrt::auto_revoke, { get_weak(), &TermControl::_updateSelectionMarkers }); - _revokers.coreOpenHyperlink = _core->OpenHyperlink(winrt::auto_revoke, { get_weak(), &TermControl::_HyperlinkHandler }); - _revokers.interactivityOpenHyperlink = _interactivity->OpenHyperlink(winrt::auto_revoke, { get_weak(), &TermControl::_HyperlinkHandler }); - _revokers.interactivityScrollPositionChanged = _interactivity->ScrollPositionChanged(winrt::auto_revoke, { get_weak(), &TermControl::_ScrollPositionChanged }); - _revokers.ContextMenuRequested = _interactivity->ContextMenuRequested(winrt::auto_revoke, { get_weak(), &TermControl::_contextMenuHandler }); + _revokers.BackgroundColorChanged = projectedCore.BackgroundColorChanged(winrt::auto_revoke, { get_weak(), &TermControl::_coreBackgroundColorChanged }); + _revokers.FontSizeChanged = projectedCore.FontSizeChanged(winrt::auto_revoke, { get_weak(), &TermControl::_coreFontSizeChanged }); + _revokers.TransparencyChanged = projectedCore.TransparencyChanged(winrt::auto_revoke, { get_weak(), &TermControl::_coreTransparencyChanged }); + _revokers.RaiseNotice = projectedCore.RaiseNotice(winrt::auto_revoke, { get_weak(), &TermControl::_coreRaisedNotice }); + _revokers.HoveredHyperlinkChanged = projectedCore.HoveredHyperlinkChanged(winrt::auto_revoke, { get_weak(), &TermControl::_hoveredHyperlinkChanged }); + _revokers.OutputIdle = projectedCore.OutputIdle(winrt::auto_revoke, { get_weak(), &TermControl::_coreOutputIdle }); + _revokers.UpdateSelectionMarkers = projectedCore.UpdateSelectionMarkers(winrt::auto_revoke, { get_weak(), &TermControl::_updateSelectionMarkers }); + _revokers.coreOpenHyperlink = projectedCore.OpenHyperlink(winrt::auto_revoke, { get_weak(), &TermControl::_HyperlinkHandler }); + _revokers.interactivityOpenHyperlink = content.OpenHyperlink(winrt::auto_revoke, { get_weak(), &TermControl::_HyperlinkHandler }); + _revokers.interactivityScrollPositionChanged = content.ScrollPositionChanged(winrt::auto_revoke, { get_weak(), &TermControl::_ScrollPositionChanged }); + _revokers.ContextMenuRequested = content.ContextMenuRequested(winrt::auto_revoke, { get_weak(), &TermControl::_contextMenuHandler }); // "Bubbled" events - ones we want to handle, by raising our own event. - _revokers.TitleChanged = _core->TitleChanged(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleTitleChanged }); - _revokers.TabColorChanged = _core->TabColorChanged(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleTabColorChanged }); - _revokers.TaskbarProgressChanged = _core->TaskbarProgressChanged(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleSetTaskbarProgress }); - _revokers.ConnectionStateChanged = _core->ConnectionStateChanged(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleConnectionStateChanged }); - _revokers.ShowWindowChanged = _core->ShowWindowChanged(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleShowWindowChanged }); - _revokers.CloseTerminalRequested = _core->CloseTerminalRequested(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleCloseTerminalRequested }); - _revokers.CompletionsChanged = _core->CompletionsChanged(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleCompletionsChanged }); - _revokers.RestartTerminalRequested = _core->RestartTerminalRequested(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleRestartTerminalRequested }); - _revokers.SearchMissingCommand = _core->SearchMissingCommand(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleSearchMissingCommand }); - _revokers.ShowNotification = _core->ShowNotification(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleShowNotification }); - _revokers.WindowSizeChanged = _core->WindowSizeChanged(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleWindowSizeChanged }); - _revokers.WriteToClipboard = _core->WriteToClipboard(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleWriteToClipboard }); + _revokers.TitleChanged = projectedCore.TitleChanged(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleTitleChanged }); + _revokers.TabColorChanged = projectedCore.TabColorChanged(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleTabColorChanged }); + _revokers.TaskbarProgressChanged = projectedCore.TaskbarProgressChanged(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleSetTaskbarProgress }); + _revokers.ConnectionStateChanged = projectedCore.ConnectionStateChanged(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleConnectionStateChanged }); + _revokers.ShowWindowChanged = projectedCore.ShowWindowChanged(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleShowWindowChanged }); + _revokers.CloseTerminalRequested = projectedCore.CloseTerminalRequested(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleCloseTerminalRequested }); + _revokers.CompletionsChanged = projectedCore.CompletionsChanged(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleCompletionsChanged }); + _revokers.RestartTerminalRequested = projectedCore.RestartTerminalRequested(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleRestartTerminalRequested }); + _revokers.SearchMissingCommand = projectedCore.SearchMissingCommand(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleSearchMissingCommand }); + _revokers.ShowNotification = projectedCore.ShowNotification(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleShowNotification }); + _revokers.WindowSizeChanged = projectedCore.WindowSizeChanged(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleWindowSizeChanged }); + _revokers.WriteToClipboard = projectedCore.WriteToClipboard(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleWriteToClipboard }); - _revokers.PasteFromClipboard = _interactivity->PasteFromClipboard(winrt::auto_revoke, { get_weak(), &TermControl::_bubblePasteFromClipboard }); + _revokers.PasteFromClipboard = content.PasteFromClipboard(winrt::auto_revoke, { get_weak(), &TermControl::_bubblePasteFromClipboard }); - _revokers.RefreshQuickFixUI = _core->RefreshQuickFixUI(winrt::auto_revoke, [this](auto /*s*/, auto /*e*/) { + _revokers.RefreshQuickFixUI = projectedCore.RefreshQuickFixUI(winrt::auto_revoke, [this](auto /*s*/, auto /*e*/) { RefreshQuickFixMenu(); }); @@ -398,8 +399,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation // NOTE: _ScrollPositionChanged has to be registered after we set up the // _updateScrollBar func. Otherwise, we could get a callback from an // attached content before we set up the throttled func, and that'll A/V - _revokers.coreScrollPositionChanged = _core->ScrollPositionChanged(winrt::auto_revoke, { get_weak(), &TermControl::_ScrollPositionChanged }); - _revokers.WarningBell = _core->WarningBell(winrt::auto_revoke, { get_weak(), &TermControl::_coreWarningBell }); + _revokers.coreScrollPositionChanged = projectedCore.ScrollPositionChanged(winrt::auto_revoke, { get_weak(), &TermControl::_ScrollPositionChanged }); + _revokers.WarningBell = projectedCore.WarningBell(winrt::auto_revoke, { get_weak(), &TermControl::_coreWarningBell }); static constexpr auto AutoScrollUpdateInterval = std::chrono::microseconds(static_cast(1.0 / 30.0 * 1000000)); _autoScrollTimer.Interval(AutoScrollUpdateInterval); From 7cd5c05f1d7b8e202e48d6691e1331dc35205edf Mon Sep 17 00:00:00 2001 From: "Dustin L. Howett" Date: Fri, 25 Sep 2026 14:22:00 -0500 Subject: [PATCH 8/8] why --- src/cascadia/TerminalSettingsModel/IInheritable.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cascadia/TerminalSettingsModel/IInheritable.h b/src/cascadia/TerminalSettingsModel/IInheritable.h index f25e3e81bb..aae47f61db 100644 --- a/src/cascadia/TerminalSettingsModel/IInheritable.h +++ b/src/cascadia/TerminalSettingsModel/IInheritable.h @@ -136,7 +136,7 @@ private: \ return std::nullopt; \ } \ \ - auto _get##name##OverrideSourceImpl() -> decltype(get_strong()) \ + auto _get##name##OverrideSourceImpl()->decltype(get_strong()) \ { \ /*we have a value*/ \ if (_##name) \ @@ -159,7 +159,7 @@ private: \ } \ \ auto _get##name##OverrideSourceAndValueImpl() \ - -> std::pair \ + ->std::pair \ { \ /*we have a value*/ \ if (_##name) \