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

Commit b5de9f3b authored by Adam Powell's avatar Adam Powell
Browse files

Fix bug 2845609 - Touch event dispatching problem.

Maintain the state of the CANCEL_NEXT_UP_EVENT flag properly.

Change-Id: I5ca22409bf8557c486d02806811b10550c5576eb
parent b6a45e39
Loading
Loading
Loading
Loading
+4 −9
Original line number Diff line number Diff line
@@ -5088,7 +5088,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
     */
    public final void setTop(int top) {
        if (top != mTop) {
            Matrix m = getMatrix();
            if (mMatrixIsIdentity) {
                final ViewParent p = mParent;
                if (p != null && mAttachInfo != null) {
@@ -5129,7 +5128,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
     */
    public final void setBottom(int bottom) {
        if (bottom != mBottom) {
            Matrix m = getMatrix();
            if (mMatrixIsIdentity) {
                final ViewParent p = mParent;
                if (p != null && mAttachInfo != null) {
@@ -5170,7 +5168,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
     */
    public final void setLeft(int left) {
        if (left != mLeft) {
            Matrix m = getMatrix();
            if (mMatrixIsIdentity) {
                final ViewParent p = mParent;
                if (p != null && mAttachInfo != null) {
@@ -5211,7 +5208,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
     */
    public final void setRight(int right) {
        if (right != mRight) {
            Matrix m = getMatrix();
            if (mMatrixIsIdentity) {
                final ViewParent p = mParent;
                if (p != null && mAttachInfo != null) {
@@ -5283,10 +5279,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
     * @param outRect The hit rectangle of the view.
     */
    public void getHitRect(Rect outRect) {
        Matrix m = getMatrix();
        if (mMatrixIsIdentity || mAttachInfo == null) {
            outRect.set(mLeft, mTop, mRight, mBottom);
        } else {
            Matrix m = getMatrix();
            final RectF tmpRect = mAttachInfo.mTmpTransformRect;
            tmpRect.set(-mPivotX, -mPivotY,
                    getWidth() - mPivotX, getHeight() - mPivotY);
@@ -5308,7 +5304,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
    boolean dispatchTouchEvent(MotionEvent ev, float parentX, float parentY) {
        float localX = parentX - mLeft;
        float localY = parentY - mTop;
        Matrix m = getMatrix();
        if (!mMatrixIsIdentity && mAttachInfo != null) {
            // non-identity matrix: transform the point into the view's coordinates
            final float[] localXY = mAttachInfo.mTmpTransformLocation;
@@ -5320,6 +5315,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
        }
        if (localX >= 0 && localY >= 0 &&
                localX < (mRight - mLeft) && localY < (mBottom - mTop)) {
            // It would be safer to clone the event here but we don't for performance.
            // There are many subtle interactions in touch event dispatch; change at your own risk.
            mPrivateFlags &= ~CANCEL_NEXT_UP_EVENT;
            ev.setLocation(localX, localY);
            return dispatchTouchEvent(ev);
        }
@@ -5333,7 +5331,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
     * is still within the view.
     */
    private boolean pointInView(float localX, float localY, float slop) {
        Matrix m = getMatrix();
        if (!mMatrixIsIdentity && mAttachInfo != null) {
            // non-identity matrix: transform the point into the view's coordinates
            final float[] localXY = mAttachInfo.mTmpTransformLocation;
@@ -5411,7 +5408,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
     */
    public void offsetTopAndBottom(int offset) {
        if (offset != 0) {
            Matrix m = getMatrix();
            if (mMatrixIsIdentity) {
                final ViewParent p = mParent;
                if (p != null && mAttachInfo != null) {
@@ -5443,7 +5439,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
     */
    public void offsetLeftAndRight(int offset) {
        if (offset != 0) {
            Matrix m = getMatrix();
            if (mMatrixIsIdentity) {
                final ViewParent p = mParent;
                if (p != null && mAttachInfo != null) {
+0 −6
Original line number Diff line number Diff line
@@ -841,7 +841,6 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
        final float yf = ev.getY();
        final float scrolledXFloat = xf + mScrollX;
        final float scrolledYFloat = yf + mScrollY;
        final Rect frame = mTempRect;

        boolean disallowIntercept = (mGroupFlags & FLAG_DISALLOW_INTERCEPT) != 0;

@@ -860,8 +859,6 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
                ev.setAction(MotionEvent.ACTION_DOWN);
                // We know we want to dispatch the event down, find a child
                // who can handle it, start with the front-most child.
                final int scrolledXInt = (int) scrolledXFloat;
                final int scrolledYInt = (int) scrolledYFloat;
                final View[] children = mChildren;
                final int count = mChildrenCount;
                for (int i = count - 1; i >= 0; i--) {
@@ -869,7 +866,6 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
                    if ((child.mViewFlags & VISIBILITY_MASK) == VISIBLE
                            || child.getAnimation() != null) {
                        if (child.dispatchTouchEvent(ev, scrolledXFloat, scrolledYFloat)) {
                            child.mPrivateFlags &= ~CANCEL_NEXT_UP_EVENT;
                            mMotionTarget = child;
                            return true;
                        }
@@ -929,7 +925,6 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
        // dispatch the event.
        float xc;
        float yc;
        Matrix m = getMatrix();
        if (mMatrixIsIdentity || mAttachInfo == null) {
            xc = scrolledXFloat - (float) target.mLeft;
            yc = scrolledYFloat - (float) target.mTop;
@@ -1613,7 +1608,6 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
        }

        float alpha = child.getAlpha();
        Matrix childMatrix = child.getMatrix();

        if (transformToApply != null || alpha < 1.0f || !child.mMatrixIsIdentity) {
            int transX = 0;