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

Commit 6bab4cf5 authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Fixed bug with cropping out drop shadow for pinned stack.

The surface crop we apply to windows in the pinned stack was based on
the stack bounds. However, the windows in the pinned stack have a
drop shadow that extends outside the stack bounds to make them appear
floating so they were out displayed. We now extand the crop for windows
in stacks that have shadows and occupy the entire stack space to that
their drop shadows are visible.

Bug: 27364161
Change-Id: Ic2a94b091a93e7145a5455b494f0b689118eb5e3
parent 03f1e026
Loading
Loading
Loading
Loading
+3 −2
Original line number Original line Diff line number Diff line
@@ -2397,8 +2397,8 @@ final class WindowState implements WindowManagerPolicy.WindowState {
            pw.print(prefix); pw.print("mToken="); pw.println(mToken);
            pw.print(prefix); pw.print("mToken="); pw.println(mToken);
            pw.print(prefix); pw.print("mRootToken="); pw.println(mRootToken);
            pw.print(prefix); pw.print("mRootToken="); pw.println(mRootToken);
            if (mAppToken != null) {
            if (mAppToken != null) {
                pw.print(prefix); pw.print("mAppToken="); pw.print(mAppToken);
                pw.print(prefix); pw.print("mAppToken="); pw.println(mAppToken);
                pw.print(" isAnimatingWithSavedSurface()=");
                pw.print(prefix); pw.print(" isAnimatingWithSavedSurface()=");
                pw.print(isAnimatingWithSavedSurface());
                pw.print(isAnimatingWithSavedSurface());
                pw.print(" mAppDied=");pw.println(mAppDied);
                pw.print(" mAppDied=");pw.println(mAppDied);
            }
            }
@@ -2483,6 +2483,7 @@ final class WindowState implements WindowManagerPolicy.WindowState {
                    pw.print(" content="); mContentInsets.printShortString(pw);
                    pw.print(" content="); mContentInsets.printShortString(pw);
                    pw.print(" visible="); mVisibleInsets.printShortString(pw);
                    pw.print(" visible="); mVisibleInsets.printShortString(pw);
                    pw.print(" stable="); mStableInsets.printShortString(pw);
                    pw.print(" stable="); mStableInsets.printShortString(pw);
                    pw.print(" surface="); mAttrs.surfaceInsets.printShortString(pw);
                    pw.print(" outsets="); mOutsets.printShortString(pw);
                    pw.print(" outsets="); mOutsets.printShortString(pw);
                    pw.println();
                    pw.println();
            pw.print(prefix); pw.print("Lst insets: overscan=");
            pw.print(prefix); pw.print("Lst insets: overscan=");
+31 −19
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package com.android.server.wm;
package com.android.server.wm;


import static android.app.ActivityManager.StackId;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
import static android.view.WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
import static android.view.WindowManager.LayoutParams.FLAG_SCALED;
import static android.view.WindowManager.LayoutParams.FLAG_SCALED;
@@ -1170,8 +1171,8 @@ class WindowStateAnimator {
            return;
            return;
        }
        }
        final DisplayInfo displayInfo = displayContent.getDisplayInfo();
        final DisplayInfo displayInfo = displayContent.getDisplayInfo();
        if (DEBUG_WINDOW_CROP) Slog.d(TAG, "Updating crop for window: " + w + ", " + "mLastCrop=" +
        if (DEBUG_WINDOW_CROP) Slog.d(TAG,
                mLastClipRect);
                "Updating crop win=" + w + " mLastCrop=" + mLastClipRect);


        // Need to recompute a new system decor rect each time.
        // Need to recompute a new system decor rect each time.
        if (!w.isDefaultDisplay()) {
        if (!w.isDefaultDisplay()) {
@@ -1196,8 +1197,8 @@ class WindowStateAnimator {
        } else {
        } else {
            // Crop to the system decor specified by policy.
            // Crop to the system decor specified by policy.
            calculateSystemDecorRect();
            calculateSystemDecorRect();
            if (DEBUG_WINDOW_CROP) Slog.d(TAG, "Applying decor to crop for " + w + ", mDecorFrame="
            if (DEBUG_WINDOW_CROP) Slog.d(TAG, "Applying decor to crop win=" + w + " mDecorFrame="
                    + w.mDecorFrame + ", mSystemDecorRect=" + mSystemDecorRect);
                    + w.mDecorFrame + " mSystemDecorRect=" + mSystemDecorRect);
        }
        }


        final boolean fullscreen = w.isFrameFullscreen(displayInfo);
        final boolean fullscreen = w.isFrameFullscreen(displayInfo);
@@ -1207,8 +1208,8 @@ class WindowStateAnimator {
        // We use the clip rect as provided by the tranformation for non-fullscreen windows to
        // We use the clip rect as provided by the tranformation for non-fullscreen windows to
        // avoid premature clipping with the system decor rect.
        // avoid premature clipping with the system decor rect.
        clipRect.set((mHasClipRect && !fullscreen) ? mClipRect : mSystemDecorRect);
        clipRect.set((mHasClipRect && !fullscreen) ? mClipRect : mSystemDecorRect);
        if (DEBUG_WINDOW_CROP) Slog.d(TAG, "Initial clip rect: " + clipRect + ", mHasClipRect="
        if (DEBUG_WINDOW_CROP) Slog.d(TAG, "win=" + w + " Initial clip rect: " + clipRect
                + mHasClipRect + ", fullscreen=" + fullscreen);
                + " mHasClipRect=" + mHasClipRect + " fullscreen=" + fullscreen);


        if (isFreeformResizing && !w.isChildWindow()) {
        if (isFreeformResizing && !w.isChildWindow()) {
            // For freeform resizing non child windows, we are using the big surface positioned
            // For freeform resizing non child windows, we are using the big surface positioned
@@ -1235,7 +1236,8 @@ class WindowStateAnimator {


        finalClipRect.setEmpty();
        finalClipRect.setEmpty();
        adjustCropToStackBounds(w, clipRect, finalClipRect, isFreeformResizing);
        adjustCropToStackBounds(w, clipRect, finalClipRect, isFreeformResizing);
        if (DEBUG_WINDOW_CROP) Slog.d(TAG, "Clip rect after stack adjustment=" + clipRect);
        if (DEBUG_WINDOW_CROP) Slog.d(TAG,
                "win=" + w + " Clip rect after stack adjustment=" + clipRect);


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


@@ -1246,6 +1248,8 @@ class WindowStateAnimator {
    }
    }


    void updateSurfaceWindowCrop(Rect clipRect, Rect finalClipRect, boolean recoveringMemory) {
    void updateSurfaceWindowCrop(Rect clipRect, Rect finalClipRect, boolean recoveringMemory) {
        if (DEBUG_WINDOW_CROP) Slog.d(TAG, "updateSurfaceWindowCrop: win=" + mWin
                + " clipRect=" + clipRect + " finalClipRect=" + finalClipRect);
        if (!clipRect.equals(mLastClipRect)) {
        if (!clipRect.equals(mLastClipRect)) {
            mLastClipRect.set(clipRect);
            mLastClipRect.set(clipRect);
            mSurfaceController.setCropInTransaction(clipRect, recoveringMemory);
            mSurfaceController.setCropInTransaction(clipRect, recoveringMemory);
@@ -1286,13 +1290,14 @@ class WindowStateAnimator {


        final TaskStack stack = task.mStack;
        final TaskStack stack = task.mStack;
        stack.getDimBounds(mTmpStackBounds);
        stack.getDimBounds(mTmpStackBounds);
        final Rect surfaceInsets = w.getAttrs().surfaceInsets;
        // 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
        // hardcoding it, we use surface coordinates.
        // hardcoding it, we use surface coordinates.
        final int frameX = isFreeformResizing ? (int) mSurfaceController.getX() :
        final int frameX = isFreeformResizing ? (int) mSurfaceController.getX() :
                w.mFrame.left + mWin.mXOffset - w.getAttrs().surfaceInsets.left;
                w.mFrame.left + mWin.mXOffset - surfaceInsets.left;
        final int frameY = isFreeformResizing ? (int) mSurfaceController.getY() :
        final int frameY = isFreeformResizing ? (int) mSurfaceController.getY() :
                w.mFrame.top + mWin.mYOffset - w.getAttrs().surfaceInsets.top;
                w.mFrame.top + mWin.mYOffset - surfaceInsets.top;


        // If we are animating, we either apply the clip before applying all the animation
        // If we are animating, we either apply the clip before applying all the animation
        // transformation or after all the transformation.
        // transformation or after all the transformation.
@@ -1303,6 +1308,15 @@ class WindowStateAnimator {
        if (useFinalClipRect) {
        if (useFinalClipRect) {
            finalClipRect.set(mTmpStackBounds);
            finalClipRect.set(mTmpStackBounds);
        } else {
        } else {
            if (StackId.hasWindowShadow(stack.mStackId)
                    && !StackId.isTaskResizeAllowed(stack.mStackId)) {
                // The windows in this stack display drop shadows and the fill the entire stack
                // area. Adjust the stack bounds we will use to cropping take into account the
                // offsets we use to display the drop shadow so it doesn't get cropped.
                mTmpStackBounds.inset(-surfaceInsets.left, -surfaceInsets.top,
                        -surfaceInsets.right, -surfaceInsets.bottom);
            }

            clipRect.left = Math.max(0,
            clipRect.left = Math.max(0,
                    Math.max(mTmpStackBounds.left, frameX + clipRect.left) - frameX);
                    Math.max(mTmpStackBounds.left, frameX + clipRect.left) - frameX);
            clipRect.top = Math.max(0,
            clipRect.top = Math.max(0,
@@ -1348,21 +1362,19 @@ class WindowStateAnimator {
            // past where the system would have cropped us
            // past where the system would have cropped us
            mTmpClipRect.set(0, 0, mTmpSize.width(), mTmpSize.height());
            mTmpClipRect.set(0, 0, mTmpSize.width(), mTmpSize.height());
            mTmpFinalClipRect.setEmpty();
            mTmpFinalClipRect.setEmpty();
            updateSurfaceWindowCrop(mTmpClipRect, mTmpFinalClipRect, recoveringMemory);
        } else {
        } else {
            mSurfaceController.setPositionInTransaction(mTmpSize.left, mTmpSize.top,
            mSurfaceController.setPositionInTransaction(mTmpSize.left, mTmpSize.top,
                    recoveringMemory);
                    recoveringMemory);
            updateSurfaceWindowCrop(mTmpClipRect, mTmpFinalClipRect, recoveringMemory);
        }
        }


        updateSurfaceWindowCrop(mTmpClipRect, mTmpFinalClipRect, recoveringMemory);


        mSurfaceController.setMatrixInTransaction(mDsDx * w.mHScale * extraHScale,
        mSurfaceController.setMatrixInTransaction(mDsDx * w.mHScale * extraHScale,
                mDtDx * w.mVScale * extraVScale,
                mDtDx * w.mVScale * extraVScale,
                mDsDy * w.mHScale * extraHScale,
                mDsDy * w.mHScale * extraHScale,
                mDtDy * w.mVScale * extraVScale, recoveringMemory);
                mDtDy * w.mVScale * extraVScale, recoveringMemory);
        mSurfaceResized = mSurfaceController.setSizeInTransaction(
        mSurfaceResized = mSurfaceController.setSizeInTransaction(
                mTmpSize.width(), mTmpSize.height(),
                mTmpSize.width(), mTmpSize.height(), recoveringMemory);
                recoveringMemory);


        if (mSurfaceResized) {
        if (mSurfaceResized) {
            mReportSurfaceResized = true;
            mReportSurfaceResized = true;
@@ -1772,7 +1784,7 @@ class WindowStateAnimator {
            pw.print(prefix); pw.print("mAnimating="); pw.print(mAnimating);
            pw.print(prefix); pw.print("mAnimating="); pw.print(mAnimating);
                    pw.print(" mLocalAnimating="); pw.print(mLocalAnimating);
                    pw.print(" mLocalAnimating="); pw.print(mLocalAnimating);
                    pw.print(" mAnimationIsEntrance="); pw.print(mAnimationIsEntrance);
                    pw.print(" mAnimationIsEntrance="); pw.print(mAnimationIsEntrance);
                    pw.print(" mAnimation="); pw.println(mAnimation);
                    pw.print(" mAnimation="); pw.print(mAnimation);
                    pw.print(" mStackClip="); pw.println(mStackClip);
                    pw.print(" mStackClip="); pw.println(mStackClip);
        }
        }
        if (mHasTransformation || mHasLocalTransformation) {
        if (mHasTransformation || mHasLocalTransformation) {
@@ -1790,9 +1802,9 @@ class WindowStateAnimator {
            pw.print(prefix); pw.print(" mLastHidden="); pw.println(mLastHidden);
            pw.print(prefix); pw.print(" mLastHidden="); pw.println(mLastHidden);
            pw.print(prefix); pw.print("mSystemDecorRect="); mSystemDecorRect.printShortString(pw);
            pw.print(prefix); pw.print("mSystemDecorRect="); mSystemDecorRect.printShortString(pw);
            pw.print(" last="); mLastSystemDecorRect.printShortString(pw);
            pw.print(" last="); mLastSystemDecorRect.printShortString(pw);
            if (mHasClipRect) {
            pw.print(" mHasClipRect="); pw.print(mHasClipRect);
            pw.print(" mLastClipRect="); mLastClipRect.printShortString(pw);
            pw.print(" mLastClipRect="); mLastClipRect.printShortString(pw);
            }

            if (!mLastFinalClipRect.isEmpty()) {
            if (!mLastFinalClipRect.isEmpty()) {
                pw.print(" mLastFinalClipRect="); mLastFinalClipRect.printShortString(pw);
                pw.print(" mLastFinalClipRect="); mLastFinalClipRect.printShortString(pw);
            }
            }