Skip to content

Commit b55fee5

Browse files
committed
Allow Interactivity to suppress autoscroll
This will need to be undone when we move timers and autoscroll down.
1 parent b3f4162 commit b55fee5

File tree

5 files changed

+46
-16
lines changed

5 files changed

+46
-16
lines changed

src/cascadia/TerminalControl/ControlInteractivity.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,14 +334,17 @@ namespace winrt::Microsoft::Terminal::Control::implementation
334334
const ::Microsoft::Terminal::Core::ControlKeyStates modifiers,
335335
const bool focused,
336336
const Core::Point pixelPosition,
337-
const bool pointerPressedInBounds)
337+
const bool pointerPressedInBounds,
338+
bool& suppressFurtherHandling)
338339
{
339340
const auto terminalPosition = _getTerminalPosition(til::point{ pixelPosition });
341+
suppressFurtherHandling = false;
340342

341343
// Short-circuit isReadOnly check to avoid warning dialog
342344
if (focused && !_core->IsInReadOnlyMode() && _canSendVTMouseInput(modifiers))
343345
{
344346
_sendMouseEventHelper(terminalPosition, pointerUpdateKind, modifiers, 0, buttonState);
347+
suppressFurtherHandling = true;
345348
}
346349
// GH#4603 - don't modify the selection if the pointer press didn't
347350
// actually start _in_ the control bounds. Case in point - someone drags

src/cascadia/TerminalControl/ControlInteractivity.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
6363
const ::Microsoft::Terminal::Core::ControlKeyStates modifiers,
6464
const bool focused,
6565
const Core::Point pixelPosition,
66-
const bool pointerPressedInBounds);
66+
const bool pointerPressedInBounds,
67+
bool& suppressFurtherHandling);
6768
void TouchMoved(const Core::Point newTouchPoint,
6869
const bool focused);
6970

src/cascadia/TerminalControl/ControlInteractivity.idl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ namespace Microsoft.Terminal.Control
4848
Microsoft.Terminal.Core.ControlKeyStates modifiers,
4949
Boolean focused,
5050
Microsoft.Terminal.Core.Point pixelPosition,
51-
Boolean pointerPressedInBounds);
51+
Boolean pointerPressedInBounds,
52+
out Boolean suppressFurtherHandling);
5253

5354
void TouchMoved(Microsoft.Terminal.Core.Point newTouchPoint,
5455
Boolean focused);

src/cascadia/TerminalControl/TermControl.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1910,18 +1910,20 @@ namespace winrt::Microsoft::Terminal::Control::implementation
19101910
if (type == Windows::Devices::Input::PointerDeviceType::Mouse ||
19111911
type == Windows::Devices::Input::PointerDeviceType::Pen)
19121912
{
1913+
bool suppressFurtherHandling{ false };
19131914
_interactivity.PointerMoved(TermControl::GetPressedMouseButtons(point),
19141915
TermControl::GetPointerUpdateKind(point),
19151916
ControlKeyStates(args.KeyModifiers()),
19161917
_focused,
19171918
pixelPosition.to_core_point(),
1918-
_pointerPressedInBounds);
1919+
_pointerPressedInBounds,
1920+
/* out */ suppressFurtherHandling);
19191921

19201922
// GH#9109 - Only start an auto-scroll when the drag actually
19211923
// started within our bounds. Otherwise, someone could start a drag
19221924
// outside the terminal control, drag into the padding, and trick us
19231925
// into starting to scroll.
1924-
if (_focused && _pointerPressedInBounds && point.Properties().IsLeftButtonPressed())
1926+
if (!suppressFurtherHandling && _focused && _pointerPressedInBounds && point.Properties().IsLeftButtonPressed())
19251927
{
19261928
// We want to find the distance relative to the bounds of the
19271929
// SwapChainPanel, not the entire control. If they drag out of

src/cascadia/UnitTests_Control/ControlInteractivityTests.cpp

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,8 @@ namespace ControlUnitTests
298298
TEST_METHOD_PROPERTY(L"IsolationLevel", L"Method")
299299
END_TEST_METHOD_PROPERTIES()
300300

301+
bool unused{};
302+
301303
// This is a test for GH#9725
302304
WEX::TestExecution::DisableVerifyExceptions disableVerifyExceptions{};
303305

@@ -333,7 +335,8 @@ namespace ControlUnitTests
333335
modifiers,
334336
true, // focused,
335337
cursorPosition1.to_core_point(),
336-
true);
338+
true,
339+
unused);
337340
Log::Comment(L"Verify that there's one selection");
338341
VERIFY_IS_TRUE(core->HasSelection());
339342

@@ -345,7 +348,8 @@ namespace ControlUnitTests
345348
modifiers,
346349
true, // focused,
347350
cursorPosition2.to_core_point(),
348-
true);
351+
true,
352+
unused);
349353
Log::Comment(L"Verify that there's now two selections (one on each row)");
350354
VERIFY_IS_TRUE(core->HasSelection());
351355

