This commit is contained in:
Mike Griese 2021-05-14 11:51:48 -05:00
parent 20364acc7c
commit baf97f192c
6 changed files with 28 additions and 91 deletions

View file

@ -23,8 +23,7 @@
<TextBox x:Name="GuidInput"
Width="400"
PlaceholderText="{}{guid here}" />
<Button x:Name="CreateOopControl"
Grid.Row="0"
<Button Grid.Row="0"
Tapped="CreateClicked">
Create
</Button>

View file

@ -756,13 +756,6 @@ namespace winrt::TerminalApp::implementation
::base::saturated_cast<uint32_t>(settings.InitialRows()),
::base::saturated_cast<uint32_t>(settings.InitialCols()),
winrt::guid() });
// connection = TerminalConnection::ConptyConnection(azBridgePath.wstring(),
// L".",
// L"Azure",
// nullptr,
// settings.InitialRows(),
// settings.InitialCols(),
// winrt::guid());
}
else
@ -800,14 +793,6 @@ namespace winrt::TerminalApp::implementation
::base::saturated_cast<uint32_t>(settings.InitialRows()),
::base::saturated_cast<uint32_t>(settings.InitialCols()),
winrt::guid() });
// auto conhostConn = TerminalConnection::ConptyConnection(
// settings.Commandline(),
// winrt::hstring{ cwd.c_str() },
// settings.StartingTitle(),
// envMap.GetView(),
// settings.InitialRows(),
// settings.InitialCols(),
// winrt::guid());
sessionGuid = conhostConn.Guid();
connection = conhostConn;

View file

