summaryrefslogtreecommitdiffstats
path: root/services/inputflinger/InputReader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'services/inputflinger/InputReader.cpp')
-rw-r--r--services/inputflinger/InputReader.cpp40
1 files changed, 32 insertions, 8 deletions
diff --git a/services/inputflinger/InputReader.cpp b/services/inputflinger/InputReader.cpp
index f3cb0e6..36095bf 100644
--- a/services/inputflinger/InputReader.cpp
+++ b/services/inputflinger/InputReader.cpp
@@ -3860,6 +3860,7 @@ void TouchInputMapper::reset(nsecs_t when) {
mPointerUsage = POINTER_USAGE_NONE;
mSentHoverEnter = false;
mHavePointerIds = false;
+ mCurrentMotionAborted = false;
mDownTime = 0;
mCurrentVirtualKey.down = false;
@@ -4087,11 +4088,17 @@ void TouchInputMapper::cookAndDispatch(nsecs_t when) {
mCurrentCookedState.cookedPointerData.touchingIdBits);
}
- dispatchButtonRelease(when, policyFlags);
- dispatchHoverExit(when, policyFlags);
- dispatchTouches(when, policyFlags);
- dispatchHoverEnterAndMove(when, policyFlags);
- dispatchButtonPress(when, policyFlags);
+ if (!mCurrentMotionAborted) {
+ dispatchButtonRelease(when, policyFlags);
+ dispatchHoverExit(when, policyFlags);
+ dispatchTouches(when, policyFlags);
+ dispatchHoverEnterAndMove(when, policyFlags);
+ dispatchButtonPress(when, policyFlags);
+ }
+
+ if (mCurrentCookedState.cookedPointerData.pointerCount == 0) {
+ mCurrentMotionAborted = false;
+ }
}
// Synthesize key up from raw buttons if needed.
@@ -4316,6 +4323,22 @@ void TouchInputMapper::dispatchVirtualKey(nsecs_t when, uint32_t policyFlags,
getListener()->notifyKey(&args);
}
+void TouchInputMapper::abortTouches(nsecs_t when, uint32_t policyFlags) {
+ BitSet32 currentIdBits = mCurrentCookedState.cookedPointerData.touchingIdBits;
+ if (!currentIdBits.isEmpty()) {
+ int32_t metaState = getContext()->getGlobalMetaState();
+ int32_t buttonState = mCurrentCookedState.buttonState;
+ dispatchMotion(when, policyFlags, mSource, AMOTION_EVENT_ACTION_CANCEL, 0, 0,
+ metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE,
+ mCurrentCookedState.cookedPointerData.pointerProperties,
+ mCurrentCookedState.cookedPointerData.pointerCoords,
+ mCurrentCookedState.cookedPointerData.idToIndex,
+ currentIdBits, -1,
+ mOrientedXPrecision, mOrientedYPrecision, mDownTime);
+ mCurrentMotionAborted = true;
+ }
+}
+
void TouchInputMapper::dispatchTouches(nsecs_t when, uint32_t policyFlags) {
BitSet32 currentIdBits = mCurrentCookedState.cookedPointerData.touchingIdBits;
BitSet32 lastIdBits = mLastCookedState.cookedPointerData.touchingIdBits;
@@ -4676,7 +4699,7 @@ void TouchInputMapper::cookPointerData() {
bottom = float(mRawPointerAxes.x.maxValue - rawLeft) * mXScale + mXTranslate;
top = float(mRawPointerAxes.x.maxValue - rawRight) * mXScale + mXTranslate;
orientation -= M_PI_2;
- if (orientation < mOrientedRanges.orientation.min) {
+ if (mOrientedRanges.haveOrientation && orientation < mOrientedRanges.orientation.min) {
orientation += (mOrientedRanges.orientation.max - mOrientedRanges.orientation.min);
}
break;
@@ -4688,7 +4711,7 @@ void TouchInputMapper::cookPointerData() {
bottom = float(mRawPointerAxes.y.maxValue - rawTop) * mYScale + mYTranslate;
top = float(mRawPointerAxes.y.maxValue - rawBottom) * mYScale + mYTranslate;
orientation -= M_PI;
- if (orientation < mOrientedRanges.orientation.min) {
+ if (mOrientedRanges.haveOrientation && orientation < mOrientedRanges.orientation.min) {
orientation += (mOrientedRanges.orientation.max - mOrientedRanges.orientation.min);
}
break;
@@ -4700,7 +4723,7 @@ void TouchInputMapper::cookPointerData() {
bottom = float(rawRight - mRawPointerAxes.x.minValue) * mXScale + mXTranslate;
top = float(rawLeft - mRawPointerAxes.x.minValue) * mXScale + mXTranslate;
orientation += M_PI_2;
- if (orientation > mOrientedRanges.orientation.max) {
+ if (mOrientedRanges.haveOrientation && orientation > mOrientedRanges.orientation.max) {
orientation -= (mOrientedRanges.orientation.max - mOrientedRanges.orientation.min);
}
break;
@@ -6089,6 +6112,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) {