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

Commit 1a5b09e4 authored by Simon (Qiong) Sun's avatar Simon (Qiong) Sun
Browse files

Set correct PiP bounds and user resize bounds when the display changes

- Update the max and min values of PiP Bounds State when the display
  changes.
- Set toBounds to the user resize bounds.

Bug: 382151065
Flag: com.android.wm.shell.enable_pip2
Video: http://recall/-/enO6UfsUvbbP010y4Er8TK/eNgUWMP7Jf0MVNMcpi1Wvl
Test: Test the PiP window size by folding and unfolding device.

Change-Id: I20a516aafdb9ca43381b0b7f52ab632e8b021535
parent ae434d49
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -341,7 +341,6 @@ public class PipController implements ConfigurationChangeListener,
            return;
        }
        final float snapFraction = mPipBoundsAlgorithm.getSnapFraction(mPipBoundsState.getBounds());
        final float boundsScale = mPipBoundsState.getBoundsScale();

        // Update the display layout caches even if we are not in PiP.
        setDisplayLayout(mDisplayController.getDisplayLayout(displayId));
@@ -368,6 +367,10 @@ public class PipController implements ConfigurationChangeListener,
            mPipTouchHandler.updateMovementBounds();
            mPipTransitionState.setInFixedRotation(false);
        } else {
            final float boundsScale = mPipBoundsState.getBoundsScale();
            // Before calculating the PiP bounds, the PiP minimum and maximum sizes
            // need to be recalculated for the current display.
            mPipBoundsState.updateMinMaxSize(mPipBoundsState.getAspectRatio());
            Rect toBounds = new Rect(0, 0,
                    (int) Math.ceil(mPipBoundsState.getMaxSize().x * boundsScale),
                    (int) Math.ceil(mPipBoundsState.getMaxSize().y * boundsScale));
@@ -378,6 +381,7 @@ public class PipController implements ConfigurationChangeListener,
            // The policy is to keep PiP snap fraction invariant.
            mPipBoundsAlgorithm.applySnapFraction(toBounds, snapFraction);
            mPipBoundsState.setBounds(toBounds);
            mPipTouchHandler.setUserResizeBounds(toBounds);
        }
        if (mPipTransitionState.getPipTaskToken() == null) {
            Log.d(TAG, "PipController.onDisplayChange no PiP task token"