From c73eb5d3f7c19e43b8cca27699ddc6094617be93 Mon Sep 17 00:00:00 2001 From: "jorgegil@google.com" Date: Fri, 11 Jun 2021 14:42:55 -0700 Subject: [PATCH] Start pinchResize only if pointers are inside PIP The PipResizeGestureHandler was previusly signaling a start of the pinch resize without checking that both pointers were within the PIP bounds region. This caused the TouchState to be reset with a single tap outside the PIP window while drag-moving it with another finger, which led to PIP becoming stuck without snapping to the edges. With this CL, we make sure that both fingers are inside PIP before starting resetting the touch state and allowing the pinch resize to start. Bug: 188640607 Bug: 186607893 Test: move the PIP with one finger and while still holding it tap anywhere outside of PIP with another finger - verify you can still keep moving the PIP with the first finger normally. Change-Id: I2137180ea1f333fe2e0b67e52d57da5ff9a2d094 --- .../wm/shell/pip/phone/PipResizeGestureHandler.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipResizeGestureHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipResizeGestureHandler.java index 32553f97c0206..28f3a30169caf 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipResizeGestureHandler.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipResizeGestureHandler.java @@ -235,15 +235,20 @@ public class PipResizeGestureHandler { @VisibleForTesting void onInputEvent(InputEvent ev) { + if (!mEnableDragCornerResize && !mEnablePinchResize) { + // No need to handle anything if neither form of resizing is enabled. + return; + } + // Don't allow resize when PiP is stashed. if (mPipBoundsState.isStashed()) { return; } if (ev instanceof MotionEvent) { - if (mOngoingPinchToResize) { + if (mEnablePinchResize && mOngoingPinchToResize) { onPinchResize((MotionEvent) ev); - } else { + } else if (mEnableDragCornerResize) { onDragCornerResize((MotionEvent) ev); } } @@ -318,8 +323,8 @@ public class PipResizeGestureHandler { case MotionEvent.ACTION_POINTER_DOWN: if (mEnablePinchResize && ev.getPointerCount() == 2) { onPinchResize(ev); - mOngoingPinchToResize = true; - return true; + mOngoingPinchToResize = mAllowGesture; + return mAllowGesture; } break;