From 5650fa8ee47061d4a24276bad3f65ab796c72e4d Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Mon, 10 Jan 2022 17:05:46 -0800 Subject: [PATCH] Fix an issue where the divider bar wasn't part of the hitRect for split This doesn't result in an issue with existing code but with some changes in how the animation works, this will become an issue. e.g. you can get a null target when it should be non-null which changes whether the animation is a switch between targets vs a new drag into a target. Test: manual - with new animation code, put two apps in split and then drag a new one into split and move it between containers, the animation should look like a switch (color changes seamlessly rather than a jump to transparent). Bug: 207011867 Change-Id: I6d9c892654cbd57742bdf3268a8ab343f0fd3d3b --- .../android/wm/shell/draganddrop/DragAndDropPolicy.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragAndDropPolicy.java b/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragAndDropPolicy.java index 8e6c05d83906f..eda09e3ce0b0d 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragAndDropPolicy.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragAndDropPolicy.java @@ -62,6 +62,7 @@ import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import com.android.internal.logging.InstanceId; +import com.android.wm.shell.R; import com.android.wm.shell.common.DisplayLayout; import com.android.wm.shell.common.split.SplitScreenConstants.SplitPosition; import com.android.wm.shell.splitscreen.SplitScreenController; @@ -132,6 +133,8 @@ public class DragAndDropPolicy { final Rect fullscreenHitRegion = new Rect(displayRegion); final boolean inLandscape = mSession.displayLayout.isLandscape(); final boolean inSplitScreen = mSplitScreen != null && mSplitScreen.isSplitScreenVisible(); + final float dividerWidth = mContext.getResources().getDimensionPixelSize( + R.dimen.split_divider_bar_width); // We allow splitting if we are already in split-screen or the running task is a standard // task in fullscreen mode. final boolean allowSplit = inSplitScreen @@ -153,8 +156,11 @@ public class DragAndDropPolicy { // If we have existing split regions use those bounds, otherwise split it 50/50 if (inSplitScreen) { + // Add the divider bounds to each side since that counts for the hit region. leftHitRegion.set(topOrLeftBounds); + leftHitRegion.right += dividerWidth / 2; rightHitRegion.set(bottomOrRightBounds); + rightHitRegion.left -= dividerWidth / 2; } else { displayRegion.splitVertically(leftHitRegion, rightHitRegion); } @@ -170,8 +176,11 @@ public class DragAndDropPolicy { // If we have existing split regions use those bounds, otherwise split it 50/50 if (inSplitScreen) { + // Add the divider bounds to each side since that counts for the hit region. topHitRegion.set(topOrLeftBounds); + topHitRegion.bottom += dividerWidth / 2; bottomHitRegion.set(bottomOrRightBounds); + bottomHitRegion.top -= dividerWidth / 2; } else { displayRegion.splitHorizontally(topHitRegion, bottomHitRegion); }