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
This commit is contained in:
Mady Mellor
2022-01-10 17:05:46 -08:00
parent cb2fb6825f
commit 5650fa8ee4

View File

@@ -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);
}