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

Commit 6f40fe65 authored by Ikram Gabiyev's avatar Ikram Gabiyev
Browse files

[PiP2] Update insets when rotating display layout

PipDisplayLayoutState#rotateTo() is a method we use
in PiP transitions (primarily enter with fixed rotation)
to calculate the display bounds at some target rotation
(in async rotation scheme the actual display rotation hasn't
happened yet).

However, PipDisplayLayoutState also caches the insets due
to the navbar to calculate the right insetsBounds, which is
ultimately what is used to get PiP entry bounds.

Therefore, whenever we rotate the display layout in-place,
we also need to make sure we rotate the insets to avoid extra
offsets to PiP on the wrong sides.

Bug: 418250885
Flag: com.android.wm.shell.enable_pip2
Test: manually enter PiP from ROTATION_270 and _90 in btn nav
Change-Id: I1fbcc6a0847f0ddfdab154d32d07ffc342b400dc
parent baadd8b6
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.wm.shell.common.pip;

import static android.view.Surface.ROTATION_0;

import static com.android.wm.shell.common.pip.PipUtils.dpToPx;

import static java.lang.Math.max;
@@ -25,6 +27,7 @@ import android.content.res.Resources;
import android.graphics.Insets;
import android.graphics.Point;
import android.graphics.Rect;
import android.util.RotationUtils;
import android.util.Size;
import android.view.Surface;

@@ -141,7 +144,12 @@ public class PipDisplayLayoutState {
     * @param targetRotation
     */
    public void rotateTo(@Surface.Rotation int targetRotation) {
        final int fromRotation = getRotation();
        mDisplayLayout.rotateTo(mUiContext.getResources(), targetRotation);
        final int rotation = RotationUtils.deltaRotation(fromRotation, targetRotation);
        if (rotation != ROTATION_0) {
            mNavigationBarsInsets = RotationUtils.rotateInsets(mNavigationBarsInsets, rotation);
        }
    }

    /** Returns the current display rotation of this layout state. */