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

Commit 1f693f3f authored by Harry Cutts's avatar Harry Cutts
Browse files

GestureConverter: remove checks on choreographer flag

The only reason it needed to check the flag was when calling
mPointerController->getPosition, but since change
I475f3286c83b90e161e186e62c2842e539434603 that method handles the check
itself.

Bug: 245989146
Test: manual tests of movement and gestures with an Apple Magic Trackpad
Test: atest inputflinger_tests:GestureConverterTest \
            inputflinger_tests:GestureConverterTestWithChoreographer
Change-Id: I2ba46ba863ba8cd3a6caa94ec0dfafa7273df97b
parent 3beea7dc
Loading
Loading
Loading
Loading
+12 −24
Original line number Diff line number Diff line
@@ -67,7 +67,6 @@ GestureConverter::GestureConverter(InputReaderContext& readerContext,
      : mDeviceId(deviceId),
        mReaderContext(readerContext),
        mPointerController(readerContext.getPointerController(deviceId)),
        mEnablePointerChoreographer(input_flags::enable_pointer_choreographer()),
        mEnableFlingStop(input_flags::enable_touchpad_fling_stop()) {
    deviceContext.getAbsoluteAxisInfo(ABS_MT_POSITION_X, &mXAxisInfo);
    deviceContext.getAbsoluteAxisInfo(ABS_MT_POSITION_Y, &mYAxisInfo);
@@ -175,8 +174,7 @@ std::list<NotifyArgs> GestureConverter::handleMove(nsecs_t when, nsecs_t readTim
                                                   const Gesture& gesture) {
    float deltaX = gesture.details.move.dx;
    float deltaY = gesture.details.move.dy;
    const auto [oldXCursorPosition, oldYCursorPosition] =
            mEnablePointerChoreographer ? FloatPoint{0, 0} : mPointerController->getPosition();
    const auto [oldXCursorPosition, oldYCursorPosition] = mPointerController->getPosition();
    if (ENABLE_TOUCHPAD_PALM_REJECTION_V2) {
        bool wasHoverCancelled = mIsHoverCancelled;
        // Gesture will be cancelled if it started before the user started typing and
@@ -214,8 +212,7 @@ std::list<NotifyArgs> GestureConverter::handleMove(nsecs_t when, nsecs_t readTim
    if (!down) {
        out += enterHover(when, readTime, oldXCursorPosition, oldYCursorPosition);
    }
    const auto [newXCursorPosition, newYCursorPosition] =
            mEnablePointerChoreographer ? FloatPoint{0, 0} : mPointerController->getPosition();
    const auto [newXCursorPosition, newYCursorPosition] = mPointerController->getPosition();

    PointerCoords coords;
    coords.clear();
@@ -239,8 +236,7 @@ std::list<NotifyArgs> GestureConverter::handleButtonsChange(nsecs_t when, nsecs_
    mPointerController->setPresentation(PointerControllerInterface::Presentation::POINTER);
    mPointerController->unfade(PointerControllerInterface::Transition::IMMEDIATE);

    const auto [xCursorPosition, yCursorPosition] =
            mEnablePointerChoreographer ? FloatPoint{0, 0} : mPointerController->getPosition();
    const auto [xCursorPosition, yCursorPosition] = mPointerController->getPosition();

    PointerCoords coords;
    coords.clear();
@@ -320,8 +316,7 @@ std::list<NotifyArgs> GestureConverter::handleButtonsChange(nsecs_t when, nsecs_

std::list<NotifyArgs> GestureConverter::releaseAllButtons(nsecs_t when, nsecs_t readTime) {
    std::list<NotifyArgs> out;
    const auto [xCursorPosition, yCursorPosition] =
            mEnablePointerChoreographer ? FloatPoint{0, 0} : mPointerController->getPosition();
    const auto [xCursorPosition, yCursorPosition] = mPointerController->getPosition();

    PointerCoords coords;
    coords.clear();
@@ -356,8 +351,7 @@ std::list<NotifyArgs> GestureConverter::handleScroll(nsecs_t when, nsecs_t readT
                                                     const Gesture& gesture) {
    std::list<NotifyArgs> out;
    PointerCoords& coords = mFakeFingerCoords[0];
    const auto [xCursorPosition, yCursorPosition] =
            mEnablePointerChoreographer ? FloatPoint{0, 0} : mPointerController->getPosition();
    const auto [xCursorPosition, yCursorPosition] = mPointerController->getPosition();
    if (mCurrentClassification != MotionClassification::TWO_FINGER_SWIPE) {
        out += exitHover(when, readTime, xCursorPosition, yCursorPosition);

@@ -415,9 +409,8 @@ std::list<NotifyArgs> GestureConverter::handleFling(nsecs_t when, nsecs_t readTi
                    // avoid side effects (e.g. activation of UI elements).
                    // TODO(b/326056750): add an API for fling stops.
                    mFlingMayBeInProgress = false;
                    const auto [xCursorPosition, yCursorPosition] = mEnablePointerChoreographer
                            ? FloatPoint{0, 0}
                            : mPointerController->getPosition();
                    const auto [xCursorPosition, yCursorPosition] =
                            mPointerController->getPosition();
                    PointerCoords coords;
                    coords.clear();
                    coords.setAxisValue(AMOTION_EVENT_AXIS_X, xCursorPosition);
@@ -461,8 +454,7 @@ std::list<NotifyArgs> GestureConverter::handleFling(nsecs_t when, nsecs_t readTi

std::list<NotifyArgs> GestureConverter::endScroll(nsecs_t when, nsecs_t readTime) {
    std::list<NotifyArgs> out;
    const auto [xCursorPosition, yCursorPosition] =
            mEnablePointerChoreographer ? FloatPoint{0, 0} : mPointerController->getPosition();
    const auto [xCursorPosition, yCursorPosition] = mPointerController->getPosition();
    mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_GESTURE_SCROLL_X_DISTANCE, 0);
    mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_GESTURE_SCROLL_Y_DISTANCE, 0);
    NotifyMotionArgs args =
@@ -482,8 +474,7 @@ std::list<NotifyArgs> GestureConverter::endScroll(nsecs_t when, nsecs_t readTime
                                                                             float dx, float dy) {
    std::list<NotifyArgs> out = {};

    const auto [xCursorPosition, yCursorPosition] =
            mEnablePointerChoreographer ? FloatPoint{0, 0} : mPointerController->getPosition();
    const auto [xCursorPosition, yCursorPosition] = mPointerController->getPosition();
    if (mCurrentClassification != MotionClassification::MULTI_FINGER_SWIPE) {
        // If the user changes the number of fingers mid-way through a swipe (e.g. they start with
        // three and then put a fourth finger down), the gesture library will treat it as two
@@ -547,8 +538,7 @@ std::list<NotifyArgs> GestureConverter::endScroll(nsecs_t when, nsecs_t readTime
    if (mCurrentClassification != MotionClassification::MULTI_FINGER_SWIPE) {
        return out;
    }
    const auto [xCursorPosition, yCursorPosition] =
            mEnablePointerChoreographer ? FloatPoint{0, 0} : mPointerController->getPosition();
    const auto [xCursorPosition, yCursorPosition] = mPointerController->getPosition();
    mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_GESTURE_X_OFFSET, 0);
    mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_GESTURE_Y_OFFSET, 0);

@@ -571,8 +561,7 @@ std::list<NotifyArgs> GestureConverter::endScroll(nsecs_t when, nsecs_t readTime

[[nodiscard]] std::list<NotifyArgs> GestureConverter::handlePinch(nsecs_t when, nsecs_t readTime,
                                                                  const Gesture& gesture) {
    const auto [xCursorPosition, yCursorPosition] =
            mEnablePointerChoreographer ? FloatPoint{0, 0} : mPointerController->getPosition();
    const auto [xCursorPosition, yCursorPosition] = mPointerController->getPosition();

    // Pinch gesture phases are reported a little differently from others, in that the same details
    // struct is used for all phases of the gesture, just with different zoom_state values. When
@@ -630,8 +619,7 @@ std::list<NotifyArgs> GestureConverter::endScroll(nsecs_t when, nsecs_t readTime

std::list<NotifyArgs> GestureConverter::endPinch(nsecs_t when, nsecs_t readTime) {
    std::list<NotifyArgs> out;
    const auto [xCursorPosition, yCursorPosition] =
            mEnablePointerChoreographer ? FloatPoint{0, 0} : mPointerController->getPosition();
    const auto [xCursorPosition, yCursorPosition] = mPointerController->getPosition();

    mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_GESTURE_PINCH_SCALE_FACTOR, 1.0);
    out.push_back(makeMotionArgs(when, readTime,
+0 −1
Original line number Diff line number Diff line
@@ -105,7 +105,6 @@ private:
    const int32_t mDeviceId;
    InputReaderContext& mReaderContext;
    std::shared_ptr<PointerControllerInterface> mPointerController;
    const bool mEnablePointerChoreographer;
    const bool mEnableFlingStop;

    std::optional<int32_t> mDisplayId;