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

Commit 23bf5462 authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Handle multi-window for inset hint

We need to incorporate task bounds when calculating the inset hint
so we don't specify something wrong to the client which we correct
immediately after.

Bug: 28697105
Change-Id: I23cec7d6cc62a4d982e0796a867e803d4cce0803
parent 29af3cab
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -938,7 +938,11 @@ public interface WindowManagerPolicy {
     * be correct.
     *
     * @param attrs The LayoutParams of the window.
     * @param rotation Rotation of the display.
     * @param taskBounds The bounds of the task this window is on or {@code null} if no task is
     *                   associated with the window.
     * @param displayRotation Rotation of the display.
     * @param displayWidth The width of the display.
     * @param displayHeight The height of the display.
     * @param outContentInsets The areas covered by system windows, expressed as positive insets.
     * @param outStableInsets The areas covered by stable system windows irrespective of their
     *                        current visibility. Expressed as positive insets.
@@ -946,8 +950,9 @@ public interface WindowManagerPolicy {
     * @return Whether to always consume the navigation bar.
     *         See {@link #isNavBarForcedShownLw(WindowState)}.
     */
    public boolean getInsetHintLw(WindowManager.LayoutParams attrs, int rotation,
            Rect outContentInsets, Rect outStableInsets, Rect outOutsets);
    public boolean getInsetHintLw(WindowManager.LayoutParams attrs, Rect taskBounds,
            int displayRotation, int displayWidth, int displayHeight, Rect outContentInsets,
            Rect outStableInsets, Rect outOutsets);

    /**
     * Called when layout of the windows is finished.  After this function has
+26 −2
Original line number Diff line number Diff line
@@ -553,6 +553,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    static final Rect mTmpStableFrame = new Rect();
    static final Rect mTmpNavigationFrame = new Rect();
    static final Rect mTmpOutsetFrame = new Rect();
    private static final Rect mTmpRect = new Rect();

    WindowState mTopFullscreenOpaqueWindowState;
    WindowState mTopFullscreenOpaqueOrDimmingWindowState;
@@ -3797,8 +3798,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    }

    @Override
    public boolean getInsetHintLw(WindowManager.LayoutParams attrs, int displayRotation,
            Rect outContentInsets, Rect outStableInsets, Rect outOutsets) {
    public boolean getInsetHintLw(WindowManager.LayoutParams attrs, Rect taskBounds,
            int displayRotation, int displayWidth, int displayHeight, Rect outContentInsets,
            Rect outStableInsets, Rect outOutsets) {
        final int fl = PolicyControl.getWindowFlags(null, attrs);
        final int sysuiVis = PolicyControl.getSystemUiVisibility(null, attrs);
        final int systemUiVisibility = (sysuiVis | attrs.subtreeSystemUiVisibility);
@@ -3852,6 +3854,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {

            outStableInsets.set(mStableLeft, mStableTop,
                    availRight - mStableRight, availBottom - mStableBottom);
            if (taskBounds != null) {
                calculateRelevantTaskInsets(taskBounds, outContentInsets,
                        displayWidth, displayHeight);
                calculateRelevantTaskInsets(taskBounds, outStableInsets,
                        displayWidth, displayHeight);
            }
            return mForceShowSystemBars;
        }
        outContentInsets.setEmpty();
@@ -3859,6 +3867,22 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        return mForceShowSystemBars;
    }

    /**
     * For any given task bounds, the insets relevant for these bounds given the insets relevant
     * for the entire display.
     */
    private void calculateRelevantTaskInsets(Rect taskBounds, Rect inOutInsets, int displayWidth,
            int displayHeight) {
        mTmpRect.set(0, 0, displayWidth, displayHeight);
        mTmpRect.inset(inOutInsets);
        mTmpRect.intersect(taskBounds);
        int leftInset = mTmpRect.left - taskBounds.left;
        int topInset = mTmpRect.top - taskBounds.top;
        int rightInset = taskBounds.right - mTmpRect.right;
        int bottomInset = taskBounds.bottom - mTmpRect.bottom;
        inOutInsets.set(leftInset, topInset, rightInset, bottomInset);
    }

    private boolean shouldUseOutsets(WindowManager.LayoutParams attrs, int fl) {
        return attrs.type == TYPE_WALLPAPER || (fl & (WindowManager.LayoutParams.FLAG_FULLSCREEN
                | WindowManager.LayoutParams.FLAG_LAYOUT_IN_OVERSCAN)) != 0;
+11 −2
Original line number Diff line number Diff line
@@ -2117,8 +2117,17 @@ public class WindowManagerService extends IWindowManager.Stub
            }

            if (displayContent.isDefaultDisplay) {
                if (mPolicy.getInsetHintLw(win.mAttrs, mRotation, outContentInsets, outStableInsets,
                        outOutsets)) {
                final DisplayInfo displayInfo = displayContent.getDisplayInfo();
                final Rect taskBounds;
                if (atoken != null && atoken.mTask != null) {
                    taskBounds = mTmpRect;
                    atoken.mTask.getBounds(mTmpRect);
                } else {
                    taskBounds = null;
                }
                if (mPolicy.getInsetHintLw(win.mAttrs, taskBounds, mRotation,
                        displayInfo.logicalWidth, displayInfo.logicalHeight, outContentInsets,
                        outStableInsets, outOutsets)) {
                    res |= WindowManagerGlobal.ADD_FLAG_ALWAYS_CONSUME_NAV_BAR;
                }
            } else {