terminal/src/cascadia/TerminalControl
Mike Griese 8910a16fd0
Split TermControl into a Core, Interactivity, and Control layer (#9820)
## Summary of the Pull Request

Brace yourselves, it's finally here. This PR does the dirty work of splitting the monolithic `TermControl` into three components. These components are: 

* `ControlCore`: This encapsulates the `Terminal` instance, the `DxEngine` and `Renderer`, and the `Connection`. This is intended to everything that someone might need to stand up a terminal instance in a control, but without any regard for how the UX works.
* `ControlInteractivity`: This is a wrapper for the `ControlCore`, which holds the logic for things like double-click, right click copy/paste, selection, etc. This is intended to be a UI framework-independent abstraction. The methods this layer exposes can be called the same from both the WinUI TermControl and the WPF control.
* `TermControl`: This is the UWP control. It's got a Core and Interactivity inside it, which it uses for the actual logic of the terminal itself. TermControl's main responsibility is now 

By splitting into smaller pieces, it will enable us to
* write unit tests for the `Core` and `Interactivity` bits, which we desparately need
* Combine `ControlCore` and `ControlInteractivity` in an out-of-proc core process in the future, to enable tab tearout.

However, we're not doing that work quite yet. There's still lots of work to be done to enable that, thought this is likely the biggest portion.

Ideally, this would just be methods moved wholesale from one file to another. Unfortunately, there are a bunch of cases where that didn't work as well as expected. Especially when trying to better enforce the boundary between the classes. 

We've got a couple tests here that I've added. These are partially examples, and partially things I ran into while implementing this. A bunch of things from #7001 can go in now that we have this.

This PR is gonna be a huge pain to review - 38 files with 3,730 additions and 1,661 deletions is nothing to scoff at. It will also conflict 100% with anything that's targeting `TermControl`. I'm hoping we can review this over the course of the next week and just be done with it, and leave plenty of runway for 1.9 bugs in post.

## References

* In pursuit of #1256
* Proc Model: #5000
* https://github.com/microsoft/terminal/projects/5

## PR Checklist
* [x] Closes #6842
* [x] Closes https://github.com/microsoft/terminal/projects/5#card-50760249
* [x] Closes https://github.com/microsoft/terminal/projects/5#card-50760258
* [x] I work here
* [x] Tests added/passed
* [n/a] Requires documentation to be updated

## Detailed Description of the Pull Request / Additional comments

* I don't love the names `ControlCore` and `ControlInteractivity`. Open to other names.
* I added a `ICoreState` interface for "properties that come from the `ControlCore`, but consumers of the `TermControl` need to know". In the future, these will all need to be handled specially, because they might involve an RPC call to retrieve the info from the core (or cache it) in the window process.
* I've added more `EventArgs` to make more events proper `TypedEvent`s.
* I've changed how the TerminalApp layer requests updated TaskbarProgress state. It doesn't need to pump TermControl to raise a new event anymore.
* ~~Something that snuck into this branch in the very long history is the switch to `DCompositionCreateSurfaceHandle` for the `DxEngine`. @miniksa wrote this originally in 30b8335, I'm just finally committing it here. We'll need that in the future for the out-of-proc stuff.~~
  * I reverted this in c113b65d9. We can revert _that_ commit when we want to come back to it.
* I've changed the acrylic handler a decent amount. But added tests!
* All the `ThrottledFunc` things are left in `TermControl`. Some might be able to move down into core/interactivity, but once we figure out how to use a different kind of Dispatcher (because a UI thread won't necessarily exist for those components).
* I've undoubtably messed up the merging of the locking around the appearance config stuff recently

## Validation Steps Performed

I've got a rolling list in https://github.com/microsoft/terminal/issues/6842#issuecomment-810990460 that I'm updating as I go.
2021-04-27 15:50:45 +00:00
..
dll Create a control unittesting project (#9677) 2021-04-05 16:07:55 +00:00
Resources/en-US Introduce read-only panes (#8867) 2021-02-08 18:03:55 +00:00
ControlCore.cpp Split TermControl into a Core, Interactivity, and Control layer (#9820) 2021-04-27 15:50:45 +00:00
ControlCore.h Split TermControl into a Core, Interactivity, and Control layer (#9820) 2021-04-27 15:50:45 +00:00
ControlCore.idl Split TermControl into a Core, Interactivity, and Control layer (#9820) 2021-04-27 15:50:45 +00:00
ControlInteractivity.cpp Split TermControl into a Core, Interactivity, and Control layer (#9820) 2021-04-27 15:50:45 +00:00
ControlInteractivity.h Split TermControl into a Core, Interactivity, and Control layer (#9820) 2021-04-27 15:50:45 +00:00
ControlInteractivity.idl Split TermControl into a Core, Interactivity, and Control layer (#9820) 2021-04-27 15:50:45 +00:00
EventArgs.cpp Split TermControl into a Core, Interactivity, and Control layer (#9820) 2021-04-27 15:50:45 +00:00
EventArgs.h Split TermControl into a Core, Interactivity, and Control layer (#9820) 2021-04-27 15:50:45 +00:00
EventArgs.idl Split TermControl into a Core, Interactivity, and Control layer (#9820) 2021-04-27 15:50:45 +00:00
IControlAppearance.idl Add support for a profile to specify an "unfocused" appearance (#8392) 2021-04-08 22:46:16 +00:00
IControlSettings.idl Add support for a profile to specify an "unfocused" appearance (#8392) 2021-04-08 22:46:16 +00:00
ICoreState.idl Split TermControl into a Core, Interactivity, and Control layer (#9820) 2021-04-27 15:50:45 +00:00
IDirectKeyListener.idl Move events out of TermControl.h ; Use TYPED_EVENT in more places (#9526) 2021-03-18 22:02:39 +00:00
IKeyBindings.idl Rename Microsoft.Terminal.TerminalControl to .Control; Split into dll & lib (#9472) 2021-03-17 20:47:24 +00:00
IMouseWheelListener.idl Rename Microsoft.Terminal.TerminalControl to .Control; Split into dll & lib (#9472) 2021-03-17 20:47:24 +00:00
init.cpp Rename Microsoft.Terminal.TerminalControl to .Control; Split into dll & lib (#9472) 2021-03-17 20:47:24 +00:00
KeyChord.cpp Add support for the win key in keybindings (#9783) 2021-04-15 16:52:28 +00:00
KeyChord.h Add support for the win key in keybindings (#9783) 2021-04-15 16:52:28 +00:00
KeyChord.idl Add support for the win key in keybindings (#9783) 2021-04-15 16:52:28 +00:00
packages.config Update C++/WinRT to 2.0.210309.3 (#9437) 2021-03-10 16:04:59 -06:00
pch.cpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
pch.h Move events out of TermControl.h ; Use TYPED_EVENT in more places (#9526) 2021-03-18 22:02:39 +00:00
SearchBoxControl.cpp Rename Microsoft.Terminal.TerminalControl to .Control; Split into dll & lib (#9472) 2021-03-17 20:47:24 +00:00
SearchBoxControl.h Rename Microsoft.Terminal.TerminalControl to .Control; Split into dll & lib (#9472) 2021-03-17 20:47:24 +00:00
SearchBoxControl.idl Rename Microsoft.Terminal.TerminalControl to .Control; Split into dll & lib (#9472) 2021-03-17 20:47:24 +00:00
SearchBoxControl.xaml Auto-format our XAML files and enforce in CI (#9589) 2021-03-29 17:09:38 -05:00
TermControl.cpp Split TermControl into a Core, Interactivity, and Control layer (#9820) 2021-04-27 15:50:45 +00:00
TermControl.h Split TermControl into a Core, Interactivity, and Control layer (#9820) 2021-04-27 15:50:45 +00:00
TermControl.idl Split TermControl into a Core, Interactivity, and Control layer (#9820) 2021-04-27 15:50:45 +00:00
TermControl.xaml Fix tab and hyperlink tooltips to wrap long text (#9913) 2021-04-21 15:40:17 +00:00
TermControlAutomationPeer.cpp Split TermControl into a Core, Interactivity, and Control layer (#9820) 2021-04-27 15:50:45 +00:00
TermControlAutomationPeer.h Rename Microsoft.Terminal.TerminalControl to .Control; Split into dll & lib (#9472) 2021-03-17 20:47:24 +00:00
TermControlAutomationPeer.idl Rename Microsoft.Terminal.TerminalControl to .Control; Split into dll & lib (#9472) 2021-03-17 20:47:24 +00:00
TerminalControlLib.vcxproj Split TermControl into a Core, Interactivity, and Control layer (#9820) 2021-04-27 15:50:45 +00:00
ThrottledFunc.h Resolve circular reference in ThrottledFunc (#9729) 2021-04-06 19:07:49 +00:00
TSFInputControl.cpp Rename Microsoft.Terminal.TerminalControl to .Control; Split into dll & lib (#9472) 2021-03-17 20:47:24 +00:00
TSFInputControl.h Rename Microsoft.Terminal.TerminalControl to .Control; Split into dll & lib (#9472) 2021-03-17 20:47:24 +00:00
TSFInputControl.idl Rename Microsoft.Terminal.TerminalControl to .Control; Split into dll & lib (#9472) 2021-03-17 20:47:24 +00:00
TSFInputControl.xaml Auto-format our XAML files and enforce in CI (#9589) 2021-03-29 17:09:38 -05:00
XamlUiaTextRange.cpp Rename Microsoft.Terminal.TerminalControl to .Control; Split into dll & lib (#9472) 2021-03-17 20:47:24 +00:00
XamlUiaTextRange.h Rename Microsoft.Terminal.TerminalControl to .Control; Split into dll & lib (#9472) 2021-03-17 20:47:24 +00:00