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

Commit cceb6b31 authored by Jorge Gil's avatar Jorge Gil
Browse files

Make single bounding rect when none set relative to window origin

When a source doesn't have any bounding rects set it means that the
entire source frame should be treated as one single rect. This change
makes that rect relative to the |relativeFrame|, which is what the API
is promising.

Bug: 328667331
Test: atest FrameworksCoreTests:InsetsSourceTest
Change-Id: I5669895f15bfc6e1e8dad8aa32191e48b06bfbbb
parent 10fe5e6e
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -355,11 +355,17 @@ public class InsetsSource implements Parcelable {
        final Rect frame = getFrame();
        if (mBoundingRects == null) {
            // No bounding rects set, make a single bounding rect that covers the intersection of
            // the |frame| and the |relativeFrame|.
            // the |frame| and the |relativeFrame|. Also make it relative to the window origin.
            return mTmpBoundingRect.setIntersect(frame, relativeFrame)
                    ? new Rect[]{ new Rect(mTmpBoundingRect) }
                    ? new Rect[]{
                            new Rect(
                                    mTmpBoundingRect.left - relativeFrame.left,
                                    mTmpBoundingRect.top - relativeFrame.top,
                                    mTmpBoundingRect.right - relativeFrame.left,
                                    mTmpBoundingRect.bottom - relativeFrame.top
                            )
                    }
                    : NO_BOUNDING_RECTS;

        }

        // Special treatment for captionBar inset type. During drag-resizing, the |frame| and
+11 −0
Original line number Diff line number Diff line
@@ -290,6 +290,17 @@ public class InsetsSourceTest {
        assertEquals(new Rect(0, 0, 1000, 100), rects[0]);
    }

    @Test
    public void testCalculateBoundingRects_noBoundingRectsAndFrameNotAtOrigin_createsSingleRect() {
        mSource.setFrame(new Rect(100, 100, 1200, 200));
        mSource.setBoundingRects(null);

        final Rect[] rects = mSource.calculateBoundingRects(new Rect(100, 100, 1100, 1100), false);

        assertEquals(1, rects.length);
        assertEquals(new Rect(0, 0, 1000, 100), rects[0]);
    }

    @Test
    public void testCalculateBoundingRects_noBoundingRectsAndLargerFrame_singleRectFitsRelFrame() {
        mSource.setFrame(new Rect(0, 0, 1000, 100));