summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jerry Chang <chenghsiuchang@google.com> 2021-09-16 14:36:50 +0800
committer Jerry Chang <chenghsiuchang@google.com> 2021-09-16 14:40:03 +0800
commita2267025b5a7355b785545f13b49e15f6cccdee7 (patch)
tree4bad9fb77598ac1866a4de96ccbdacbf10f3b11c
parentd0b1d557e9651b09d7587212ac140e4cdeadb3e8 (diff)
Use screen-based coordinates to calculate divier bar dragging velocity
Fix: 199468325 Test: atest WMShellUnitTests Test: manual check the snapping behavior of divider bar. Change-Id: I1256dbe8cb6fbfefdfdaa15c884c2ade4029e256
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerView.java7
1 files changed, 4 insertions, 3 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerView.java
index f35c8e1c5929..f9ba97f8f9b1 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerView.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerView.java
@@ -24,7 +24,6 @@ import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.Property;
-import android.util.TypedValue;
import android.view.GestureDetector;
import android.view.InsetsSource;
import android.view.InsetsState;
@@ -178,10 +177,12 @@ public class DividerView extends FrameLayout implements View.OnTouchListener {
return true;
}
+ // Convert to use screen-based coordinates to prevent lost track of motion events while
+ // moving divider bar and calculating dragging velocity.
+ event.setLocation(event.getRawX(), event.getRawY());
final int action = event.getAction() & MotionEvent.ACTION_MASK;
final boolean isLandscape = isLandscape();
- // Using raw xy to prevent lost track of motion events while moving divider bar.
- final int touchPos = isLandscape ? (int) event.getRawX() : (int) event.getRawY();
+ final int touchPos = (int) (isLandscape ? event.getX() : event.getY());
switch (action) {
case MotionEvent.ACTION_DOWN:
mVelocityTracker = VelocityTracker.obtain();