Skip to content

Commit

Permalink
Adjust event location when two-finger dragging in TouchExplorer
Browse files Browse the repository at this point in the history
To scroll on the screen when using TalkBack, a user need to dragging two
finger pointers. If the dragging pointer are closer that a given distance
we use the location of the primary one. Otherwise, we should adjust the
event location to take the middle between the two finger pointers.

Bug: 126354276
Test: atest TouchExplorerTest
Change-Id: I9e95ccec964d7930498febdd02731b94826fbb7b
  • Loading branch information
mincheli committed Apr 25, 2019
1 parent c37d832 commit b7507a9
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -703,12 +703,17 @@ private void handleMotionEventStateDragging(MotionEvent event, int policyFlags)
final float secondPtrX = event.getX(1);
final float secondPtrY = event.getY(1);

final float deltaX = firstPtrX - secondPtrX;
final float deltaY = firstPtrY - secondPtrY;
final int pointerIndex = event.findPointerIndex(mDraggingPointerId);
final float deltaX =
(pointerIndex == 0) ? (secondPtrX - firstPtrX)
: (firstPtrX - secondPtrX);
final float deltaY =
(pointerIndex == 0) ? (secondPtrY - firstPtrY)
: (firstPtrY - secondPtrY);
final double distance = Math.hypot(deltaX, deltaY);

if (distance > mScaledMinPointerDistanceToUseMiddleLocation) {
event.setLocation(deltaX / 2, deltaY / 2);
event.offsetLocation(deltaX / 2, deltaY / 2);
}

// If still dragging send a drag event.
Expand Down

0 comments on commit b7507a9

Please sign in to comment.