summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMotionHelper.java11
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipMotionHelper.java11
2 files changed, 22 insertions, 0 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMotionHelper.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMotionHelper.java
index df3803d54d9d..999ab95ccb1e 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMotionHelper.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMotionHelper.java
@@ -416,6 +416,17 @@ public class PipMotionHelper implements PipAppOpsListener.Callback,
// location now.
mSpringingToTouch = false;
+ // Boost the velocityX if it's zero to forcefully push it towards the nearest edge.
+ // We don't simply change the xEndValue below since the PhysicsAnimator would rely on the
+ // same velocityX to find out which edge to snap to.
+ if (velocityX == 0) {
+ final int motionCenterX = mPipBoundsState
+ .getMotionBoundsState().getBoundsInMotion().centerX();
+ final int displayCenterX = mPipBoundsState
+ .getDisplayBounds().centerX();
+ velocityX = (motionCenterX < displayCenterX) ? -0.001f : 0.001f;
+ }
+
mTemporaryBoundsPhysicsAnimator
.spring(FloatProperties.RECT_WIDTH, getBounds().width(), mSpringConfig)
.spring(FloatProperties.RECT_HEIGHT, getBounds().height(), mSpringConfig)
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipMotionHelper.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipMotionHelper.java
index ea02de9d9704..e1e072a7faad 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipMotionHelper.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipMotionHelper.java
@@ -416,6 +416,17 @@ public class PipMotionHelper implements PipAppOpsListener.Callback,
// location now.
mSpringingToTouch = false;
+ // Boost the velocityX if it's zero to forcefully push it towards the nearest edge.
+ // We don't simply change the xEndValue below since the PhysicsAnimator would rely on the
+ // same velocityX to find out which edge to snap to.
+ if (velocityX == 0) {
+ final int motionCenterX = mPipBoundsState
+ .getMotionBoundsState().getBoundsInMotion().centerX();
+ final int displayCenterX = mPipBoundsState
+ .getDisplayBounds().centerX();
+ velocityX = (motionCenterX < displayCenterX) ? -0.001f : 0.001f;
+ }
+
mTemporaryBoundsPhysicsAnimator
.spring(FloatProperties.RECT_WIDTH, getBounds().width(), mSpringConfig)
.spring(FloatProperties.RECT_HEIGHT, getBounds().height(), mSpringConfig)