@@ -376,7 +380,8 @@ namespace ControlUnitTests
376380
modifiers,
377381
true, // focused,
378382
cursorPosition4.to_core_point(),
379-
true);
383+
true,
384+
unused);
380385
Log::Comment(L"Verify that there's now one selection");
381386
VERIFY_IS_TRUE(core->HasSelection());
382387
}
@@ -390,6 +395,8 @@ namespace ControlUnitTests
390395
// For the sake of this test, scroll one line at a time
391396
interactivity->_rowsToScroll = 1;
392397

398+
bool unused{};
399+
393400
Log::Comment(L"Add some test to the terminal so we can scroll");
394401
for (auto i = 0; i < 40; ++i)
395402
{
@@ -430,7 +437,8 @@ namespace ControlUnitTests
430437
modifiers,
431438
true, // focused,
432439
cursorPosition1.to_core_point(),
433-
true);
440+
true,
441+
unused);
434442
Log::Comment(L"Verify that there's one selection");
435443
VERIFY_IS_TRUE(core->HasSelection());
436444

@@ -550,6 +558,8 @@ namespace ControlUnitTests
550558
auto [core, interactivity] = _createCoreAndInteractivity(*settings, *conn);
551559
_standardInit(core, interactivity);
552560

561+
bool unused{};
562+
553563
// For this test, don't use any modifiers
554564
const auto modifiers = ControlKeyStates();
555565
const auto leftMouseDown{ Control::MouseButtonState::IsLeftButtonDown };
@@ -577,7 +587,8 @@ namespace ControlUnitTests
577587
modifiers,
578588
true, // focused,
579589
cursorPosition1.to_core_point(),
580-
true);
590+
true,
591+
unused);
581592
Log::Comment(L"Verify that there's one selection");
582593
VERIFY_IS_TRUE(core->HasSelection());
583594

@@ -594,6 +605,8 @@ namespace ControlUnitTests
594605
auto [core, interactivity] = _createCoreAndInteractivity(*settings, *conn);
595606
_standardInit(core, interactivity);
596607

608+
bool unused {}
609+
597610
// For this test, don't use any modifiers
598611
const auto modifiers = ControlKeyStates();
599612
const auto leftMouseDown{ Control::MouseButtonState::IsLeftButtonDown };
@@ -621,7 +634,8 @@ namespace ControlUnitTests
621634
modifiers,
622635
true, // focused,
623636
cursorPosition1.to_core_point(),
624-
true);
637+
true,
638+
unused);
625639
Log::Comment(L"Verify that there's one selection");
626640
VERIFY_IS_TRUE(core->HasSelection());
627641

@@ -646,7 +660,8 @@ namespace ControlUnitTests
646660
modifiers,
647661
true, // focused,
648662
cursorPosition2.to_core_point(),
649-
false);
663+
false,
664+
unused);
650665

651666
Log::Comment(L"The selection should be unchanged.");
652667
VERIFY_ARE_EQUAL(expectedAnchor, core->_terminal->GetSelectionAnchor());
@@ -662,6 +677,8 @@ namespace ControlUnitTests
662677
auto [core, interactivity] = _createCoreAndInteractivity(*settings, *conn);
663678
_standardInit(core, interactivity);
664679

680+
bool unused{};
681+
665682
// For this test, don't use any modifiers
666683
const auto modifiers = ControlKeyStates();
667684
const auto leftMouseDown{ Control::MouseButtonState::IsLeftButtonDown };
@@ -737,7 +754,8 @@ namespace ControlUnitTests
737754
modifiers,
738755
true, // focused,
739756
cursorPosition1.to_core_point(),
740-
true);
757+
true,
758+
unused);
741759
Log::Comment(L"Verify that there's still no selection");
742760
VERIFY_IS_FALSE(core->HasSelection());
743761
}
@@ -751,6 +769,8 @@ namespace ControlUnitTests
751769
auto [core, interactivity] = _createCoreAndInteractivity(*settings, *conn);
752770
_standardInit(core, interactivity);
753771

772+
bool unused{};
773+
754774
Log::Comment(L"Fill up the history buffer");
755775
const auto scrollbackLength = settings->HistorySize();
756776
// Output lines equal to history size + viewport height to make sure we're
@@ -790,7 +810,8 @@ namespace ControlUnitTests
790810
modifiers,
791811
true, // focused,
792812
cursorPosition1.to_core_point(),
793-
true);
813+
true,
814+
unused);
794815
Log::Comment(L"Verify that there's one selection");
795816
VERIFY_IS_TRUE(core->HasSelection());
796817

@@ -849,7 +870,8 @@ namespace ControlUnitTests
849870
modifiers,
850871
true, // focused,
851872
cursorPosition0.to_core_point(),
852-
true);
873+
true,
874+
unused);
853875
VERIFY_IS_TRUE(core->HasSelection());
854876
{
855877
const auto anchor{ core->_terminal->GetSelectionAnchor() };
@@ -873,7 +895,8 @@ namespace ControlUnitTests
873895
modifiers,
874896
true, // focused,
875897
cursorPosition1.to_core_point(),
876-
true);
898+
true,
899+
unused);
877900
VERIFY_IS_TRUE(core->HasSelection());
878901
{
879902
const auto anchor{ core->_terminal->GetSelectionAnchor() };

0 commit comments

Comments
 (0)