Skip to content

Commit

Permalink
Fixes #4603
Browse files Browse the repository at this point in the history
  Kinda the same thing. Don't modify the selection if the pointer down drag
  didn't even start in the control to begin with.
  • Loading branch information
zadjii-msft committed Jul 13, 2021
1 parent 3d30295 commit 2aaae9e
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
9 changes: 7 additions & 2 deletions src/cascadia/TerminalControl/ControlInteractivity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
const unsigned int pointerUpdateKind,
const ::Microsoft::Terminal::Core::ControlKeyStates modifiers,
const bool focused,
const til::point pixelPosition)
const til::point pixelPosition,
const bool pointerPressedInBounds)
{
const til::point terminalPosition = _getTerminalPosition(pixelPosition);

Expand All @@ -283,7 +284,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation
{
_core->SendMouseEvent(terminalPosition, pointerUpdateKind, modifiers, 0, toInternalMouseState(buttonState));
}
else if (focused && WI_IsFlagSet(buttonState, MouseButtonState::IsLeftButtonDown))
// GH#4603 - don't modify the selection if the pointer press didn't
// actually start _in_ the control bounds. Case in point - someone drags
// a file into the bounds of the control. That shouldn't send the
// selection into space.
else if (focused && pointerPressedInBounds && WI_IsFlagSet(buttonState, MouseButtonState::IsLeftButtonDown))
{
if (_singleClickTouchdownPos)
{
Expand Down
3 changes: 2 additions & 1 deletion src/cascadia/TerminalControl/ControlInteractivity.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
const unsigned int pointerUpdateKind,
const ::Microsoft::Terminal::Core::ControlKeyStates modifiers,
const bool focused,
const til::point pixelPosition);
const til::point pixelPosition,
const bool pointerPressedInBounds);
void TouchMoved(const til::point newTouchPoint,
const bool focused);

Expand Down
3 changes: 2 additions & 1 deletion src/cascadia/TerminalControl/ControlInteractivity.idl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ namespace Microsoft.Terminal.Control
UInt32 pointerUpdateKind,
Microsoft.Terminal.Core.ControlKeyStates modifiers,
Boolean focused,
Microsoft.Terminal.Core.Point pixelPosition);
Microsoft.Terminal.Core.Point pixelPosition,
Boolean pointerPressedInBounds);
void TouchMoved(Microsoft.Terminal.Core.Point newTouchPoint,
Boolean focused);

Expand Down
3 changes: 2 additions & 1 deletion src/cascadia/TerminalControl/TermControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
TermControl::GetPointerUpdateKind(point),
ControlKeyStates(args.KeyModifiers()),
_focused,
pixelPosition);
pixelPosition,
_pointerPressedInBounds);

// GH#9109 - Only start an auto-scroll when the drag actually
// started within our bounds. Otherwise, someone could start a drag
Expand Down
15 changes: 10 additions & 5 deletions src/cascadia/UnitTests_Control/ControlInteractivityTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ namespace ControlUnitTests
WM_LBUTTONDOWN, //pointerUpdateKind
modifiers,
true, // focused,
cursorPosition1);
cursorPosition1,
true);
Log::Comment(L"Verify that there's one selection");
VERIFY_IS_TRUE(core->HasSelection());
VERIFY_ARE_EQUAL(1u, core->_terminal->GetSelectionRects().size());
Expand All @@ -299,7 +300,8 @@ namespace ControlUnitTests
WM_LBUTTONDOWN, //pointerUpdateKind
modifiers,
true, // focused,
cursorPosition2);
cursorPosition2,
true);
Log::Comment(L"Verify that there's now two selections (one on each row)");
VERIFY_IS_TRUE(core->HasSelection());
VERIFY_ARE_EQUAL(2u, core->_terminal->GetSelectionRects().size());
Expand Down Expand Up @@ -332,7 +334,8 @@ namespace ControlUnitTests
WM_LBUTTONDOWN, //pointerUpdateKind
modifiers,
true, // focused,
cursorPosition4);
cursorPosition4,
true);
Log::Comment(L"Verify that there's now one selection");
VERIFY_IS_TRUE(core->HasSelection());
VERIFY_ARE_EQUAL(1u, core->_terminal->GetSelectionRects().size());
Expand Down Expand Up @@ -387,7 +390,8 @@ namespace ControlUnitTests
WM_LBUTTONDOWN, //pointerUpdateKind
modifiers,
true, // focused,
cursorPosition1);
cursorPosition1,
true);
Log::Comment(L"Verify that there's one selection");
VERIFY_IS_TRUE(core->HasSelection());
VERIFY_ARE_EQUAL(1u, core->_terminal->GetSelectionRects().size());
Expand Down Expand Up @@ -535,7 +539,8 @@ namespace ControlUnitTests
WM_LBUTTONDOWN, //pointerUpdateKind
modifiers,
true, // focused,
cursorPosition1);
cursorPosition1,
true);
Log::Comment(L"Verify that there's one selection");
VERIFY_IS_TRUE(core->HasSelection());
VERIFY_ARE_EQUAL(1u, core->_terminal->GetSelectionRects().size());
Expand Down

1 comment on commit 2aaae9e

@github-actions

This comment was marked as outdated.

Please sign in to comment.