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

Commit 5ea7ea44 authored by Michael Wright's avatar Michael Wright Committed by Android (Google) Code Review
Browse files

Merge "DO NOT MERGE. Cancel touches as well as pointer gestures." into cw-d-mr1-dev

parents e6406e35 e6f6ad04
Loading
Loading
Loading
Loading
+26 −3
Original line number Diff line number Diff line
@@ -3721,6 +3721,7 @@ void TouchInputMapper::reset(nsecs_t when) {
    mLastMouseIdBits.clear();
    mPointerUsage = POINTER_USAGE_NONE;
    mSentHoverEnter = false;
    mCurrentMotionAborted = false;
    mDownTime = 0;

    mCurrentVirtualKey.down = false;
@@ -3874,12 +3875,17 @@ void TouchInputMapper::sync(nsecs_t when) {
                        mCurrentCookedPointerData.idToIndex,
                        mCurrentCookedPointerData.touchingIdBits);
            }

            if (!mCurrentMotionAborted) {
                dispatchHoverExit(when, policyFlags);
                dispatchTouches(when, policyFlags);
                dispatchHoverEnterAndMove(when, policyFlags);
            }

            if (mCurrentCookedPointerData.pointerCount == 0) {
                mCurrentMotionAborted = false;
            }
        }

        // Synthesize key up from raw buttons if needed.
        synthesizeButtonKeys(getContext(), AKEY_EVENT_ACTION_UP, when, getDeviceId(), mSource,
                policyFlags, mLastButtonState, mCurrentButtonState);
@@ -4018,6 +4024,22 @@ void TouchInputMapper::dispatchVirtualKey(nsecs_t when, uint32_t policyFlags,
    getListener()->notifyKey(&args);
}

void TouchInputMapper::abortTouches(nsecs_t when, uint32_t policyFlags) {
    BitSet32 currentIdBits = mCurrentCookedPointerData.touchingIdBits;
    if (!currentIdBits.isEmpty()) {
        int32_t metaState = getContext()->getGlobalMetaState();
        int32_t buttonState = mCurrentButtonState;
        dispatchMotion(when, policyFlags, mSource, AMOTION_EVENT_ACTION_CANCEL, 0,
                metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE,
                mCurrentCookedPointerData.pointerProperties,
                mCurrentCookedPointerData.pointerCoords,
                mCurrentCookedPointerData.idToIndex,
                currentIdBits, -1,
                mOrientedXPrecision, mOrientedYPrecision, mDownTime);
        mCurrentMotionAborted = true;
    }
}

void TouchInputMapper::dispatchTouches(nsecs_t when, uint32_t policyFlags) {
    BitSet32 currentIdBits = mCurrentCookedPointerData.touchingIdBits;
    BitSet32 lastIdBits = mLastCookedPointerData.touchingIdBits;
@@ -5733,6 +5755,7 @@ void TouchInputMapper::fadePointer() {

void TouchInputMapper::cancelTouch(nsecs_t when) {
    abortPointerUsage(when, 0 /*policyFlags*/);
    abortTouches(when, 0 /* policyFlags*/);
}

bool TouchInputMapper::isPointInsideSurface(int32_t x, int32_t y) {
+4 −0
Original line number Diff line number Diff line
@@ -1364,6 +1364,9 @@ protected:
    // True if we sent a HOVER_ENTER event.
    bool mSentHoverEnter;

    // Is the current stream of direct touch events aborted
    bool mCurrentMotionAborted;

    // The time the primary pointer last went down.
    nsecs_t mDownTime;

@@ -1688,6 +1691,7 @@ private:

    void dispatchPointerUsage(nsecs_t when, uint32_t policyFlags, PointerUsage pointerUsage);
    void abortPointerUsage(nsecs_t when, uint32_t policyFlags);
    void abortTouches(nsecs_t when, uint32_t policyFlags);

    void dispatchPointerGestures(nsecs_t when, uint32_t policyFlags, bool isTimeout);
    void abortPointerGestures(nsecs_t when, uint32_t policyFlags);