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

Commit 5400de35 authored by Ben Lin's avatar Ben Lin
Browse files

Update bound as user moves PIP, and reuse it for snapAlgorithm reentry.

Update PipTaskOrganizer's last reported bounds as user moves the PIP
around. We then use this bound to calculate the snap fraction, and then
restore it on display rotation.

Bug: 147155783
Test: Start PIP, move PIP to different corner, rotate - same corner.
Change-Id: Ieb7054d9b66557aae63260767689d6523d87cdca
parent 0a1a911a
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -272,8 +272,8 @@ public class PipBoundsHandler {
     *
     * @return {@code true} if internal {@link DisplayInfo} is rotated, {@code false} otherwise.
     */
    public boolean onDisplayRotationChanged(Rect outBounds, int displayId, int fromRotation,
            int toRotation, WindowContainerTransaction t) {
    public boolean onDisplayRotationChanged(Rect outBounds, Rect oldBounds, int displayId,
            int fromRotation, int toRotation, WindowContainerTransaction t) {
        // Bail early if the event is not sent to current {@link #mDisplayInfo}
        if ((displayId != mDisplayInfo.displayId) || (fromRotation == toRotation)) {
            return false;
@@ -291,7 +291,7 @@ public class PipBoundsHandler {
        }

        // Calculate the snap fraction of the current stack along the old movement bounds
        final Rect postChangeStackBounds = new Rect(mLastDestinationBounds);
        final Rect postChangeStackBounds = new Rect(oldBounds);
        final float snapFraction = getSnapFraction(postChangeStackBounds);

        // Populate the new {@link #mDisplayInfo}.
+1 −0
Original line number Diff line number Diff line
@@ -523,6 +523,7 @@ public class PipTaskOrganizer extends TaskOrganizer {
            Log.w(TAG, "Abort animation, invalid leash");
            return;
        }
        mLastReportedBounds.set(destinationBounds);
        final SurfaceControl.Transaction tx = mSurfaceControlTransactionFactory.getTransaction();
        mSurfaceTransactionHelper
                .crop(tx, mLeash, destinationBounds)
+1 −1
Original line number Diff line number Diff line
@@ -96,7 +96,7 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
    private final DisplayChangeController.OnDisplayChangingListener mRotationController = (
            int displayId, int fromRotation, int toRotation, WindowContainerTransaction t) -> {
        final boolean changed = mPipBoundsHandler.onDisplayRotationChanged(mTmpNormalBounds,
                displayId, fromRotation, toRotation, t);
                mPipTaskOrganizer.getLastReportedBounds(), displayId, fromRotation, toRotation, t);
        if (changed) {
            updateMovementBounds(mTmpNormalBounds, true /* fromRotation */,
                    false /* fromImeAdjustment */, false /* fromShelfAdjustment */);
+1 −1
Original line number Diff line number Diff line
@@ -425,7 +425,7 @@ public class PipTouchHandler {

        // If this is from an IME or shelf adjustment, then we should move the PiP so that it is not
        // occluded by the IME or shelf.
        if (fromImeAdjustment || fromShelfAdjustment || fromDisplayRotationChanged) {
        if (fromImeAdjustment || fromShelfAdjustment) {
            if (mTouchState.isUserInteracting()) {
                // Defer the update of the current movement bounds until after the user finishes
                // touching the screen