From f2ad1a442bd85bd6ae0c5fd47701ec7dfa91c1f9 Mon Sep 17 00:00:00 2001 From: tingna_sung Date: Tue, 21 Oct 2014 17:09:57 +0800 Subject: [PATCH] Measure absolute value of pointer motion distance If pointer is moving to the negative axis direction, pointer movement distance will always less than pre-defined mMotionSlop, thus TAP_OUTSIDE_STACK will have chance to be sent, will cause unnecessary focus stack switch. Change-Id: Ia4c066bebce250257c7361ef976907a0ca2c6461 Signed-off-by: tingna_sung --- .../java/com/android/server/wm/StackTapPointerEventListener.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/wm/StackTapPointerEventListener.java b/services/core/java/com/android/server/wm/StackTapPointerEventListener.java index 19d8ab372afe..75734002dbc9 100644 --- a/services/core/java/com/android/server/wm/StackTapPointerEventListener.java +++ b/services/core/java/com/android/server/wm/StackTapPointerEventListener.java @@ -57,8 +57,8 @@ public class StackTapPointerEventListener implements PointerEventListener { if (mPointerId >= 0) { int index = motionEvent.findPointerIndex(mPointerId); if ((motionEvent.getEventTime() - motionEvent.getDownTime()) > TAP_TIMEOUT_MSEC - || (motionEvent.getX(index) - mDownX) > mMotionSlop - || (motionEvent.getY(index) - mDownY) > mMotionSlop) { + || Math.abs(motionEvent.getX(index) - mDownX) > mMotionSlop + || Math.abs(motionEvent.getY(index) - mDownY) > mMotionSlop) { mPointerId = -1; } } @@ -73,7 +73,8 @@ public class StackTapPointerEventListener implements PointerEventListener { final int y = (int)motionEvent.getY(index); if ((motionEvent.getEventTime() - motionEvent.getDownTime()) < TAP_TIMEOUT_MSEC - && (x - mDownX) < mMotionSlop && (y - mDownY) < mMotionSlop + && Math.abs(x - mDownX) < mMotionSlop + && Math.abs(y - mDownY) < mMotionSlop && !mTouchExcludeRegion.contains(x, y)) { mService.mH.obtainMessage(H.TAP_OUTSIDE_STACK, x, y, mDisplayContent).sendToTarget(); -- 2.11.0