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

Commit 4664623c authored by John Spurlock's avatar John Spurlock
Browse files

Store decor rects per window for transition cropping.

Instead of keeping a single global system decor rect around
in WindowManagerService, calculate and store policy-defined
system-decor frame for each window.

The per-window decor rect is useful for smooth transitions, since it
determines window cropping during transition animations.

Bug:10938001
Change-Id: Ice6652aa5946027c45c0b7ab4e46473a0f8e3f90
parent 913f87ef
Loading
Loading
Loading
Loading
+6 −13
Original line number Original line Diff line number Diff line
@@ -165,9 +165,11 @@ public interface WindowManagerPolicy {
         * This can be used as a hint for scrolling (avoiding resizing)
         * This can be used as a hint for scrolling (avoiding resizing)
         * the window to make certain that parts of its content
         * the window to make certain that parts of its content
         * are visible.
         * are visible.
         * @param decorFrame The decor frame specified by policy specific to this window,
         * to use for proper cropping during animation.
         */
         */
        public void computeFrameLw(Rect parentFrame, Rect displayFrame,
        public void computeFrameLw(Rect parentFrame, Rect displayFrame,
                Rect overlayFrame, Rect contentFrame, Rect visibleFrame);
                Rect overlayFrame, Rect contentFrame, Rect visibleFrame, Rect decorFrame);


        /**
        /**
         * Retrieve the current frame of the window that has been assigned by
         * Retrieve the current frame of the window that has been assigned by
@@ -815,19 +817,10 @@ public interface WindowManagerPolicy {
                              int displayRotation);
                              int displayRotation);


    /**
    /**
     * Return the rectangle of the screen currently covered by system decorations.
     * Returns the bottom-most layer of the system decor, above which no policy decor should
     * This will be called immediately after {@link #layoutWindowLw}.  It can
     * be applied.
     * fill in the rectangle to indicate any part of the screen that it knows
     * for sure is covered by system decor such as the status bar.  The rectangle
     * is initially set to the actual size of the screen, indicating nothing is
     * covered.
     *
     * @param systemRect The rectangle of the screen that is not covered by
     * system decoration.
     * @return Returns the layer above which the system rectangle should
     * not be applied.
     */
     */
    public int getSystemDecorRectLw(Rect systemRect);
    public int getSystemDecorLayerLw();


    /**
    /**
     * Return the rectangle of the screen that is available for applications to run in.
     * Return the rectangle of the screen that is available for applications to run in.
+35 −13
Original line number Original line Diff line number Diff line
@@ -374,6 +374,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    static final Rect mTmpOverscanFrame = new Rect();
    static final Rect mTmpOverscanFrame = new Rect();
    static final Rect mTmpContentFrame = new Rect();
    static final Rect mTmpContentFrame = new Rect();
    static final Rect mTmpVisibleFrame = new Rect();
    static final Rect mTmpVisibleFrame = new Rect();
    static final Rect mTmpDecorFrame = new Rect();
    static final Rect mTmpNavigationFrame = new Rect();
    static final Rect mTmpNavigationFrame = new Rect();


    WindowState mTopFullscreenOpaqueWindowState;
    WindowState mTopFullscreenOpaqueWindowState;
@@ -2680,10 +2681,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        final Rect df = mTmpDisplayFrame;
        final Rect df = mTmpDisplayFrame;
        final Rect of = mTmpOverscanFrame;
        final Rect of = mTmpOverscanFrame;
        final Rect vf = mTmpVisibleFrame;
        final Rect vf = mTmpVisibleFrame;
        final Rect dcf = mTmpDecorFrame;
        pf.left = df.left = of.left = vf.left = mDockLeft;
        pf.left = df.left = of.left = vf.left = mDockLeft;
        pf.top = df.top = of.top = vf.top = mDockTop;
        pf.top = df.top = of.top = vf.top = mDockTop;
        pf.right = df.right = of.right = vf.right = mDockRight;
        pf.right = df.right = of.right = vf.right = mDockRight;
        pf.bottom = df.bottom = of.bottom = vf.bottom = mDockBottom;
        pf.bottom = df.bottom = of.bottom = vf.bottom = mDockBottom;
        dcf.setEmpty();  // Decor frame N/A for system bars.


        if (isDefaultDisplay) {
        if (isDefaultDisplay) {
            // For purposes of putting out fake window up to steal focus, we will
            // For purposes of putting out fake window up to steal focus, we will
@@ -2781,7 +2784,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                mStatusBarLayer = mNavigationBar.getSurfaceLayer();
                mStatusBarLayer = mNavigationBar.getSurfaceLayer();
                // And compute the final frame.
                // And compute the final frame.
                mNavigationBar.computeFrameLw(mTmpNavigationFrame, mTmpNavigationFrame,
                mNavigationBar.computeFrameLw(mTmpNavigationFrame, mTmpNavigationFrame,
                        mTmpNavigationFrame, mTmpNavigationFrame, mTmpNavigationFrame);
                        mTmpNavigationFrame, mTmpNavigationFrame, mTmpNavigationFrame, dcf);
                if (DEBUG_LAYOUT) Slog.i(TAG, "mNavigationBar frame: " + mTmpNavigationFrame);
                if (DEBUG_LAYOUT) Slog.i(TAG, "mNavigationBar frame: " + mTmpNavigationFrame);
                if (mNavigationBarController.checkHiddenLw()) {
                if (mNavigationBarController.checkHiddenLw()) {
                    updateSysUiVisibility = true;
                    updateSysUiVisibility = true;
@@ -2806,7 +2809,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                mStatusBarLayer = mStatusBar.getSurfaceLayer();
                mStatusBarLayer = mStatusBar.getSurfaceLayer();


                // Let the status bar determine its size.
                // Let the status bar determine its size.
                mStatusBar.computeFrameLw(pf, df, vf, vf, vf);
                mStatusBar.computeFrameLw(pf, df, vf, vf, vf, dcf);


                // For layout, the status bar is always at the top with our fixed height.
                // For layout, the status bar is always at the top with our fixed height.
                mStableTop = mUnrestrictedScreenTop + mStatusBarHeight;
                mStableTop = mUnrestrictedScreenTop + mStatusBarHeight;
@@ -2854,11 +2857,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {


    /** {@inheritDoc} */
    /** {@inheritDoc} */
    @Override
    @Override
    public int getSystemDecorRectLw(Rect systemRect) {
    public int getSystemDecorLayerLw() {
        systemRect.left = mSystemLeft;
        systemRect.top = mSystemTop;
        systemRect.right = mSystemRight;
        systemRect.bottom = mSystemBottom;
        if (mStatusBar != null) return mStatusBar.getSurfaceLayer();
        if (mStatusBar != null) return mStatusBar.getSurfaceLayer();
        if (mNavigationBar != null) return mNavigationBar.getSurfaceLayer();
        if (mNavigationBar != null) return mNavigationBar.getSurfaceLayer();
        return 0;
        return 0;
@@ -2961,6 +2960,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        final Rect of = mTmpOverscanFrame;
        final Rect of = mTmpOverscanFrame;
        final Rect cf = mTmpContentFrame;
        final Rect cf = mTmpContentFrame;
        final Rect vf = mTmpVisibleFrame;
        final Rect vf = mTmpVisibleFrame;
        final Rect dcf = mTmpDecorFrame;
        dcf.setEmpty();


        final boolean hasNavBar = (isDefaultDisplay && mHasNavigationBar
        final boolean hasNavBar = (isDefaultDisplay && mHasNavigationBar
                && mNavigationBar != null && mNavigationBar.isVisibleLw());
                && mNavigationBar != null && mNavigationBar.isVisibleLw());
@@ -2991,6 +2992,27 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            attrs.gravity = Gravity.BOTTOM;
            attrs.gravity = Gravity.BOTTOM;
            mDockLayer = win.getSurfaceLayer();
            mDockLayer = win.getSurfaceLayer();
        } else {
        } else {

            // Default policy decor for the default display
            dcf.left = mSystemLeft;
            dcf.top = mSystemTop;
            dcf.right = mSystemRight;
            dcf.bottom = mSystemBottom;
            if (attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW
                    && attrs.type <= WindowManager.LayoutParams.LAST_APPLICATION_WINDOW) {
                if ((attrs.flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) == 0
                        && (sysUiFl & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0
                        && (sysUiFl & View.SYSTEM_UI_FLAG_TRANSPARENT_STATUS) == 0) {
                    // Ensure policy decor includes status bar
                    dcf.top = mStableTop;
                }
                if ((sysUiFl & View.SYSTEM_UI_FLAG_TRANSPARENT_NAVIGATION) == 0) {
                    // Ensure policy decor includes navigation bar
                    dcf.bottom = mStableBottom;
                    dcf.right = mStableRight;
                }
            }

            if ((fl & (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR))
            if ((fl & (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR))
                    == (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR)) {
                    == (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR)) {
                if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle() 
                if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle() 
@@ -3026,7 +3048,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                        if (DEBUG_LAYOUT) Slog.v(TAG, String.format(
                        if (DEBUG_LAYOUT) Slog.v(TAG, String.format(
                                        "Laying out status bar window: (%d,%d - %d,%d)",
                                        "Laying out status bar window: (%d,%d - %d,%d)",
                                        pf.left, pf.top, pf.right, pf.bottom));
                                        pf.left, pf.top, pf.right, pf.bottom));
                    } else if ((attrs.flags&FLAG_LAYOUT_IN_OVERSCAN) != 0
                    } else if ((fl & FLAG_LAYOUT_IN_OVERSCAN) != 0
                            && attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW
                            && attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW
                            && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) {
                            && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) {
                        // Asking to layout into the overscan region, so give it that pure
                        // Asking to layout into the overscan region, so give it that pure
@@ -3071,7 +3093,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                        of.bottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight;
                        of.bottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight;
                    }
                    }


                    if ((attrs.flags&FLAG_FULLSCREEN) == 0) {
                    if ((fl & FLAG_FULLSCREEN) == 0) {
                        if (adjust != SOFT_INPUT_ADJUST_RESIZE) {
                        if (adjust != SOFT_INPUT_ADJUST_RESIZE) {
                            cf.left = mDockLeft;
                            cf.left = mDockLeft;
                            cf.top = mDockTop;
                            cf.top = mDockTop;
@@ -3093,7 +3115,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                        cf.right = mRestrictedScreenLeft + mRestrictedScreenWidth;
                        cf.right = mRestrictedScreenLeft + mRestrictedScreenWidth;
                        cf.bottom = mRestrictedScreenTop + mRestrictedScreenHeight;
                        cf.bottom = mRestrictedScreenTop + mRestrictedScreenHeight;
                    }
                    }

                    applyStableConstraints(sysUiFl, fl, cf);
                    applyStableConstraints(sysUiFl, fl, cf);
                    if (adjust != SOFT_INPUT_ADJUST_NOTHING) {
                    if (adjust != SOFT_INPUT_ADJUST_NOTHING) {
                        vf.left = mCurLeft;
                        vf.left = mCurLeft;
@@ -3164,7 +3185,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                            = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth;
                            = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth;
                    pf.bottom = df.bottom = of.bottom = cf.bottom
                    pf.bottom = df.bottom = of.bottom = cf.bottom
                            = mUnrestrictedScreenTop + mUnrestrictedScreenHeight;
                            = mUnrestrictedScreenTop + mUnrestrictedScreenHeight;
                } else if ((attrs.flags & FLAG_LAYOUT_IN_OVERSCAN) != 0
                } else if ((fl & FLAG_LAYOUT_IN_OVERSCAN) != 0
                        && attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW
                        && attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW
                        && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) {
                        && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) {
                    // Asking to layout into the overscan region, so give it that pure
                    // Asking to layout into the overscan region, so give it that pure
@@ -3275,9 +3296,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                + String.format(" flags=0x%08x", fl)
                + String.format(" flags=0x%08x", fl)
                + " pf=" + pf.toShortString() + " df=" + df.toShortString()
                + " pf=" + pf.toShortString() + " df=" + df.toShortString()
                + " of=" + of.toShortString()
                + " of=" + of.toShortString()
                + " cf=" + cf.toShortString() + " vf=" + vf.toShortString());
                + " cf=" + cf.toShortString() + " vf=" + vf.toShortString()
                + " dcf=" + dcf.toShortString());


        win.computeFrameLw(pf, df, of, cf, vf);
        win.computeFrameLw(pf, df, of, cf, vf, dcf);


        // Dock windows carve out the bottom of the screen, so normal windows
        // Dock windows carve out the bottom of the screen, so normal windows
        // can't appear underneath them.
        // can't appear underneath them.
+2 −4
Original line number Original line Diff line number Diff line
@@ -440,7 +440,6 @@ public class WindowManagerService extends IWindowManager.Stub
            = new ArrayList<IRotationWatcher>();
            = new ArrayList<IRotationWatcher>();
    int mDeferredRotationPauseCount;
    int mDeferredRotationPauseCount;


    final Rect mSystemDecorRect = new Rect();
    int mSystemDecorLayer = 0;
    int mSystemDecorLayer = 0;
    final Rect mScreenRect = new Rect();
    final Rect mScreenRect = new Rect();


@@ -8202,7 +8201,7 @@ public class WindowManagerService extends IWindowManager.Stub
        mPolicy.beginLayoutLw(isDefaultDisplay, dw, dh, mRotation);
        mPolicy.beginLayoutLw(isDefaultDisplay, dw, dh, mRotation);
        if (isDefaultDisplay) {
        if (isDefaultDisplay) {
            // Not needed on non-default displays.
            // Not needed on non-default displays.
            mSystemDecorLayer = mPolicy.getSystemDecorRectLw(mSystemDecorRect);
            mSystemDecorLayer = mPolicy.getSystemDecorLayerLw();
            mScreenRect.set(0, 0, dw, dh);
            mScreenRect.set(0, 0, dw, dh);
        }
        }


@@ -10410,7 +10409,6 @@ public class WindowManagerService extends IWindowManager.Stub
                }
                }
                pw.println();
                pw.println();
        if (dumpAll) {
        if (dumpAll) {
            pw.print("  mSystemDecorRect="); pw.print(mSystemDecorRect.toShortString());
            pw.print(" mSystemDecorLayer="); pw.print(mSystemDecorLayer);
            pw.print(" mSystemDecorLayer="); pw.print(mSystemDecorLayer);
                    pw.print(" mScreenRect="); pw.println(mScreenRect.toShortString());
                    pw.print(" mScreenRect="); pw.println(mScreenRect.toShortString());
            if (mLastStatusBarVisibility != 0) {
            if (mLastStatusBarVisibility != 0) {
+5 −1
Original line number Original line Diff line number Diff line
@@ -218,6 +218,7 @@ final class WindowState implements WindowManagerPolicy.WindowState {
    final Rect mContentFrame = new Rect();
    final Rect mContentFrame = new Rect();
    final Rect mParentFrame = new Rect();
    final Rect mParentFrame = new Rect();
    final Rect mVisibleFrame = new Rect();
    final Rect mVisibleFrame = new Rect();
    final Rect mDecorFrame = new Rect();


    boolean mContentChanged;
    boolean mContentChanged;


@@ -458,7 +459,7 @@ final class WindowState implements WindowManagerPolicy.WindowState {
    }
    }


    @Override
    @Override
    public void computeFrameLw(Rect pf, Rect df, Rect of, Rect cf, Rect vf) {
    public void computeFrameLw(Rect pf, Rect df, Rect of, Rect cf, Rect vf, Rect dcf) {
        mHaveFrame = true;
        mHaveFrame = true;


        TaskStack stack = mAppToken != null ? getStack() : null;
        TaskStack stack = mAppToken != null ? getStack() : null;
@@ -524,6 +525,7 @@ final class WindowState implements WindowManagerPolicy.WindowState {
        mOverscanFrame.set(of);
        mOverscanFrame.set(of);
        mContentFrame.set(cf);
        mContentFrame.set(cf);
        mVisibleFrame.set(vf);
        mVisibleFrame.set(vf);
        mDecorFrame.set(dcf);


        final int fw = mFrame.width();
        final int fw = mFrame.width();
        final int fh = mFrame.height();
        final int fh = mFrame.height();
@@ -1404,6 +1406,8 @@ final class WindowState implements WindowManagerPolicy.WindowState {
            pw.print(prefix); pw.print("    content="); mContentFrame.printShortString(pw);
            pw.print(prefix); pw.print("    content="); mContentFrame.printShortString(pw);
                    pw.print(" visible="); mVisibleFrame.printShortString(pw);
                    pw.print(" visible="); mVisibleFrame.printShortString(pw);
                    pw.println();
                    pw.println();
            pw.print(prefix); pw.print("    decor="); mDecorFrame.printShortString(pw);
                    pw.println();
            pw.print(prefix); pw.print("Cur insets: overscan=");
            pw.print(prefix); pw.print("Cur insets: overscan=");
                    mOverscanInsets.printShortString(pw);
                    mOverscanInsets.printShortString(pw);
                    pw.print(" content="); mContentInsets.printShortString(pw);
                    pw.print(" content="); mContentInsets.printShortString(pw);
+5 −3
Original line number Original line Diff line number Diff line
@@ -1100,12 +1100,14 @@ class WindowStateAnimator {
            } else {
            } else {
                applyDecorRect(mService.mScreenRect);
                applyDecorRect(mService.mScreenRect);
            }
            }
        } else if (w.mAttrs.type == WindowManager.LayoutParams.TYPE_UNIVERSE_BACKGROUND) {
        } else if (w.mAttrs.type == WindowManager.LayoutParams.TYPE_UNIVERSE_BACKGROUND
            // The universe background isn't cropped.
                || w.mDecorFrame.isEmpty()) {
            // The universe background isn't cropped, nor windows without policy decor.
            w.mSystemDecorRect.set(0, 0, w.mCompatFrame.width(),
            w.mSystemDecorRect.set(0, 0, w.mCompatFrame.width(),
                    w.mCompatFrame.height());
                    w.mCompatFrame.height());
        } else {
        } else {
            applyDecorRect(mService.mSystemDecorRect);
            // Crop to the system decor specified by policy.
            applyDecorRect(w.mDecorFrame);
        }
        }


        if (!w.mSystemDecorRect.equals(w.mLastSystemDecorRect)) {
        if (!w.mSystemDecorRect.equals(w.mLastSystemDecorRect)) {