7f3bc3cb04
## Summary of the Pull Request This forces the `TermControl` to only use `ControlCore` and `ControlInteractivity` via their WinRT projections. We want this, because WinRT projections can be used across process boundaries. In the future, `ControlCore` and `ControlInteractivity` are going to be living in a different process entirely from `TermControl`. By enforcing this boundary now, we can make sure that they will work seamlessly in the future. ## References * Tear-out: #1256 * Megathread: #5000 * Project: https://github.com/microsoft/terminal/projects/5 ## PR Checklist * [x] Closes https://github.com/microsoft/terminal/projects/5#card-50760270 * [x] I work here * [x] Tests added/passed * [n/a] Requires documentation to be updated ## Detailed Description of the Pull Request / Additional comments Most all this was just converting pure c++ types to winrt types when possible. I've added a couple helper projections with `til` converters, which made most of this really easy. The "`MouseButtonState` needs to be composed of `Int32`s instead of `bool`s" is MENTAL. I have no idea why this is, but when I had the control OOP in the sample, that would crash when trying to de-marshal the bools. BODGY. The biggest changes are in the way the UIA stuff is hooked up. The UiaEngine needs to be attached directly to the `Renderer`, and it can't be easily projected, so it needs to live next to the `ControlCore`. But the `TermControlAutomationPeer` needed the `UiaEngine` to help implement some interfaces. Now, there's a new layer we've introduced. `InteractivityAutomationPeer` does the `ITextProvider`, `IControlAccessibilityInfo` and the `IUiaEventDispatcher` thing. `TermControlAutomationPeer` now has a `InteractivityAutomationPeer` stashed inside itself, so that it can ask the interactivity layer to do the real work. We still need the `TermControlAutomationPeer` though, to be able to attach to the real UI tree. ## Validation Steps Performed The terminal behaves basically the same as before. Most importantly, I whipped out Accessibility Insights, and the Terminal looks the same as before.
84 lines
3.7 KiB
C++
84 lines
3.7 KiB
C++
/*++
|
|
Copyright (c) Microsoft Corporation
|
|
Licensed under the MIT license.
|
|
|
|
Module Name:
|
|
- TermControlAutomationPeer.h
|
|
|
|
Abstract:
|
|
- This module provides UI Automation access to the TermControl
|
|
to support both automation tests and accessibility (screen
|
|
reading) applications. This mainly interacts with ScreenInfoUiaProvider
|
|
to allow for shared code between ConHost and Windows Terminal
|
|
accessibility providers.
|
|
- Based on the Custom Automation Peers guide on msdn
|
|
(https://docs.microsoft.com/en-us/windows/uwp/design/accessibility/custom-automation-peers)
|
|
- Wraps the UIAutomationCore ITextProvider
|
|
(https://docs.microsoft.com/en-us/windows/win32/api/uiautomationcore/nn-uiautomationcore-itextprovider)
|
|
with a XAML ITextProvider
|
|
(https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.automation.provider.itextprovider)
|
|
|
|
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
|
|
|
|
#include "TermControl.h"
|
|
#include "ControlInteractivity.h"
|
|
#include "TermControlAutomationPeer.g.h"
|
|
#include "../types/TermControlUiaProvider.hpp"
|
|
#include "../types/IUiaEventDispatcher.h"
|
|
#include "../types/IControlAccessibilityInfo.h"
|
|
|
|
namespace winrt::Microsoft::Terminal::Control::implementation
|
|
{
|
|
struct TermControlAutomationPeer :
|
|
public TermControlAutomationPeerT<TermControlAutomationPeer>,
|
|
::Microsoft::Console::Types::IUiaEventDispatcher
|
|
{
|
|
public:
|
|
TermControlAutomationPeer(Microsoft::Terminal::Control::implementation::TermControl* owner,
|
|
Control::InteractivityAutomationPeer implementation);
|
|
|
|
void UpdateControlBounds();
|
|
void SetControlPadding(const Core::Padding padding);
|
|
|
|
#pragma region FrameworkElementAutomationPeer
|
|
hstring GetClassNameCore() const;
|
|
Windows::UI::Xaml::Automation::Peers::AutomationControlType GetAutomationControlTypeCore() const;
|
|
hstring GetLocalizedControlTypeCore() const;
|
|
Windows::Foundation::IInspectable GetPatternCore(Windows::UI::Xaml::Automation::Peers::PatternInterface patternInterface) const;
|
|
Windows::UI::Xaml::Automation::Peers::AutomationOrientation GetOrientationCore() const;
|
|
hstring GetNameCore() const;
|
|
hstring GetHelpTextCore() const;
|
|
Windows::UI::Xaml::Automation::Peers::AutomationLiveSetting GetLiveSettingCore() const;
|
|
#pragma endregion
|
|
|
|
#pragma region IUiaEventDispatcher
|
|
void SignalSelectionChanged() override;
|
|
void SignalTextChanged() override;
|
|
void SignalCursorChanged() 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<Windows::UI::Xaml::Automation::Provider::ITextRangeProvider> GetVisibleRanges();
|
|
com_array<Windows::UI::Xaml::Automation::Provider::ITextRangeProvider> GetSelection();
|
|
Windows::UI::Xaml::Automation::SupportedTextSelection SupportedTextSelection();
|
|
Windows::UI::Xaml::Automation::Provider::ITextRangeProvider DocumentRange();
|
|
#pragma endregion
|
|
|
|
private:
|
|
winrt::Microsoft::Terminal::Control::implementation::TermControl* _termControl;
|
|
Control::InteractivityAutomationPeer _contentAutomationPeer;
|
|
|
|
winrt::com_array<Windows::UI::Xaml::Automation::Provider::ITextRangeProvider> WrapArrayOfTextRangeProviders(SAFEARRAY* textRanges);
|
|
};
|
|
}
|