Skip to content

Commit

Permalink
I wasn't the murderer after all
Browse files Browse the repository at this point in the history
  • Loading branch information
zadjii-msft committed Mar 11, 2021
1 parent acf84f1 commit 5e655ef
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 27 deletions.
34 changes: 10 additions & 24 deletions src/cascadia/TerminalControl/ControlCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,12 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
_renderer = std::make_unique<::Microsoft::Console::Render::Renderer>(_terminal.get(), nullptr, 0, std::move(renderThread));
::Microsoft::Console::Render::IRenderTarget& renderTarget = *_renderer;

// !TODO!: We _DO_ want this
// _renderer->SetRendererEnteredErrorStateCallback([weakThis = get_weak()]() {
// if (auto strongThis{ weakThis.get() })
// {
// strongThis->_RendererEnteredErrorState();
// }
// });
_renderer->SetRendererEnteredErrorStateCallback([weakThis = get_weak()]() {
if (auto strongThis{ weakThis.get() })
{
strongThis->_RendererEnteredErrorStateHandlers(*strongThis, nullptr);
}
});

THROW_IF_FAILED(localPointerToThread->Initialize(_renderer.get()));

Expand Down Expand Up @@ -225,9 +224,9 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
THROW_IF_FAILED(dxEngine->Enable());
_renderEngine = std::move(dxEngine);

// !TODO! in the past we did _AttachDxgiSwapChainToXaml _before_ calling
// EnablePainting. Mild worry that doing EnablePainting first will
// break
// In the past we did _AttachDxgiSwapChainToXaml _before_ calling
// EnablePainting. There's mild worry that doing EnablePainting
// first will break something, but this seems to work.
localPointerToThread->EnablePainting();

_initializedTerminal = true;
Expand All @@ -237,10 +236,6 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
// start writing output immediately.
_connection.Start();

// !TODO!: Do we want this?
// Likewise, run the event handlers outside of lock (they could
// be reentrant)
// _InitializedHandlers(*this, nullptr);
return true;
}
// Method Description:
Expand Down Expand Up @@ -979,14 +974,6 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
const int viewHeight,
const int bufferSize)
{
// !!TODO!! do we need this?
// // Since this callback fires from non-UI thread, we might be already
// // closed/closing.
// if (_closing.load())
// {
// return;
// }

// Clear the regex pattern tree so the renderer does not try to render
// them while scrolling
_terminal->ClearPatternTree();
Expand Down Expand Up @@ -1034,8 +1021,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
const bool goForward,
const bool caseSensitive)
{
// !!TODO!! do we need this?
if (text.size() == 0 /* || _closing*/)
if (text.size() == 0)
{
return;
}
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalControl/ControlCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation

TYPED_EVENT(HoveredHyperlinkChanged, IInspectable, IInspectable);

TYPED_EVENT(RendererEnteredErrorState, IInspectable, IInspectable);
TYPED_EVENT(SwapChainChanged, IInspectable, IInspectable);
TYPED_EVENT(RendererWarning, IInspectable, TerminalControl::RendererWarningArgs);
};
Expand Down
8 changes: 6 additions & 2 deletions src/cascadia/TerminalControl/TermControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
_core->BackgroundColorChanged({ get_weak(), &TermControl::_BackgroundColorChangedHandler });
_core->ScrollPositionChanged({ get_weak(), &TermControl::_ScrollPositionChanged });
_core->CursorPositionChanged({ get_weak(), &TermControl::_CursorPositionChanged });
_core->RendererEnteredErrorState({ get_weak(), &TermControl::_RendererEnteredErrorState });

// Initialize the terminal only once the swapchainpanel is loaded - that
// way, we'll be able to query the real pixel size it got on layout
Expand Down Expand Up @@ -1087,7 +1088,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation

const auto cursorPosition = point.Position();
const auto terminalPosition = _GetTerminalPosition(cursorPosition);
const auto clickCount = _NumberOfClicks(cursorPosition, point.Timestamp());
// const auto clickCount = _NumberOfClicks(cursorPosition, point.Timestamp());

// GH#9396: we prioritize hyper-link over VT mouse events
//
Expand All @@ -1096,6 +1097,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
if (point.Properties().IsLeftButtonPressed() &&
ctrlEnabled && !hyperlink.empty())
{
const auto clickCount = _NumberOfClicks(cursorPosition, point.Timestamp());
// Handle hyper-link only on the first click to prevent multiple activations
if (clickCount == 1)
{
Expand All @@ -1108,6 +1110,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
}
else if (point.Properties().IsLeftButtonPressed())
{
const auto clickCount = _NumberOfClicks(cursorPosition, point.Timestamp());
// This formula enables the number of clicks to cycle properly
// between single-, double-, and triple-click. To increase the
// number of acceptable click states, simply increment
Expand Down Expand Up @@ -2584,7 +2587,8 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation

// Method Description:
// - Produces the error dialog that notifies the user that rendering cannot proceed.
winrt::fire_and_forget TermControl::_RendererEnteredErrorState()
winrt::fire_and_forget TermControl::_RendererEnteredErrorState(IInspectable const& /*sender*/,
IInspectable const& /*args*/)
{
auto strongThis{ get_strong() };
co_await Dispatcher(); // pop up onto the UI thread
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalControl/TermControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation

winrt::fire_and_forget RenderEngineSwapChainChanged(const IInspectable& sender, const IInspectable& args);
void _AttachDxgiSwapChainToXaml(HANDLE swapChainHandle);
winrt::fire_and_forget _RendererEnteredErrorState();
winrt::fire_and_forget _RendererEnteredErrorState(const IInspectable& sender, const IInspectable& args);
void _RenderRetryButton_Click(IInspectable const& button, IInspectable const& args);
winrt::fire_and_forget _RendererWarning(const IInspectable& sender,
const TerminalControl::RendererWarningArgs& args);
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalCore/Terminal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,7 @@ void Terminal::UpdatePatterns() noexcept
// visible region is changing
void Terminal::ClearPatternTree() noexcept
{
auto lock = LockForWriting();
auto oldTree = _patternIntervalTree;
_patternIntervalTree = {};
_InvalidatePatternTree(oldTree);
Expand Down

1 comment on commit 5e655ef

@github-actions

This comment was marked as outdated.

Please sign in to comment.