Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e57b1c71 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Disallow stashing if a drag mirror is showing." into main

parents c0124cdc d4cfd0f7
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -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,
@@ -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()) {
@@ -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();
    }
@@ -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,
+5 −1
Original line number Diff line number Diff line
@@ -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();
        }
    }

+7 −0
Original line number Diff line number Diff line
@@ -260,6 +260,7 @@ class PipDisplayTransferHandlerTest : ShellTestCase() {
        )
        verify(mockSurfaceTransactionHelper, never()).setMirrorTransformations(any(), any())
        verify(mockTransaction, times(1)).apply()
        assertThat(pipDisplayTransferHandler.isMirrorShown()).isFalse()
    }

    @Test
@@ -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
        )
@@ -281,6 +283,7 @@ class PipDisplayTransferHandlerTest : ShellTestCase() {
        )
        verify(mockSurfaceTransactionHelper, never()).setMirrorTransformations(any(), any())
        verify(mockTransaction, times(1)).apply()
        assertThat(pipDisplayTransferHandler.isMirrorShown()).isFalse()
    }

    @Test
@@ -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
        )
@@ -314,6 +318,7 @@ class PipDisplayTransferHandlerTest : ShellTestCase() {
        )
        verify(mockSurfaceTransactionHelper, times(1)).setMirrorTransformations(any(), any())
        verify(mockTransaction, times(1)).apply()
        assertThat(pipDisplayTransferHandler.isMirrorShown()).isTrue()
    }

    @Test
@@ -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
        )
@@ -356,6 +362,7 @@ class PipDisplayTransferHandlerTest : ShellTestCase() {
        )
        verify(mockSurfaceTransactionHelper, times(2)).setMirrorTransformations(any(), any())
        verify(mockTransaction, times(1)).apply()
        assertThat(pipDisplayTransferHandler.isMirrorShown()).isTrue()
    }

    @Test