Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b7507a99 authored by mincheli's avatar mincheli
Browse files

Adjust event location when two-finger dragging in TouchExplorer

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
parent c37d8321
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -703,12 +703,17 @@ class TouchExplorer extends BaseEventStreamTransformation
                            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.