@@ -1995,6 +1995,15 @@ namespace winrt::Microsoft::Terminal::Control::implementation
19951995 else
19961996 {
19971997 const auto cursorPosition = point.Position ();
1998+ if (point.Properties ().IsMiddleButtonPressed () && !_core.IsVtMouseModeEnabled ())
1999+ {
2000+ const auto action = _core.Settings ().MiddleClickAction ();
2001+ if (action == Control::MiddleClickAction::Pan)
2002+ {
2003+ _isPanning = true ;
2004+ _panningAnchorPos = cursorPosition;
2005+ }
2006+ }
19982007 _interactivity.PointerPressed (point.PointerId (),
19992008 TermControl::GetPressedMouseButtons (point),
20002009 TermControl::GetPointerUpdateKind (point),
@@ -2019,7 +2028,10 @@ namespace winrt::Microsoft::Terminal::Control::implementation
20192028 return ;
20202029 }
20212030
2022- RestorePointerCursor.raise (*this , nullptr );
2031+ if (!_isPanning)
2032+ {
2033+ RestorePointerCursor.raise (*this , nullptr );
2034+ }
20232035
20242036 const auto ptr = args.Pointer ();
20252037 const auto point = args.GetCurrentPoint (*this );
@@ -2041,11 +2053,39 @@ namespace winrt::Microsoft::Terminal::Control::implementation
20412053 ControlKeyStates (args.KeyModifiers ()),
20422054 pixelPosition);
20432055
2056+ if (_isPanning && _panningAnchorPos)
2057+ {
2058+ const auto dy = cursorPosition.Y - _panningAnchorPos->Y ;
2059+ constexpr auto MinPanDist = 5.0 ;
2060+
2061+ if (const auto window = CoreWindow::GetForCurrentThread ())
2062+ {
2063+ if (std::abs (dy) > MinPanDist)
2064+ {
2065+ window.PointerCursor (CoreCursor (CoreCursorType::SizeNorthSouth, 1 ));
2066+ }
2067+ else
2068+ {
2069+ window.PointerCursor (CoreCursor (CoreCursorType::SizeAll, 1 ));
2070+ }
2071+ }
2072+
2073+ if (std::abs (dy) > MinPanDist)
2074+ {
2075+ const auto scrollDist = dy > 0 ? (dy - MinPanDist) : (dy + MinPanDist);
2076+ const auto newVelocity = _GetAutoScrollSpeed (std::abs (scrollDist)) * (dy > 0 ? 1.0 : -1.0 );
2077+ _TryStartAutoScroll (point, newVelocity);
2078+ }
2079+ else
2080+ {
2081+ _TryStopAutoScroll (ptr.PointerId ());
2082+ }
2083+ }
20442084 // GH#9109 - Only start an auto-scroll when the drag actually
20452085 // started within our bounds. Otherwise, someone could start a drag
20462086 // outside the terminal control, drag into the padding, and trick us
20472087 // into starting to scroll.
2048- if (!suppressFurtherHandling && _focused && _pointerPressedInBounds && point.Properties ().IsLeftButtonPressed ())
2088+ else if (!suppressFurtherHandling && _focused && _pointerPressedInBounds && point.Properties ().IsLeftButtonPressed ())
20492089 {
20502090 // We want to find the distance relative to the bounds of the
20512091 // SwapChainPanel, not the entire control. If they drag out of
@@ -2124,6 +2164,16 @@ namespace winrt::Microsoft::Terminal::Control::implementation
21242164 _interactivity.TouchReleased ();
21252165 }
21262166
2167+ if (_isPanning)
2168+ {
2169+ _isPanning = false ;
2170+ _panningAnchorPos = std::nullopt ;
2171+ if (const auto window = CoreWindow::GetForCurrentThread ())
2172+ {
2173+ window.PointerCursor (CoreCursor (CoreCursorType::IBeam, 1 ));
2174+ }
2175+ }
2176+
21272177 _TryStopAutoScroll (ptr.PointerId ());
21282178
21292179 args.Handled (true );
0 commit comments