DO NOT MERGE. Cancel touches as well as pointer gestures.

Bug: 19264992
Change-Id: If48e0953b972c9d69f516906adf7c6faf67e3eb8
This commit is contained in:
Michael Wright 2015-06-22 16:18:21 +01:00
parent 35851e2abb
commit e6f6ad04ed
2 changed files with 30 additions and 3 deletions

View File

@ -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,10 +3875,15 @@ void TouchInputMapper::sync(nsecs_t when) {
mCurrentCookedPointerData.idToIndex,
mCurrentCookedPointerData.touchingIdBits);
}
if (!mCurrentMotionAborted) {
dispatchHoverExit(when, policyFlags);
dispatchTouches(when, policyFlags);
dispatchHoverEnterAndMove(when, policyFlags);
}
dispatchHoverExit(when, policyFlags);
dispatchTouches(when, policyFlags);
dispatchHoverEnterAndMove(when, policyFlags);
if (mCurrentCookedPointerData.pointerCount == 0) {
mCurrentMotionAborted = false;
}
}
// Synthesize key up from raw buttons if needed.
@ -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) {

View File

@ -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);