Skip to content

Commit

Permalink
This too didn't work. Creating the XAML thing not on the XAML thing i…
Browse files Browse the repository at this point in the history
…sn't going to work
  • Loading branch information
zadjii-msft committed Aug 16, 2021
1 parent 3a0fbd9 commit fd364db
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/cascadia/TerminalControl/ControlCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1484,4 +1484,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
_updatePatternLocations->Run();
}

winrt::Windows::System::DispatcherQueue ControlCore::Dispatcher()
{
return _dispatcher;
}
}
2 changes: 2 additions & 0 deletions src/cascadia/TerminalControl/ControlCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
bool IsInReadOnlyMode() const;
void ToggleReadOnlyMode();

winrt::Windows::System::DispatcherQueue Dispatcher();

// -------------------------------- WinRT Events ---------------------------------
// clang-format off
WINRT_CALLBACK(FontSizeChanged, Control::FontSizeChangedEventArgs);
Expand Down
19 changes: 15 additions & 4 deletions src/cascadia/TerminalControl/ControlInteractivity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "ControlInteractivity.g.cpp"
#include "TermControl.h"
#include <til/latch.h>

using namespace ::Microsoft::Console::Types;
using namespace ::Microsoft::Console::VirtualTerminal;
Expand Down Expand Up @@ -614,11 +615,21 @@ namespace winrt::Microsoft::Terminal::Control::implementation
Control::InteractivityAutomationPeer ControlInteractivity::OnCreateAutomationPeer()
try
{
auto autoPeer = winrt::make_self<implementation::InteractivityAutomationPeer>(this);
til::latch latch{ 1 };
Control::InteractivityAutomationPeer peer{ nullptr };

_uiaEngine = std::make_unique<::Microsoft::Console::Render::UiaEngine>(autoPeer.get());
_core->AttachUiaEngine(_uiaEngine.get());
return *autoPeer;
_core->Dispatcher().TryEnqueue([this, &peer, &latch]() {
auto autoPeer = winrt::make_self<implementation::InteractivityAutomationPeer>(this);

_uiaEngine = std::make_unique<::Microsoft::Console::Render::UiaEngine>(autoPeer.get());
_core->AttachUiaEngine(_uiaEngine.get());

peer = *autoPeer;
latch.count_down();
});

latch.wait();
return peer;
}
catch (...)
{
Expand Down

0 comments on commit fd364db

Please sign in to comment.