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

Commit bae2b15c authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Fix cutout with temp inset bounds

Cutout needs to be calculated before shifting back, otherwise it
will end up at the wrong position.

Test: WindowFrameTests
Test: Resize with cutout, less jank
Bug: 78214347
Change-Id: I4eebd61aff9c13b2b53d0ed1afa7e4159eb29b29
parent 8182e354
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -1088,6 +1088,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
                            :  Math.max(mFrame.bottom - mStableFrame.bottom, 0));
        }

        mDisplayCutout = displayCutout.calculateRelativeTo(mFrame);

        // Offset the actual frame by the amount layout frame is off.
        mFrame.offset(-layoutXDiff, -layoutYDiff);
        mCompatFrame.offset(-layoutXDiff, -layoutYDiff);
@@ -1095,10 +1097,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        mVisibleFrame.offset(-layoutXDiff, -layoutYDiff);
        mStableFrame.offset(-layoutXDiff, -layoutYDiff);

        // TODO(roosa): Figure out what frame exactly this needs to be calculated with.
        mDisplayCutout = displayCutout.calculateRelativeTo(mFrame);


        mCompatFrame.set(mFrame);
        if (mEnforceSizeCompat) {
            // If there is a size compatibility scale being applied to the
+22 −0
Original line number Diff line number Diff line
@@ -441,6 +441,28 @@ public class WindowFrameTests extends WindowTestsBase {
        assertEquals(w.mDisplayCutout.getDisplayCutout().getSafeInsetRight(), 0);
    }

    @Test
    public void testDisplayCutout_tempInsetBounds() {
        // Regular fullscreen task and window
        TaskWithBounds task = new TaskWithBounds(new Rect(0, -500, 1000, 1500));
        task.mFullscreenForTest = false;
        task.mInsetBounds.set(0, 0, 1000, 2000);
        WindowState w = createWindow(task, FILL_PARENT, FILL_PARENT);
        w.mAttrs.gravity = Gravity.LEFT | Gravity.TOP;

        final Rect pf = new Rect(0, -500, 1000, 1500);
        // Create a display cutout of size 50x50, aligned top-center
        final WmDisplayCutout cutout = WmDisplayCutout.computeSafeInsets(
                fromBoundingRect(500, 0, 550, 50), pf.width(), pf.height());

        w.computeFrameLw(pf, pf, pf, pf, pf, pf, pf, pf, cutout, false);

        assertEquals(w.mDisplayCutout.getDisplayCutout().getSafeInsetTop(), 50);
        assertEquals(w.mDisplayCutout.getDisplayCutout().getSafeInsetBottom(), 0);
        assertEquals(w.mDisplayCutout.getDisplayCutout().getSafeInsetLeft(), 0);
        assertEquals(w.mDisplayCutout.getDisplayCutout().getSafeInsetRight(), 0);
    }

    private WindowStateWithTask createWindow(Task task, int width, int height) {
        final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams(TYPE_APPLICATION);
        attrs.width = width;