@ -7,7 +7,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
struct ConptyConnectionSettings : ConptyConnectionSettingsT<ConptyConnectionSettings>
{
// WINRT_PROPERTY will be VERY unhappy if you use this templated type
// directly in the macro, so just typdef a helper here.
// directly in the macro, so just typedef a helper here.
using EnvironmentMap = Windows::Foundation::Collections::IMapView<hstring, hstring>;
ConptyConnectionSettings(hstring const& cmdline,
hstring const& startingDirectory,

View file

@ -104,6 +104,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation
auto pfnTerminalTaskbarProgressChanged = std::bind(&ControlCore::_terminalTaskbarProgressChanged, this);
_terminal->TaskbarProgressChangedCallback(pfnTerminalTaskbarProgressChanged);
// Get our dispatcher. If we're hosted in-proc with XAML, this will get
// us the same dispatcher as TermControl::Dispatcher(). If we're out of
// proc, this'll return null. We'll need to instead make a new
// DispatcherQueue (on a new thread), so we can use that for throttled
// functions.
_dispatcher = winrt::Windows::System::DispatcherQueue::GetForCurrentThread();
if (!_dispatcher)
{
@ -111,6 +116,19 @@ namespace winrt::Microsoft::Terminal::Control::implementation
_dispatcher = controller.DispatcherQueue();
}
// A few different events should be throttled, so they don't fire absolutely all the time:
// * _tsfTryRedrawCanvas: When the cursor position moves, we need to
// inform TSF, so it can move the canvas for the composition. We
// throttle this so that we're not hopping across the process boundary
// every time that the cursor moves.
// * _updatePatternLocations: When there's new output, or we scroll the
// viewport, we should re-check if there are any visible hyperlinks.
// But we don't really need to do this every single time text is
// output, we can limit this update to once every 500ms.
// * _updateScrollBar: Same idea as the TSF update - we don't _really_
// need to hop across the process boundary every time text is output.
// We can throttle this to once every 8ms, which will get us out of
// the way of the main output & rendering threads.
_tsfTryRedrawCanvas = std::make_shared<ThrottledFunc<winrt::Windows::System::DispatcherQueue>>(
[weakThis = get_weak()]() {
if (auto core{ weakThis.get() })
@ -137,22 +155,6 @@ namespace winrt::Microsoft::Terminal::Control::implementation
{
core->_ScrollPositionChangedHandlers(*core, update);
}
// if (auto control{ weakThis.get() })
// {
// control->_isInternalScrollBarUpdate = true;
// auto scrollBar = control->ScrollBar();
// if (update.newValue.has_value())
// {
// scrollBar.Value(update.newValue.value());
// }
// scrollBar.Maximum(update.newMaximum);
// scrollBar.Minimum(update.newMinimum);
// scrollBar.ViewportSize(update.newViewportSize);
// // scroll one full screen worth at a time when the scroll bar is clicked
// scrollBar.LargeChange(std::max(update.newViewportSize - 1, 0.));
// control->_isInternalScrollBarUpdate = false;
// }
},
ScrollBarUpdateInterval,
_dispatcher);
@ -1143,22 +1145,21 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// TODO GH#9617: refine locking around pattern tree
_terminal->ClearPatternTree();
// Start the throttled update of our scrollbar.
auto update{ winrt::make<ScrollPositionChangedArgs>(viewTop,
viewHeight,
bufferSize) };
// _ScrollPositionChangedHandlers(*this,
// winrt::make<ScrollPositionChangedArgs>(viewTop,
// viewHeight,
// bufferSize));
_updateScrollBar->Run(update);
// Additionally, start the throttled update of where our links are.
_updatePatternLocations->Run();
}
void ControlCore::_terminalCursorPositionChanged()
{
// When the buffer's cursor moves, start the throttled func to
// eventually dispatch a CursorPositionChanged event.
_tsfTryRedrawCanvas->Run();
// _CursorPositionChangedHandlers(*this, nullptr);
}
void ControlCore::_terminalTaskbarProgressChanged()
@ -1446,19 +1447,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
{
_terminal->Write(hstr);
// // NOTE: We're raising an event here to inform the TermControl that
// // output has been received, so it can queue up a throttled
// // UpdatePatternLocations call. In the future, we should have the
// // _updatePatternLocations ThrottledFunc internal to this class, and
// // run on this object's dispatcher queue.
// //
// // We're not doing that quite yet, because the Core will eventually
// // be out-of-proc from the UI thread, and won't be able to just use
// // the UI thread as the dispatcher queue thread.
// //
// // See TODO: https://github.com/microsoft/terminal/projects/5#card-50760282
// _ReceivedOutputHandlers(*this, nullptr);
// Start the throttled update of where our hyperlinks are.
_updatePatternLocations->Run();
}

View file

@ -81,13 +81,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
}
_core = _interactivity.Core();
// // Use a manual revoker on the output event, so we can immediately stop
// // worrying about it on destruction.
// _coreOutputEventToken = _core.ReceivedOutput({ this, &TermControl::_coreReceivedOutput });
// // These events might all be triggered by the connection, but that
// // should be drained and closed before we complete destruction. So these
// // are safe.
// These events might all be triggered by the connection, but that
// should be drained and closed before we complete destruction. So these
// are safe.
_core.ScrollPositionChanged({ this, &TermControl::_ScrollPositionChanged });
_core.WarningBell({ this, &TermControl::_coreWarningBell });
_core.CursorPositionChanged({ this, &TermControl::_CursorPositionChanged });
@ -136,16 +132,6 @@ namespace winrt::Microsoft::Terminal::Control::implementation
TsfRedrawInterval,
Dispatcher());
// _updatePatternLocations = std::make_shared<ThrottledFunc<winrt::Windows::UI::Core::CoreDispatcher>>(
// [weakThis = get_weak()]() {
// if (auto control{ weakThis.get() })
// {
// control->_core.UpdatePatternLocations();
// }
// },
// UpdatePatternLocationsInterval,
// Dispatcher());
_playWarningBell = std::make_shared<ThrottledFunc<winrt::Windows::UI::Core::CoreDispatcher>>(
[weakThis = get_weak()]() {
if (auto control{ weakThis.get() })
@ -1276,23 +1262,6 @@ namespace winrt::Microsoft::Terminal::Control::implementation
CATCH_LOG();
}
// void TermControl::_coreReceivedOutput(const IInspectable& /*sender*/,
// const IInspectable& /*args*/)
// {
// // Queue up a throttled UpdatePatternLocations call. In the future, we
// // should have the _updatePatternLocations ThrottledFunc internal to
// // ControlCore, and run on that object's dispatcher queue.
// //
// // We're not doing that quite yet, because the Core will eventually
// // be out-of-proc from the UI thread, and won't be able to just use
// // the UI thread as the dispatcher queue thread.
// //
// // THIS IS CALLED ON EVERY STRING OF TEXT OUTPUT TO THE TERMINAL. Think
// // twice before adding anything here.
// _updatePatternLocations->Run();
// }
// Method Description:
// - Reset the font size of the terminal to its default size.
// Arguments:
@ -1330,8 +1299,6 @@ namespace winrt::Microsoft::Terminal::Control::implementation
_updateScrollBar->ModifyPending([](auto& update) {
update.newValue.reset();
});
// _updatePatternLocations->Run();
}
// Method Description:
@ -1669,7 +1636,6 @@ namespace winrt::Microsoft::Terminal::Control::implementation
update.newValue = args.ViewTop();
_updateScrollBar->Run(update);
// _updatePatternLocations->Run();
}
// Method Description:

View file

@ -146,7 +146,6 @@ namespace winrt::Microsoft::Terminal::Control::implementation
bool _initializedTerminal;
std::shared_ptr<ThrottledFunc<winrt::Windows::UI::Core::CoreDispatcher>> _tsfTryRedrawCanvas;
// std::shared_ptr<ThrottledFunc<winrt::Windows::UI::Core::CoreDispatcher>> _updatePatternLocations;
std::shared_ptr<ThrottledFunc<winrt::Windows::UI::Core::CoreDispatcher>> _playWarningBell;
struct ScrollBarUpdate
@ -246,7 +245,6 @@ namespace winrt::Microsoft::Terminal::Control::implementation
const int fontHeight,
const bool isInitialChange);
winrt::fire_and_forget _coreTransparencyChanged(IInspectable sender, Control::TransparencyChangedEventArgs args);
// void _coreReceivedOutput(const IInspectable& sender, const IInspectable& args);
void _coreRaisedNotice(const IInspectable& s, const Control::NoticeEventArgs& args);
void _coreWarningBell(const IInspectable& sender, const IInspectable& args);
};