Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipDisplayTransferHandler.java +10 −1 Original line number Diff line number Diff line Loading @@ -71,7 +71,7 @@ public class PipDisplayTransferHandler implements ArrayMap<Integer, SurfaceControl> mOnDragMirrorPerDisplayId = new ArrayMap<>(); @VisibleForTesting int mTargetDisplayId; private PipResizeAnimatorSupplier mPipResizeAnimatorSupplier; private boolean mIsMirrorShown; public PipDisplayTransferHandler(Context context, PipTransitionState pipTransitionState, PipScheduler pipScheduler, RootTaskDisplayAreaOrganizer rootTaskDisplayAreaOrganizer, PipBoundsState pipBoundsState, DisplayController displayController, Loading Loading @@ -194,6 +194,7 @@ public class PipDisplayTransferHandler implements */ public void showDragMirrorOnConnectedDisplays(RectF globalDpPipBounds, int focusedDisplayId) { final Transaction transaction = mSurfaceControlTransactionFactory.getTransaction(); mIsMirrorShown = false; // Iterate through each connected display ID to ensure partial PiP bounds are shown on // all corresponding displays while dragging for (int displayId : mRootTaskDisplayAreaOrganizer.getDisplayIds()) { Loading Loading @@ -230,6 +231,7 @@ public class PipDisplayTransferHandler implements mPipBoundsState.getBounds(), boundsOnCurrentDisplay, /* degrees= */ 0).setMirrorTransformations(transaction, mirror); mRootTaskDisplayAreaOrganizer.reparentToDisplayArea(displayId, mirror, transaction); mIsMirrorShown = true; } transaction.apply(); } Loading Loading @@ -259,6 +261,13 @@ public class PipDisplayTransferHandler implements mPipSurfaceTransactionHelper = surfaceTransactionHelper; } /** * Whether any of the drag mirror(s) are showing on any display other than the primary display. */ boolean isMirrorShown() { return mIsMirrorShown; } @VisibleForTesting interface PipResizeAnimatorSupplier { PipResizeAnimator get(@NonNull Context context, Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTouchHandler.java +5 −1 Original line number Diff line number Diff line Loading @@ -1079,7 +1079,11 @@ public class PipTouchHandler implements PipTransitionState.PipTransitionStateCha // PIP into stashed mode. final boolean stashFromDroppingOnEdge = droppingOnLeft || droppingOnRight; return stashFromFlingToEdge || stashFromDroppingOnEdge; // If dragging PiP across displays is allowed, then ensure that stashing only occurs // when no drag mirrors of the window are shown, meaning that it wasn't partially shown // on another display return (stashFromFlingToEdge || stashFromDroppingOnEdge) && !mPipDisplayTransferHandler.isMirrorShown(); } } Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip2/phone/PipDisplayTransferHandlerTest.kt +7 −0 Original line number Diff line number Diff line Loading @@ -260,6 +260,7 @@ class PipDisplayTransferHandlerTest : ShellTestCase() { ) verify(mockSurfaceTransactionHelper, never()).setMirrorTransformations(any(), any()) verify(mockTransaction, times(1)).apply() assertThat(pipDisplayTransferHandler.isMirrorShown()).isFalse() } @Test Loading @@ -268,6 +269,7 @@ class PipDisplayTransferHandlerTest : ShellTestCase() { displayLayouts.get(ORIGIN_DISPLAY_ID)!!, START_DRAG_COORDINATES, PIP_BOUNDS, displayLayouts.get(TARGET_DISPLAY_ID)!!, TestDisplay.DISPLAY_1.bounds.centerX(), TestDisplay.DISPLAY_1.bounds.centerY()) pipDisplayTransferHandler.showDragMirrorOnConnectedDisplays( globalDpBounds, TARGET_DISPLAY_ID ) Loading @@ -281,6 +283,7 @@ class PipDisplayTransferHandlerTest : ShellTestCase() { ) verify(mockSurfaceTransactionHelper, never()).setMirrorTransformations(any(), any()) verify(mockTransaction, times(1)).apply() assertThat(pipDisplayTransferHandler.isMirrorShown()).isFalse() } @Test Loading @@ -290,6 +293,7 @@ class PipDisplayTransferHandlerTest : ShellTestCase() { PIP_BOUNDS, displayLayouts.get(TARGET_DISPLAY_ID)!!, TestDisplay.DISPLAY_1.bounds.centerX(), TestDisplay.DISPLAY_1.bounds.centerY() ) pipDisplayTransferHandler.showDragMirrorOnConnectedDisplays( globalDpBounds, ORIGIN_DISPLAY_ID ) Loading @@ -314,6 +318,7 @@ class PipDisplayTransferHandlerTest : ShellTestCase() { ) verify(mockSurfaceTransactionHelper, times(1)).setMirrorTransformations(any(), any()) verify(mockTransaction, times(1)).apply() assertThat(pipDisplayTransferHandler.isMirrorShown()).isTrue() } @Test Loading @@ -322,6 +327,7 @@ class PipDisplayTransferHandlerTest : ShellTestCase() { displayLayouts.get(ORIGIN_DISPLAY_ID)!!, START_DRAG_COORDINATES, PIP_BOUNDS, displayLayouts.get(TARGET_DISPLAY_ID)!!, 1000f, -100f) pipDisplayTransferHandler.showDragMirrorOnConnectedDisplays( globalDpBounds, ORIGIN_DISPLAY_ID ) Loading Loading @@ -356,6 +362,7 @@ class PipDisplayTransferHandlerTest : ShellTestCase() { ) verify(mockSurfaceTransactionHelper, times(2)).setMirrorTransformations(any(), any()) verify(mockTransaction, times(1)).apply() assertThat(pipDisplayTransferHandler.isMirrorShown()).isTrue() } @Test Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipDisplayTransferHandler.java +10 −1 Original line number Diff line number Diff line Loading @@ -71,7 +71,7 @@ public class PipDisplayTransferHandler implements ArrayMap<Integer, SurfaceControl> mOnDragMirrorPerDisplayId = new ArrayMap<>(); @VisibleForTesting int mTargetDisplayId; private PipResizeAnimatorSupplier mPipResizeAnimatorSupplier; private boolean mIsMirrorShown; public PipDisplayTransferHandler(Context context, PipTransitionState pipTransitionState, PipScheduler pipScheduler, RootTaskDisplayAreaOrganizer rootTaskDisplayAreaOrganizer, PipBoundsState pipBoundsState, DisplayController displayController, Loading Loading @@ -194,6 +194,7 @@ public class PipDisplayTransferHandler implements */ public void showDragMirrorOnConnectedDisplays(RectF globalDpPipBounds, int focusedDisplayId) { final Transaction transaction = mSurfaceControlTransactionFactory.getTransaction(); mIsMirrorShown = false; // Iterate through each connected display ID to ensure partial PiP bounds are shown on // all corresponding displays while dragging for (int displayId : mRootTaskDisplayAreaOrganizer.getDisplayIds()) { Loading Loading @@ -230,6 +231,7 @@ public class PipDisplayTransferHandler implements mPipBoundsState.getBounds(), boundsOnCurrentDisplay, /* degrees= */ 0).setMirrorTransformations(transaction, mirror); mRootTaskDisplayAreaOrganizer.reparentToDisplayArea(displayId, mirror, transaction); mIsMirrorShown = true; } transaction.apply(); } Loading Loading @@ -259,6 +261,13 @@ public class PipDisplayTransferHandler implements mPipSurfaceTransactionHelper = surfaceTransactionHelper; } /** * Whether any of the drag mirror(s) are showing on any display other than the primary display. */ boolean isMirrorShown() { return mIsMirrorShown; } @VisibleForTesting interface PipResizeAnimatorSupplier { PipResizeAnimator get(@NonNull Context context, Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTouchHandler.java +5 −1 Original line number Diff line number Diff line Loading @@ -1079,7 +1079,11 @@ public class PipTouchHandler implements PipTransitionState.PipTransitionStateCha // PIP into stashed mode. final boolean stashFromDroppingOnEdge = droppingOnLeft || droppingOnRight; return stashFromFlingToEdge || stashFromDroppingOnEdge; // If dragging PiP across displays is allowed, then ensure that stashing only occurs // when no drag mirrors of the window are shown, meaning that it wasn't partially shown // on another display return (stashFromFlingToEdge || stashFromDroppingOnEdge) && !mPipDisplayTransferHandler.isMirrorShown(); } } Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip2/phone/PipDisplayTransferHandlerTest.kt +7 −0 Original line number Diff line number Diff line Loading @@ -260,6 +260,7 @@ class PipDisplayTransferHandlerTest : ShellTestCase() { ) verify(mockSurfaceTransactionHelper, never()).setMirrorTransformations(any(), any()) verify(mockTransaction, times(1)).apply() assertThat(pipDisplayTransferHandler.isMirrorShown()).isFalse() } @Test Loading @@ -268,6 +269,7 @@ class PipDisplayTransferHandlerTest : ShellTestCase() { displayLayouts.get(ORIGIN_DISPLAY_ID)!!, START_DRAG_COORDINATES, PIP_BOUNDS, displayLayouts.get(TARGET_DISPLAY_ID)!!, TestDisplay.DISPLAY_1.bounds.centerX(), TestDisplay.DISPLAY_1.bounds.centerY()) pipDisplayTransferHandler.showDragMirrorOnConnectedDisplays( globalDpBounds, TARGET_DISPLAY_ID ) Loading @@ -281,6 +283,7 @@ class PipDisplayTransferHandlerTest : ShellTestCase() { ) verify(mockSurfaceTransactionHelper, never()).setMirrorTransformations(any(), any()) verify(mockTransaction, times(1)).apply() assertThat(pipDisplayTransferHandler.isMirrorShown()).isFalse() } @Test Loading @@ -290,6 +293,7 @@ class PipDisplayTransferHandlerTest : ShellTestCase() { PIP_BOUNDS, displayLayouts.get(TARGET_DISPLAY_ID)!!, TestDisplay.DISPLAY_1.bounds.centerX(), TestDisplay.DISPLAY_1.bounds.centerY() ) pipDisplayTransferHandler.showDragMirrorOnConnectedDisplays( globalDpBounds, ORIGIN_DISPLAY_ID ) Loading @@ -314,6 +318,7 @@ class PipDisplayTransferHandlerTest : ShellTestCase() { ) verify(mockSurfaceTransactionHelper, times(1)).setMirrorTransformations(any(), any()) verify(mockTransaction, times(1)).apply() assertThat(pipDisplayTransferHandler.isMirrorShown()).isTrue() } @Test Loading @@ -322,6 +327,7 @@ class PipDisplayTransferHandlerTest : ShellTestCase() { displayLayouts.get(ORIGIN_DISPLAY_ID)!!, START_DRAG_COORDINATES, PIP_BOUNDS, displayLayouts.get(TARGET_DISPLAY_ID)!!, 1000f, -100f) pipDisplayTransferHandler.showDragMirrorOnConnectedDisplays( globalDpBounds, ORIGIN_DISPLAY_ID ) Loading Loading @@ -356,6 +362,7 @@ class PipDisplayTransferHandlerTest : ShellTestCase() { ) verify(mockSurfaceTransactionHelper, times(2)).setMirrorTransformations(any(), any()) verify(mockTransaction, times(1)).apply() assertThat(pipDisplayTransferHandler.isMirrorShown()).isTrue() } @Test Loading