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

Commit 5d685f52 authored by Wei Sheng Shih's avatar Wei Sheng Shih Committed by Android (Google) Code Review
Browse files

Merge "Allow bar to be transparent if letterbox contains bar" into rvc-dev

parents 9ccee07a 39f818c7
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -395,14 +395,6 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
            return false;
        }

        /**
         * Returns true if the window has a letterbox and any part of that letterbox overlaps with
         * the given {@code rect}.
         */
        default boolean isLetterboxedOverlappingWith(Rect rect) {
            return false;
        }

        /** @return the current windowing mode of this window. */
        int getWindowingMode();

+3 −4
Original line number Diff line number Diff line
@@ -1419,11 +1419,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    }

    /**
     * @return {@code true} if there is a letterbox and any part of that letterbox overlaps with
     * the given {@code rect}.
     * @see Letterbox#notIntersectsOrFullyContains(Rect)
     */
    boolean isLetterboxOverlappingWith(Rect rect) {
        return mLetterbox != null && mLetterbox.isOverlappingWith(rect);
    boolean letterboxNotIntersectsOrFullyContains(Rect rect) {
        return mLetterbox == null || mLetterbox.notIntersectsOrFullyContains(rect);
    }

    static class Token extends IApplicationToken.Stub {
+1 −1
Original line number Diff line number Diff line
@@ -168,7 +168,7 @@ public class BarController {
    }

    boolean isTransparentAllowed(WindowState win) {
        return win == null || !win.isLetterboxedOverlappingWith(mContentFrame);
        return win == null || win.letterboxNotIntersectsOrFullyContains(mContentFrame);
    }

    boolean setBarShowingLw(final boolean show) {
+21 −20
Original line number Diff line number Diff line
@@ -77,10 +77,10 @@ public class Letterbox {
        mOuter.set(outer);
        mInner.set(inner);

        mTop.layout(outer.left, outer.top, inner.right, inner.top, surfaceOrigin);
        mLeft.layout(outer.left, inner.top, inner.left, outer.bottom, surfaceOrigin);
        mBottom.layout(inner.left, inner.bottom, outer.right, outer.bottom, surfaceOrigin);
        mRight.layout(inner.right, outer.top, outer.right, inner.bottom, surfaceOrigin);
        mTop.layout(outer.left, outer.top, outer.right, inner.top, surfaceOrigin);
        mLeft.layout(outer.left, outer.top, inner.left, outer.bottom, surfaceOrigin);
        mBottom.layout(outer.left, inner.bottom, outer.right, outer.bottom, surfaceOrigin);
        mRight.layout(inner.right, outer.top, outer.right, outer.bottom, surfaceOrigin);
    }


@@ -101,17 +101,29 @@ public class Letterbox {
    }

    /**
     * Returns true if any part of the letterbox overlaps with the given {@code rect}.
     * Returns {@code true} if the letterbox does not overlap with the bar, or the letterbox can
     * fully cover the window frame.
     *
     * @param rect The area of the window frame.
     */
    public boolean isOverlappingWith(Rect rect) {
    boolean notIntersectsOrFullyContains(Rect rect) {
        int emptyCount = 0;
        int noOverlappingCount = 0;
        for (LetterboxSurface surface : mSurfaces) {
            if (surface.isOverlappingWith(rect)) {
            final Rect surfaceRect = surface.mLayoutFrameGlobal;
            if (surfaceRect.isEmpty()) {
                // empty letterbox
                emptyCount++;
            } else if (!Rect.intersects(surfaceRect, rect)) {
                // no overlapping
                noOverlappingCount++;
            } else if (surfaceRect.contains(rect)) {
                // overlapping and covered
                return true;
            }
        }
        return false;
        return (emptyCount + noOverlappingCount) == mSurfaces.length;
    }

    /**
     * Hides the letterbox.
     *
@@ -282,17 +294,6 @@ public class Letterbox {
            return Math.max(0, mLayoutFrameGlobal.height());
        }

        /**
         * Returns if the given {@code rect} overlaps with this letterbox piece.
         * @param rect the area to check for overlap in global coordinates
         */
        public boolean isOverlappingWith(Rect rect) {
            if (mLayoutFrameGlobal.isEmpty()) {
                return false;
            }
            return Rect.intersects(rect, mLayoutFrameGlobal);
        }

        public void applySurfaceChanges(SurfaceControl.Transaction t) {
            if (mSurfaceFrameRelative.equals(mLayoutFrameRelative)) {
                // Nothing changed.
+6 −3
Original line number Diff line number Diff line
@@ -3660,9 +3660,12 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        return mActivityRecord.getBounds().equals(mTmpRect);
    }

    @Override
    public boolean isLetterboxedOverlappingWith(Rect rect) {
        return mActivityRecord != null && mActivityRecord.isLetterboxOverlappingWith(rect);
    /**
     * @see Letterbox#notIntersectsOrFullyContains(Rect)
     */
    boolean letterboxNotIntersectsOrFullyContains(Rect rect) {
        return mActivityRecord == null
                || mActivityRecord.letterboxNotIntersectsOrFullyContains(rect);
    }

    boolean isDragResizeChanged() {
Loading