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

Commit b8fbfb4c authored by Filip Gruszczynski's avatar Filip Gruszczynski
Browse files

Fix recents from/to full screen app transition.

The window would get cutoff at the bottom due to the way we calculate
the stack crop. The crop seems to be applied on the window before
scaling/translation is applied, so we need to use windows frame
coordinates instead of surface position.

Change-Id: I0015b9c1d1fe8e7ce8b6d94dacb5a465ff956a0c
parent 5359893e
Loading
Loading
Loading
Loading
+6 −12
Original line number Diff line number Diff line
@@ -1283,8 +1283,6 @@ class WindowStateAnimator {
            mDtDy = tmpFloats[Matrix.MSCALE_Y];
            float x = tmpFloats[Matrix.MTRANS_X];
            float y = tmpFloats[Matrix.MTRANS_Y];
            int w = frame.width();
            int h = frame.height();
            mWin.mShownPosition.set((int) x, (int) y);

            mShownAlpha = mAlpha;
@@ -1381,7 +1379,6 @@ class WindowStateAnimator {
            // avoid premature clipping with the system decor rect.
            clipRect.set((mHasClipRect && !fullscreen) ? mClipRect : w.mSystemDecorRect);
        }

        // Expand the clip rect for surface insets.
        final WindowManager.LayoutParams attrs = w.mAttrs;
        clipRect.left -= attrs.surfaceInsets.left;
@@ -1395,17 +1392,14 @@ class WindowStateAnimator {
            // clip rect extends outside the system decor rect.
            clipRect.intersect(mClipRect);
        }

        // The clip rect was generated assuming (0,0) as the window origin,
        // so we need to translate to match the actual surface coordinates.
        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);
        }

        if (!clipRect.equals(mLastClipRect)) {
            mLastClipRect.set(clipRect);
            try {
@@ -1437,18 +1431,18 @@ class WindowStateAnimator {
        if (appToken != null && appToken.mCropWindowsToStack && !appToken.mReplacingWindow) {
            TaskStack stack = w.getTask().mStack;
            stack.getBounds(mTmpStackBounds);
            final int surfaceX = (int) mSurfaceX;
            final int surfaceY = (int) mSurfaceY;
            final int frameX = w.mFrame.left + mWin.mXOffset - w.getAttrs().surfaceInsets.left;
            final int frameY = w.mFrame.top + mWin.mYOffset - w.getAttrs().surfaceInsets.top;
            // We need to do some acrobatics with surface position, because their clip region is
            // relative to the inside of the surface, but the stack bounds aren't.
            clipRect.left = Math.max(0,
                    Math.max(mTmpStackBounds.left, surfaceX + clipRect.left) - surfaceX);
                    Math.max(mTmpStackBounds.left, frameX + clipRect.left) - frameX);
            clipRect.top = Math.max(0,
                    Math.max(mTmpStackBounds.top, surfaceY + clipRect.top) - surfaceY);
                    Math.max(mTmpStackBounds.top, frameY + clipRect.top) - frameY);
            clipRect.right = Math.max(0,
                    Math.min(mTmpStackBounds.right, surfaceX + clipRect.right) - surfaceX);
                    Math.min(mTmpStackBounds.right, frameX + clipRect.right) - frameX);
            clipRect.bottom = Math.max(0,
                    Math.min(mTmpStackBounds.bottom, surfaceY + clipRect.bottom) - surfaceY);
                    Math.min(mTmpStackBounds.bottom, frameY + clipRect.bottom) - frameY);
        }
    }