mirror of
https://github.com/microsoft/terminal.git
synced 2026-07-08 17:56:28 +00:00
Allow ThrottledFunc to work on different types of dispatcher (#10187)
#### ⚠️ targets #10051
## Summary of the Pull Request
This updates our `ThrottledFunc`s to take a dispatcher parameter. This means that we can use the `Windows::UI::Core::CoreDispatcher` in the `TermControl`, where there's always a `CoreDispatcher`, and use a `Windows::System::DispatcherQueue` in `ControlCore`/`ControlInteractivity`. When running in-proc, these are always the _same thing_. However, out-of-proc, the core needs a dispatcher queue that's not tied to a UI thread (because the content proces _doesn't have a UI thread!_).
This lets us get rid of the output event, because we don't need to bubble that event out to the `TermControl` to let it throttle that update anymore.
## References
* Tear-out: #1256
* Megathread: #5000
* Project: https://github.com/microsoft/terminal/projects/5
## PR Checklist
* [x] This is a part of #1256
* [x] I work here
* [n/a] Tests added/passed
* [n/a] Requires documentation to be updated
## Detailed Description of the Pull Request / Additional comments
Fortunately, `winrt::resume_foreground` works the same on both a `CoreDispatcher` and a `DispatcherQueue`, so this wasn't too hard!
## Validation Steps Performed
This was validated in `dev/migrie/oop/the-whole-thing` (or `dev/migrie/oop/connection-factory`, I forget which), and I made sure that it worked both in-proc and x-proc. Not only that, _it wasn't any slower_!This reverts commit 04b751faa7.
This commit is contained in:
@@ -56,6 +56,16 @@ namespace ControlUnitTests
|
||||
|
||||
return { settings, conn };
|
||||
}
|
||||
|
||||
winrt::com_ptr<Control::implementation::ControlCore> createCore(Control::IControlSettings settings,
|
||||
TerminalConnection::ITerminalConnection conn)
|
||||
{
|
||||
Log::Comment(L"Create ControlCore object");
|
||||
|
||||
auto core = winrt::make_self<Control::implementation::ControlCore>(settings, conn);
|
||||
core->_inUnitTests = true;
|
||||
return core;
|
||||
}
|
||||
};
|
||||
|
||||
void ControlCoreTests::ComPtrSettings()
|
||||
@@ -71,8 +81,7 @@ namespace ControlUnitTests
|
||||
{
|
||||
auto [settings, conn] = _createSettingsAndConnection();
|
||||
|
||||
Log::Comment(L"Create ControlCore object");
|
||||
auto core = winrt::make_self<Control::implementation::ControlCore>(*settings, *conn);
|
||||
auto core = createCore(*settings, *conn);
|
||||
VERIFY_IS_NOT_NULL(core);
|
||||
}
|
||||
|
||||
@@ -80,8 +89,7 @@ namespace ControlUnitTests
|
||||
{
|
||||
auto [settings, conn] = _createSettingsAndConnection();
|
||||
|
||||
Log::Comment(L"Create ControlCore object");
|
||||
auto core = winrt::make_self<Control::implementation::ControlCore>(*settings, *conn);
|
||||
auto core = createCore(*settings, *conn);
|
||||
VERIFY_IS_NOT_NULL(core);
|
||||
|
||||
VERIFY_IS_FALSE(core->_initializedTerminal);
|
||||
@@ -99,8 +107,7 @@ namespace ControlUnitTests
|
||||
settings->UseAcrylic(true);
|
||||
settings->TintOpacity(0.5f);
|
||||
|
||||
Log::Comment(L"Create ControlCore object");
|
||||
auto core = winrt::make_self<Control::implementation::ControlCore>(*settings, *conn);
|
||||
auto core = createCore(*settings, *conn);
|
||||
VERIFY_IS_NOT_NULL(core);
|
||||
|
||||
// A callback to make sure that we're raising TransparencyChanged events
|
||||
@@ -167,8 +174,7 @@ namespace ControlUnitTests
|
||||
{
|
||||
auto [settings, conn] = _createSettingsAndConnection();
|
||||
|
||||
Log::Comment(L"Create ControlCore object");
|
||||
auto core = winrt::make_self<Control::implementation::ControlCore>(*settings, *conn);
|
||||
auto core = createCore(*settings, *conn);
|
||||
VERIFY_IS_NOT_NULL(core);
|
||||
|
||||
Log::Comment(L"Close the Core, like a TermControl would");
|
||||
@@ -190,8 +196,7 @@ namespace ControlUnitTests
|
||||
// that you don't default to Cascadia*
|
||||
settings->FontFace(L"Impact");
|
||||
|
||||
Log::Comment(L"Create ControlCore object");
|
||||
auto core = winrt::make_self<Control::implementation::ControlCore>(*settings, *conn);
|
||||
auto core = createCore(*settings, *conn);
|
||||
VERIFY_IS_NOT_NULL(core);
|
||||
|
||||
VERIFY_ARE_EQUAL(L"Impact", std::wstring_view{ core->_actualFont.GetFaceName() });
|
||||
|
||||
Reference in New Issue
Block a user