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

Commit 16b83907 authored by Wale Ogunwale's avatar Wale Ogunwale Committed by Android (Google) Code Review
Browse files

Merge "Fixed bug where stack crop wasn't applied when it should"

parents 83e3563e 69cf50f7
Loading
Loading
Loading
Loading
+23 −9
Original line number Original line Diff line number Diff line
@@ -67,7 +67,7 @@ public class WindowAnimator {
    private final WindowSurfacePlacer mWindowPlacerLocked;
    private final WindowSurfacePlacer mWindowPlacerLocked;


    /** Is any window animating? */
    /** Is any window animating? */
    boolean mAnimating;
    private boolean mAnimating;


    /** Is any app window animating? */
    /** Is any app window animating? */
    boolean mAppWindowAnimating;
    boolean mAppWindowAnimating;
@@ -168,7 +168,8 @@ public class WindowAnimator {
                    appAnimator.wasAnimating = appAnimator.animating;
                    appAnimator.wasAnimating = appAnimator.animating;
                    if (appAnimator.stepAnimationLocked(mCurrentTime, displayId)) {
                    if (appAnimator.stepAnimationLocked(mCurrentTime, displayId)) {
                        appAnimator.animating = true;
                        appAnimator.animating = true;
                        mAnimating = mAppWindowAnimating = true;
                        setAnimating(true);
                        mAppWindowAnimating = true;
                    } else if (appAnimator.wasAnimating) {
                    } else if (appAnimator.wasAnimating) {
                        // stopped animating, do one more pass through the layout
                        // stopped animating, do one more pass through the layout
                        setAppLayoutChanges(appAnimator,
                        setAppLayoutChanges(appAnimator,
@@ -186,7 +187,8 @@ public class WindowAnimator {
                final AppWindowAnimator appAnimator = exitingAppTokens.get(i).mAppAnimator;
                final AppWindowAnimator appAnimator = exitingAppTokens.get(i).mAppAnimator;
                appAnimator.wasAnimating = appAnimator.animating;
                appAnimator.wasAnimating = appAnimator.animating;
                if (appAnimator.stepAnimationLocked(mCurrentTime, displayId)) {
                if (appAnimator.stepAnimationLocked(mCurrentTime, displayId)) {
                    mAnimating = mAppWindowAnimating = true;
                    setAnimating(true);
                    mAppWindowAnimating = true;
                } else if (appAnimator.wasAnimating) {
                } else if (appAnimator.wasAnimating) {
                    // stopped animating, do one more pass through the layout
                    // stopped animating, do one more pass through the layout
                    setAppLayoutChanges(appAnimator,
                    setAppLayoutChanges(appAnimator,
@@ -282,7 +284,7 @@ public class WindowAnimator {
                final boolean wasAnimating = winAnimator.mWasAnimating;
                final boolean wasAnimating = winAnimator.mWasAnimating;
                final boolean nowAnimating = winAnimator.stepAnimationLocked(mCurrentTime);
                final boolean nowAnimating = winAnimator.stepAnimationLocked(mCurrentTime);
                winAnimator.mWasAnimating = nowAnimating;
                winAnimator.mWasAnimating = nowAnimating;
                mAnimating |= nowAnimating;
                orAnimating(nowAnimating);


                if (DEBUG_WALLPAPER) {
                if (DEBUG_WALLPAPER) {
                    Slog.v(TAG, win + ": wasAnimating=" + wasAnimating +
                    Slog.v(TAG, win + ": wasAnimating=" + wasAnimating +
@@ -546,7 +548,7 @@ public class WindowAnimator {
                        }
                        }
                    }
                    }
                }
                }
                mAnimating = true;
                setAnimating(true);
            }
            }


            // If this window's app token is running a detached wallpaper
            // If this window's app token is running a detached wallpaper
@@ -617,7 +619,7 @@ public class WindowAnimator {


                            // We can now show all of the drawn windows!
                            // We can now show all of the drawn windows!
                            if (!mService.mOpeningApps.contains(wtoken)) {
                            if (!mService.mOpeningApps.contains(wtoken)) {
                                mAnimating |= appAnimator.showAllWindowsLocked();
                                orAnimating(appAnimator.showAllWindowsLocked());
                            }
                            }
                        }
                        }
                    }
                    }
@@ -636,7 +638,7 @@ public class WindowAnimator {
        mCurrentTime = frameTimeNs / TimeUtils.NANOS_PER_MS;
        mCurrentTime = frameTimeNs / TimeUtils.NANOS_PER_MS;
        mBulkUpdateParams = SET_ORIENTATION_CHANGE_COMPLETE;
        mBulkUpdateParams = SET_ORIENTATION_CHANGE_COMPLETE;
        boolean wasAnimating = mAnimating;
        boolean wasAnimating = mAnimating;
        mAnimating = false;
        setAnimating(false);
        mAppWindowAnimating = false;
        mAppWindowAnimating = false;
        if (DEBUG_WINDOW_TRACE) {
        if (DEBUG_WINDOW_TRACE) {
            Slog.i(TAG, "!!! animate: entry time=" + mCurrentTime);
            Slog.i(TAG, "!!! animate: entry time=" + mCurrentTime);
@@ -657,7 +659,7 @@ public class WindowAnimator {
                        displayAnimator.mScreenRotationAnimation;
                        displayAnimator.mScreenRotationAnimation;
                if (screenRotationAnimation != null && screenRotationAnimation.isAnimating()) {
                if (screenRotationAnimation != null && screenRotationAnimation.isAnimating()) {
                    if (screenRotationAnimation.stepAnimationLocked(mCurrentTime)) {
                    if (screenRotationAnimation.stepAnimationLocked(mCurrentTime)) {
                        mAnimating = true;
                        setAnimating(true);
                    } else {
                    } else {
                        mBulkUpdateParams |= SET_UPDATE_ROTATION;
                        mBulkUpdateParams |= SET_UPDATE_ROTATION;
                        screenRotationAnimation.kill();
                        screenRotationAnimation.kill();
@@ -697,7 +699,7 @@ public class WindowAnimator {
                    screenRotationAnimation.updateSurfacesInTransaction();
                    screenRotationAnimation.updateSurfacesInTransaction();
                }
                }


                mAnimating |= mService.getDisplayContentLocked(displayId).animateDimLayers();
                orAnimating(mService.getDisplayContentLocked(displayId).animateDimLayers());


                //TODO (multidisplay): Magnification is supported only for the default display.
                //TODO (multidisplay): Magnification is supported only for the default display.
                if (mService.mAccessibilityController != null
                if (mService.mAccessibilityController != null
@@ -920,4 +922,16 @@ public class WindowAnimator {
    private class DisplayContentsAnimator {
    private class DisplayContentsAnimator {
        ScreenRotationAnimation mScreenRotationAnimation = null;
        ScreenRotationAnimation mScreenRotationAnimation = null;
    }
    }

    boolean isAnimating() {
        return mAnimating;
    }

    void setAnimating(boolean animating) {
        mAnimating = animating;
    }

    void orAnimating(boolean animating) {
        mAnimating |= animating;
    }
}
}
+1 −1
Original line number Original line Diff line number Diff line
@@ -7688,7 +7688,7 @@ public class WindowManagerService extends IWindowManager.Stub
                    synchronized (mWindowMap) {
                    synchronized (mWindowMap) {
                        // Since we're holding both mWindowMap and mAnimator we don't need to
                        // Since we're holding both mWindowMap and mAnimator we don't need to
                        // hold mAnimator.mLayoutToAnim.
                        // hold mAnimator.mLayoutToAnim.
                        if (mAnimator.mAnimating || mAnimationScheduled) {
                        if (mAnimator.isAnimating() || mAnimationScheduled) {
                            // If we are animating, don't do the gc now but
                            // If we are animating, don't do the gc now but
                            // delay a bit so we don't interrupt the animation.
                            // delay a bit so we don't interrupt the animation.
                            sendEmptyMessageDelayed(H.FORCE_GC, 2000);
                            sendEmptyMessageDelayed(H.FORCE_GC, 2000);
+35 −30
Original line number Original line Diff line number Diff line
@@ -1085,7 +1085,7 @@ class WindowStateAnimator {
        } else if (w.mDecorFrame.isEmpty()) {
        } else if (w.mDecorFrame.isEmpty()) {
            // Windows without policy decor aren't cropped.
            // Windows without policy decor aren't cropped.
            w.mSystemDecorRect.set(0, 0, w.mCompatFrame.width(), w.mCompatFrame.height());
            w.mSystemDecorRect.set(0, 0, w.mCompatFrame.width(), w.mCompatFrame.height());
        } else if (w.mAttrs.type == LayoutParams.TYPE_WALLPAPER && mAnimator.mAnimating) {
        } else if (w.mAttrs.type == LayoutParams.TYPE_WALLPAPER && mAnimator.isAnimating()) {
            // If we're animating, the wallpaper crop should only be updated at the end of the
            // If we're animating, the wallpaper crop should only be updated at the end of the
            // animation.
            // animation.
            mTmpClipRect.set(w.mSystemDecorRect);
            mTmpClipRect.set(w.mSystemDecorRect);
@@ -1125,12 +1125,8 @@ class WindowStateAnimator {
        // The clip rect was generated assuming (0,0) as the window origin,
        // The clip rect was generated assuming (0,0) as the window origin,
        // so we need to translate to match the actual surface coordinates.
        // so we need to translate to match the actual surface coordinates.
        clipRect.offset(attrs.surfaceInsets.left, attrs.surfaceInsets.top);
        clipRect.offset(attrs.surfaceInsets.left, attrs.surfaceInsets.top);
        // We don't want to clip to stack bounds windows that are currently doing entrance
        // animation for docked window, otherwise the animating window will be suddenly cut off.


        if (!(mAnimator.mAnimating && w.inDockedWorkspace())) {
        adjustCropToStackBounds(w, clipRect, isFreeformResizing);
        adjustCropToStackBounds(w, clipRect, isFreeformResizing);
        }


        w.transformFromScreenToSurfaceSpace(clipRect);
        w.transformFromScreenToSurfaceSpace(clipRect);


@@ -1143,12 +1139,22 @@ class WindowStateAnimator {
    private void adjustCropToStackBounds(WindowState w, Rect clipRect, boolean isFreeformResizing) {
    private void adjustCropToStackBounds(WindowState w, Rect clipRect, boolean isFreeformResizing) {
        final AppWindowToken appToken = w.mAppToken;
        final AppWindowToken appToken = w.mAppToken;
        final Task task = w.getTask();
        final Task task = w.getTask();
        // We don't apply the the stack bounds to the window that is being replaced, because it was
        if (task == null || !appToken.mCropWindowsToStack) {
        // living in a different stack. If we suddenly crop it to the new stack bounds, it might
            return;
        // get cut off. We don't want it to happen, so we let it ignore the stack bounds until it
        }
        // gets removed. The window that will replace it will abide them.

        if (task != null && appToken.mCropWindowsToStack && !appToken.mWillReplaceWindow) {
        // We don't apply the stack bounds crop if:
            TaskStack stack = task.mStack;
        // 1. The window is currently animating docked mode, otherwise the animating window will be
        // suddenly cut off.
        // 2. The window that is being replaced during animation, because it was living in a
        // different stack. If we suddenly crop it to the new stack bounds, it might get cut off.
        // We don't want it to happen, so we let it ignore the stack bounds until it gets removed.
        // The window that will replace it will abide them.
        if (isAnimating() && (appToken.mWillReplaceWindow || w.inDockedWorkspace())) {
            return;
        }

        final TaskStack stack = task.mStack;
        stack.getDimBounds(mTmpStackBounds);
        stack.getDimBounds(mTmpStackBounds);
        // When we resize we use the big surface approach, which means we can't trust the
        // When we resize we use the big surface approach, which means we can't trust the
        // window frame bounds anymore. Instead, the window will be placed at 0, 0, but to avoid
        // window frame bounds anymore. Instead, the window will be placed at 0, 0, but to avoid
@@ -1168,7 +1174,6 @@ class WindowStateAnimator {
        clipRect.bottom = Math.max(0,
        clipRect.bottom = Math.max(0,
                Math.min(mTmpStackBounds.bottom, frameY + clipRect.bottom) - frameY);
                Math.min(mTmpStackBounds.bottom, frameY + clipRect.bottom) - frameY);
    }
    }
    }


    void setSurfaceBoundariesLocked(final boolean recoveringMemory) {
    void setSurfaceBoundariesLocked(final boolean recoveringMemory) {
        final WindowState w = mWin;
        final WindowState w = mWin;
+4 −7
Original line number Original line Diff line number Diff line
@@ -542,11 +542,8 @@ class WindowSurfacePlacer {


        mService.scheduleAnimationLocked();
        mService.scheduleAnimationLocked();


        if (DEBUG_WINDOW_TRACE) {
        if (DEBUG_WINDOW_TRACE) Slog.e(TAG,
            Slog.e(TAG,
                "performSurfacePlacementInner exit: animating=" + mService.mAnimator.isAnimating());
                    "performSurfacePlacementInner exit: animating="
                            + mService.mAnimator.mAnimating);
        }
    }
    }


    private void applySurfaceChangesTransaction(boolean recoveringMemory, int numDisplays,
    private void applySurfaceChangesTransaction(boolean recoveringMemory, int numDisplays,
@@ -1184,7 +1181,7 @@ class WindowSurfacePlacer {
                    ">>> OPEN TRANSACTION handleAppTransitionReadyLocked()");
                    ">>> OPEN TRANSACTION handleAppTransitionReadyLocked()");
            SurfaceControl.openTransaction();
            SurfaceControl.openTransaction();
            try {
            try {
                mService.mAnimator.mAnimating |= appAnimator.showAllWindowsLocked();
                mService.mAnimator.orAnimating(appAnimator.showAllWindowsLocked());
            } finally {
            } finally {
                SurfaceControl.closeTransaction();
                SurfaceControl.closeTransaction();
                if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
                if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
@@ -1467,7 +1464,7 @@ class WindowSurfacePlacer {
                    appAnimator.mAllAppWinAnimators.add(wtoken.allAppWindows.get(j).mWinAnimator);
                    appAnimator.mAllAppWinAnimators.add(wtoken.allAppWindows.get(j).mWinAnimator);
                }
                }
                mService.mAnimator.mAppWindowAnimating |= appAnimator.isAnimating();
                mService.mAnimator.mAppWindowAnimating |= appAnimator.isAnimating();
                mService.mAnimator.mAnimating |= appAnimator.showAllWindowsLocked();
                mService.mAnimator.orAnimating(appAnimator.showAllWindowsLocked());
            }
            }
        }
        }
    }
    }