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

Commit 4fb1e911 authored by Evan Rosky's avatar Evan Rosky
Browse files

Clean-up some out-dated layout shenanigans

Task.isFullscreen was checking for empty bounds, this wasn't
accounting for the (new) difference between being FULLSCREEN
(by policy) and actually filling the screen. This resulted in
certain checks not working properly (eg. letterbox surface
layout). isFullscreen has been removed and the callers now
check for what they care about.

useCurrentBounds is effectively dead-code now. It was
originally to deal with multi-user cases to prevent docked
stack of one user influencing the size of another user's
stacks. Nowadays, mode changes through the configuration
hierarchy handles these adjustments and falling-back on
displayBounds won't be appropriate in nested situations.

getAnimationBounds was basically trying to duplicate the
logic already performed by the hierarchy configuration
update. Specifically, looking at the mode and picking
which bounds to use. This is redundant and was actually
causing problems because new policies handled in the
hierarchy weren't being reproduced faithfully here. However,
due to letterbox, we can't use AppWindowToken bounds
directly. So for now we just use task (instead of stack)
for a representation of "the window" that also works
for freeform.

Letterbox layout was only being calculated relative to the
task. For fixed-orientation letterbox, this doesn't work
because the task itself needs to be letterboxed. For now,
this CL hard-codes an additional level (stack) and unions
that for the "letterbox fill region". We should probably
replace this with a recursive solution, but there's
currently still some issues that might require moving this
stuff around anyways.

Bug: 124626708
Test: launch a portrait-only app into fullscreen on a
      landscape-only display.
      atest AppWindowTokenTests WindowFrameTests
Change-Id: I1375c1988fbc8460802f30acee2207289fdb18e7
parent ec9488c1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -443,7 +443,7 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
         * Returns true if the window is current in multi-windowing mode. i.e. it shares the
         * screen with other application windows.
         */
        public boolean isInMultiWindowMode();
        boolean inMultiWindowMode();

        public int getRotationAnimationHint();

+14 −24
Original line number Diff line number Diff line
@@ -1979,7 +1979,14 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
                mLetterbox.attachInput(w);
            }
            getPosition(mTmpPoint);
            mLetterbox.layout(getParent().getBounds(), w.getFrameLw(), mTmpPoint);
            // Get the bounds of the "space-to-fill". We union the Task and the Stack bounds here
            // to handle both split window (where task-bounds can be larger) and orientation
            // letterbox (where the task is letterboxed within stack).
            Rect spaceToFill = getTask().getBounds();
            if (getStack() != null) {
                spaceToFill.union(getStack().getBounds());
            }
            mLetterbox.layout(spaceToFill, w.getFrameLw(), mTmpPoint);
        } else if (mLetterbox != null) {
            mLetterbox.hide();
        }
