From c40352ef8c42267138454a93639bb71293cf25d2 Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Thu, 14 May 2020 15:07:31 -0700 Subject: [PATCH] Override Rect#contains() to include bottom right In landscape, the lowest coordinate touch registered is the actual lowest pixel possible by the screen. For portrait/seascape the lowest coordinate is (lowest pixel possible - 1). The difference of the one pixel makes Rect#contains() return false since only top left Rect points are inclusive and bottom right points are exclusive. Fixes: 156333291 Test: Always able to smoothly go to overview from landscape. Change-Id: I6beddad99ae076a167d2a5f5e5acc6e466bff544 --- .../quickstep/OrientationTouchTransformer.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/quickstep/src/com/android/quickstep/OrientationTouchTransformer.java b/quickstep/src/com/android/quickstep/OrientationTouchTransformer.java index 879fd1d64f..4cf7aab4ab 100644 --- a/quickstep/src/com/android/quickstep/OrientationTouchTransformer.java +++ b/quickstep/src/com/android/quickstep/OrientationTouchTransformer.java @@ -317,13 +317,6 @@ class OrientationTouchTransformer { private class OrientationRectF extends RectF { - /** - * Delta to subtract width and height by because if we report the translated touch - * bounds as the width and height, calling {@link RectF#contains(float, float)} will - * be false - */ - private float maxDelta = 0.001f; - private int mRotation; private float mHeight; private float mWidth; @@ -331,8 +324,8 @@ class OrientationTouchTransformer { OrientationRectF(float left, float top, float right, float bottom, int rotation) { super(left, top, right, bottom); this.mRotation = rotation; - mHeight = bottom - maxDelta; - mWidth = right - maxDelta; + mHeight = bottom; + mWidth = right; } @Override @@ -342,6 +335,13 @@ class OrientationTouchTransformer { return s; } + @Override + public boolean contains(float x, float y) { + // Mark bottom right as included in the Rect (copied from Rect src, added "=" in "<=") + return left < right && top < bottom // check for empty first + && x >= left && x <= right && y >= top && y <= bottom; + } + boolean applyTransform(MotionEvent event, boolean forceTransform) { mTmpMatrix.reset(); postDisplayRotation(deltaRotation(mCurrentDisplayRotation, mRotation),