This commit is contained in:
Dustin Howett 2021-11-22 12:51:16 -08:00
parent f5f09a6869
commit a7a0d2a6c2
2 changed files with 17 additions and 21 deletions

View File

@ -137,12 +137,12 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// functions.
try
{
_dispatcher = winrt::Windows::System::DispatcherQueue::GetForCurrentThread();
if (!_dispatcher)
{
auto controller{ winrt::Windows::System::DispatcherQueueController::CreateOnDedicatedThread() };
_dispatcher = controller.DispatcherQueue();
}
//_dispatcher = winrt::Windows::System::DispatcherQueue::GetForCurrentThread();
//if (!_dispatcher)
//{
//auto controller{ winrt::Windows::System::DispatcherQueueController::CreateOnDedicatedThread() };
//_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
@ -157,8 +157,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// 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<ThrottledFuncTrailing<>>(
_dispatcher,
_tsfTryRedrawCanvas = std::make_unique<til::throttled_func_trailing<>>(
TsfRedrawInterval,
[weakThis = get_weak()]() {
if (auto core{ weakThis.get() }; !core->_IsClosing())
@ -167,8 +166,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
}
});
_updatePatternLocations = std::make_shared<ThrottledFuncTrailing<>>(
_dispatcher,
_updatePatternLocations = std::make_unique<til::throttled_func_trailing<>>(
UpdatePatternLocationsInterval,
[weakThis = get_weak()]() {
if (auto core{ weakThis.get() }; !core->_IsClosing())
@ -177,8 +175,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
}
});
_updateScrollBar = std::make_shared<ThrottledFuncTrailing<Control::ScrollPositionChangedArgs>>(
_dispatcher,
_updateScrollBar = std::make_unique<til::throttled_func_trailing<Control::ScrollPositionChangedArgs>>(
ScrollBarUpdateInterval,
[weakThis = get_weak()](const auto& update) {
if (auto core{ weakThis.get() }; !core->_IsClosing())
@ -436,7 +433,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
_terminal->UserScrollViewport(viewTop);
if (_updatePatternLocations)
_updatePatternLocations->Run();
_updatePatternLocations->operator()();
}
void ControlCore::AdjustOpacity(const double adjustment)
@ -1213,7 +1210,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
if (!_inUnitTests)
{
if (_updateScrollBar)
_updateScrollBar->Run(update);
_updateScrollBar->operator()(update);
}
else
{
@ -1222,7 +1219,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// Additionally, start the throttled update of where our links are.
if (_updatePatternLocations)
_updatePatternLocations->Run();
_updatePatternLocations->operator()();
}
void ControlCore::_terminalCursorPositionChanged()
@ -1230,7 +1227,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// When the buffer's cursor moves, start the throttled func to
// eventually dispatch a CursorPositionChanged event.
if (_tsfTryRedrawCanvas)
_tsfTryRedrawCanvas->Run();
_tsfTryRedrawCanvas->operator()();
}
void ControlCore::_terminalTaskbarProgressChanged()
@ -1521,7 +1518,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// Start the throttled update of where our hyperlinks are.
if (_updatePatternLocations)
_updatePatternLocations->Run();
_updatePatternLocations->operator()();
}
// Method Description:

View File

@ -214,10 +214,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
double _panelHeight{ 0 };
double _compositionScale{ 0 };
winrt::Windows::System::DispatcherQueue _dispatcher{ nullptr };
std::shared_ptr<ThrottledFuncTrailing<>> _tsfTryRedrawCanvas;
std::shared_ptr<ThrottledFuncTrailing<>> _updatePatternLocations;
std::shared_ptr<ThrottledFuncTrailing<Control::ScrollPositionChangedArgs>> _updateScrollBar;
std::unique_ptr<til::throttled_func_trailing<>> _tsfTryRedrawCanvas;
std::unique_ptr<til::throttled_func_trailing<>> _updatePatternLocations;
std::unique_ptr<til::throttled_func_trailing<Control::ScrollPositionChangedArgs>> _updateScrollBar;
winrt::fire_and_forget _asyncCloseConnection();