diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index 1b873bf3c06..157d7441fc4 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -1049,6 +1049,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation Focus(FocusState::Pointer); } + _pointerPressedInBounds = true; + if (type == Windows::Devices::Input::PointerDeviceType::Touch) { const auto contactRect = point.Properties().ContactRect(); @@ -1103,8 +1105,12 @@ namespace winrt::Microsoft::Terminal::Control::implementation _focused, pixelPosition); - if (_focused && point.Properties().IsLeftButtonPressed()) + if (_focused && _pointerPressedInBounds && point.Properties().IsLeftButtonPressed()) { + // We want to find the distance relative to the bounds of the + // SwapChainPanel, not the entire control. If they drag out of + // the bounds of the text, into the padding, we still what that + // to auto-scroll const double cursorBelowBottomDist = cursorPosition.Y - SwapChainPanel().Margin().Top - SwapChainPanel().ActualHeight(); const double cursorAboveTopDist = -1 * cursorPosition.Y + SwapChainPanel().Margin().Top; @@ -1154,6 +1160,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation return; } + _pointerPressedInBounds = false; + const auto ptr = args.Pointer(); const auto point = args.GetCurrentPoint(*this); const auto cursorPosition = point.Position(); diff --git a/src/cascadia/TerminalControl/TermControl.h b/src/cascadia/TerminalControl/TermControl.h index a074e020eff..6c9aa675734 100644 --- a/src/cascadia/TerminalControl/TermControl.h +++ b/src/cascadia/TerminalControl/TermControl.h @@ -167,11 +167,13 @@ namespace winrt::Microsoft::Terminal::Control::implementation std::shared_ptr> _updateScrollBar; bool _isInternalScrollBarUpdate; - // Auto scroll occurs when user, while selecting, drags cursor outside viewport. View is then scrolled to 'follow' the cursor. + // Auto scroll occurs when user, while selecting, drags cursor outside + // viewport. View is then scrolled to 'follow' the cursor. double _autoScrollVelocity; std::optional _autoScrollingPointerPoint; Windows::UI::Xaml::DispatcherTimer _autoScrollTimer; std::optional _lastAutoScrollUpdateTime; + bool _pointerPressedInBounds{ false }; winrt::Windows::UI::Composition::ScalarKeyFrameAnimation _bellLightAnimation{ nullptr }; Windows::UI::Xaml::DispatcherTimer _bellLightTimer{ nullptr };