@@ -2448,28 +2455,6 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
        return boundsLayer;
    }

    /** Get position and crop region of animation. */
    @VisibleForTesting
    void getAnimationBounds(Point outPosition, Rect outBounds) {
        outPosition.set(0, 0);
        outBounds.setEmpty();

        final TaskStack stack = getStack();
        final Task task = getTask();
        if (task != null && task.inFreeformWindowingMode()) {
            task.getRelativeDisplayedPosition(outPosition);
            task.getBounds(outBounds);
        } else if (stack != null) {
            stack.getRelativeDisplayedPosition(outPosition);
            // Use stack bounds in order to have the ability to animate outside the task region.
            // Needs to be consistent when {@link #mNeedsAnimationBoundsLayer} is set that crops
            // according to the bounds.
            stack.getBounds(outBounds);
        }
        // We have the relative position so the local position can be removed from bounds.
        outBounds.offsetTo(0, 0);
    }

    @Override
    Rect getDisplayedBounds() {
        final Task task = getTask();
@@ -2501,7 +2486,12 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
        if (okToAnimate()) {
            final AnimationAdapter adapter;
            AnimationAdapter thumbnailAdapter = null;
            getAnimationBounds(mTmpPoint, mTmpRect);

            // Separate position and size for use in animators. Use task-bounds for now so
            // that activity-level letterbox (maxAspectRatio) is included in the animation.
            mTmpRect.set(getTask() != null ? getTask().getBounds() : getBounds());
            mTmpPoint.set(mTmpRect.left, mTmpRect.top);
            mTmpRect.offsetTo(0, 0);

            final boolean isChanging = AppTransition.isChangeTransit(transit) && enter
                    && getDisplayContent().mChangingApps.contains(this);
+1 −1
Original line number Diff line number Diff line
@@ -2151,7 +2151,7 @@ public class DisplayPolicy {
        // TYPE_SYSTEM_ERROR is above the NavigationBar so it can't be allowed to extend over it.
        // Also, we don't allow windows in multi-window mode to extend out of the screen.
        if ((fl & FLAG_LAYOUT_NO_LIMITS) != 0 && type != TYPE_SYSTEM_ERROR
                && !win.isInMultiWindowMode()) {
                && !win.inMultiWindowMode()) {
            df.left = df.top = -10000;
            df.right = df.bottom = 10000;
            if (type != TYPE_WALLPAPER) {
+18 −59
Original line number Diff line number Diff line
@@ -433,29 +433,6 @@ class Task extends WindowContainer<AppWindowToken> implements ConfigurationConta
        }
    }

    /** Return true if the current bound can get outputted to the rest of the system as-is. */
    private boolean useCurrentBounds() {
        final DisplayContent displayContent = getDisplayContent();
        return matchParentBounds()
                || !inSplitScreenSecondaryWindowingMode()
                || displayContent == null
                || displayContent.getSplitScreenPrimaryStackIgnoringVisibility() != null;
    }

    @Override
    public void getBounds(Rect out) {
        if (useCurrentBounds()) {
            // No need to adjust the output bounds if fullscreen or the docked stack is visible
            // since it is already what we want to represent to the rest of the system.
            super.getBounds(out);
            return;
        }

        // The bounds has been adjusted to accommodate for a docked stack, but the docked stack is
        // not currently visible. Go ahead a represent it as fullscreen to the rest of the system.
        mStack.getDisplayContent().getBounds(out);
    }

    @Override
    public Rect getDisplayedBounds() {
        if (mOverrideDisplayedBounds.isEmpty()) {
@@ -506,7 +483,6 @@ class Task extends WindowContainer<AppWindowToken> implements ConfigurationConta
        // a DimLayer anyway if we weren't visible.
        final boolean dockedResizing = displayContent != null
                && displayContent.mDividerControllerLocked.isResizing();
        if (useCurrentBounds()) {
        if (inFreeformWindowingMode() && getMaxVisibleBounds(out)) {
            return;
        }
@@ -515,9 +491,9 @@ class Task extends WindowContainer<AppWindowToken> implements ConfigurationConta
            // When minimizing the docked stack when going home, we don't adjust the task bounds
            // so we need to intersect the task bounds with the stack bounds here.
            //
                // If we are Docked Resizing with snap points, the task bounds could be smaller than the stack
                // bounds and so we don't even want to use them. Even if the app should not be resized the Dim
                // should keep up with the divider.
            // If we are Docked Resizing with snap points, the task bounds could be smaller than the
            // stack bounds and so we don't even want to use them. Even if the app should not be
            // resized the Dim should keep up with the divider.
            if (dockedResizing) {
                mStack.getBounds(out);
            } else {
@@ -531,13 +507,6 @@ class Task extends WindowContainer<AppWindowToken> implements ConfigurationConta
        return;
    }

        // The bounds has been adjusted to accommodate for a docked stack, but the docked stack is
        // not currently visible. Go ahead a represent it as fullscreen to the rest of the system.
        if (displayContent != null) {
            displayContent.getBounds(out);
        }
    }

    void setDragResizing(boolean dragResizing, int dragResizeMode) {
        if (mDragResizing != dragResizing) {
            // No need to check if the mode is allowed if it's leaving dragResize
@@ -702,16 +671,6 @@ class Task extends WindowContainer<AppWindowToken> implements ConfigurationConta
        positionChildAt(position, aToken, false /* includeParents */);
    }

    boolean isFullscreen() {
        if (useCurrentBounds()) {
            return matchParentBounds();
        }
        // The bounds has been adjusted to accommodate for a docked stack, but the docked stack
        // is not currently visible. Go ahead a represent it as fullscreen to the rest of the
        // system.
        return true;
    }

    void forceWindowsScaleable(boolean force) {
        mWmService.openSurfaceTransaction();
        try {
+10 −34
Original line number Diff line number Diff line
@@ -303,17 +303,6 @@ public class TaskStack extends WindowContainer<Task> implements
        return super.getBounds();
    }

    /** Return true if the current bound can get outputted to the rest of the system as-is. */
    private boolean useCurrentBounds() {
        if (matchParentBounds()
                || !inSplitScreenSecondaryWindowingMode()
                || mDisplayContent == null
                || mDisplayContent.getSplitScreenPrimaryStackIgnoringVisibility() != null) {
            return true;
        }
        return false;
    }

    @Override
    public void getBounds(Rect bounds) {
        bounds.set(getBounds());
@@ -321,7 +310,6 @@ public class TaskStack extends WindowContainer<Task> implements

    @Override
    public Rect getBounds() {
        if (useCurrentBounds()) {
        // If we're currently adjusting for IME or minimized docked stack, we use the adjusted
        // bounds; otherwise, no need to adjust the output bounds if fullscreen or the docked
        // stack is visible since it is already what we want to represent to the rest of the
@@ -333,12 +321,6 @@ public class TaskStack extends WindowContainer<Task> implements
        }
    }

        // The bounds has been adjusted to accommodate for a docked stack, but the docked stack
        // is not currently visible. Go ahead a represent it as fullscreen to the rest of the
        // system.
        return mDisplayContent.getBounds();
    }

    /**
     * Sets the bounds animation target bounds ahead of an animation.  This can't currently be done
     * in onAnimationStart() since that is started on the UiThread.
@@ -1425,14 +1407,8 @@ public class TaskStack extends WindowContainer<Task> implements

    @Override
    boolean fillsParent() {
        if (useCurrentBounds()) {
        return matchParentBounds();
    }
        // The bounds has been adjusted to accommodate for a docked stack, but the docked stack
        // is not currently visible. Go ahead a represent it as fullscreen to the rest of the
        // system.
        return true;
    }

    @Override
    public String toString() {
@@ -1516,7 +1492,7 @@ public class TaskStack extends WindowContainer<Task> implements

        for (int i = mChildren.size() - 1; i >= 0; --i) {
            final Task task = mChildren.get(i);
            if (task.isFullscreen()) {
            if (task.getWindowingMode() == WINDOWING_MODE_FULLSCREEN) {
                results.searchDone = true;
                return;
            }
Loading