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

Commit acdecf6f authored by Omar Elmekkawy's avatar Omar Elmekkawy Committed by Android (Google) Code Review
Browse files

Merge "Enable corner resizing for tiled apps." into main

parents 089c86f6 c3422136
Loading
Loading
Loading
Loading
+13 −22
Original line number Diff line number Diff line
@@ -70,8 +70,8 @@ public final class DragResizeWindowGeometry {

        mDisabledEdge = disabledEdge;

        mLargeTaskCorners = new TaskCorners(mTaskSize, largeCornerSize, disabledEdge);
        mFineTaskCorners = new TaskCorners(mTaskSize, fineCornerSize, disabledEdge);
        mLargeTaskCorners = new TaskCorners(mTaskSize, largeCornerSize);
        mFineTaskCorners = new TaskCorners(mTaskSize, fineCornerSize);

        // Save touch areas for each edge.
        mTaskEdges = new TaskEdges(mTaskSize, mResizeHandleEdgeOutset, mDisabledEdge);
@@ -260,10 +260,6 @@ public final class DragResizeWindowGeometry {
    @DragPositioningCallback.CtrlType
    private int checkDistanceFromCenter(@DragPositioningCallback.CtrlType int ctrlType, float x,
            float y) {
        if ((mDisabledEdge == DisabledEdge.RIGHT && (ctrlType & CTRL_TYPE_RIGHT) != 0)
                || mDisabledEdge == DisabledEdge.LEFT && ((ctrlType & CTRL_TYPE_LEFT) != 0)) {
            return CTRL_TYPE_UNDEFINED;
        }
        final Point cornerRadiusCenter = calculateCenterForCornerRadius(ctrlType);
        double distanceFromCenter = Math.hypot(x - cornerRadiusCenter.x, y - cornerRadiusCenter.y);

@@ -349,31 +345,29 @@ public final class DragResizeWindowGeometry {
        private final @NonNull Rect mRightTopCornerBounds;
        private final @NonNull Rect mLeftBottomCornerBounds;
        private final @NonNull Rect mRightBottomCornerBounds;
        private final @NonNull DisabledEdge mDisabledEdge;

        TaskCorners(@NonNull Size taskSize, int cornerSize, DisabledEdge disabledEdge) {
        TaskCorners(@NonNull Size taskSize, int cornerSize) {
            mCornerSize = cornerSize;
            mDisabledEdge = disabledEdge;
            final int cornerRadius = cornerSize / 2;
            mLeftTopCornerBounds = (disabledEdge == DisabledEdge.LEFT) ? new Rect() : new Rect(
            mLeftTopCornerBounds = new Rect(
                    -cornerRadius,
                    -cornerRadius,
                    cornerRadius,
                    cornerRadius);

            mRightTopCornerBounds = (disabledEdge == DisabledEdge.RIGHT) ? new Rect() : new Rect(
            mRightTopCornerBounds = new Rect(
                    taskSize.getWidth() - cornerRadius,
                    -cornerRadius,
                    taskSize.getWidth() + cornerRadius,
                    cornerRadius);

            mLeftBottomCornerBounds = (disabledEdge == DisabledEdge.LEFT) ? new Rect() : new Rect(
            mLeftBottomCornerBounds = new Rect(
                    -cornerRadius,
                    taskSize.getHeight() - cornerRadius,
                    cornerRadius,
                    taskSize.getHeight() + cornerRadius);

            mRightBottomCornerBounds = (disabledEdge == DisabledEdge.RIGHT) ? new Rect() : new Rect(
            mRightBottomCornerBounds = new Rect(
                    taskSize.getWidth() - cornerRadius,
                    taskSize.getHeight() - cornerRadius,
                    taskSize.getWidth() + cornerRadius,
@@ -384,15 +378,11 @@ public final class DragResizeWindowGeometry {
         * Updates the region to include all four corners.
         */
        void union(Region region) {
            if (mDisabledEdge != DisabledEdge.RIGHT) {
            region.union(mRightTopCornerBounds);
            region.union(mRightBottomCornerBounds);
            }
            if (mDisabledEdge != DisabledEdge.LEFT) {
            region.union(mLeftTopCornerBounds);
            region.union(mLeftBottomCornerBounds);
        }
        }

        /**
         * Returns the control type based on the position of the {@code MotionEvent}'s coordinates.
@@ -529,7 +519,8 @@ public final class DragResizeWindowGeometry {
            return this.mTopEdgeBounds.equals(other.mTopEdgeBounds)
                    && this.mLeftEdgeBounds.equals(other.mLeftEdgeBounds)
                    && this.mRightEdgeBounds.equals(other.mRightEdgeBounds)
                    && this.mBottomEdgeBounds.equals(other.mBottomEdgeBounds);
                    && this.mBottomEdgeBounds.equals(other.mBottomEdgeBounds)
                    && this.mDisabledEdge.equals(other.mDisabledEdge);
        }

        @Override
+10 −22
Original line number Diff line number Diff line
@@ -91,12 +91,9 @@ class DesktopTilingDividerWindowManager(
    fun setTouchRegion(handle: Rect, divider: Rect, cornerRadius: Float) {
        val path = Path()
        path.fillType = Path.FillType.WINDING
        // The UI starts on the top-left corner, the region will be:
        // The UI starts on the top-left corner leaving a radius gap, the region will be:
        //
        //      cornerLeft     cornerRight
        // c1Top        +--------+
        //              |corners |
        // c1Bottom     +--+  +--+
        // dividerTop      +--+
        //                 |  |
        //       handleLeft|  |  handleRight
        // handleTop  +----+  +----+
@@ -104,35 +101,26 @@ class DesktopTilingDividerWindowManager(
        // handleBot  +----+  +----+
        //                 |  |
        //                 |  |
        // c2Top        +--+  +--+
        //              |corners |
        // c2Bottom     +--------+
        val cornerLeft = 0f
        // dividerBottom   +--+

        val centerX = cornerRadius + divider.width() / 2f
        val centerY = divider.height()
        val cornerRight = divider.width() + 2 * cornerRadius
        val centerY = divider.height() / 2f
        val handleLeft = centerX - handle.width() / 2f
        val handleRight = handleLeft + handle.width()
        val dividerLeft = centerY - divider.width() / 2f
        val dividerRight = dividerLeft + divider.width()

        val c1Top = 0f
        val c1Bottom = cornerRadius
        val dividerTop = cornerRadius
        val handleTop = centerY - handle.height() / 2f
        val handleBottom = handleTop + handle.height()
        val c2Top = divider.height() - cornerRadius
        val c2Bottom = divider.height().toFloat()
        val dividerBottom = divider.height() - cornerRadius

        // Top corners
        path.addRect(cornerLeft, c1Top, cornerRight, c1Bottom, Path.Direction.CCW)
        // Bottom corners
        path.addRect(cornerLeft, c1Top, cornerRight, c2Bottom, Path.Direction.CCW)
        // Handle
        path.addRect(handleLeft, handleTop, handleRight, handleBottom, Path.Direction.CCW)
        // Divider
        path.addRect(dividerLeft, c2Top, dividerRight, c2Bottom, Path.Direction.CCW)
        path.addRect(dividerLeft, dividerTop, dividerRight, dividerBottom, Path.Direction.CCW)

        val clip = Rect(handleLeft.toInt(), c1Top.toInt(), handleRight.toInt(), c2Bottom.toInt())
        val clip =
            Rect(handleLeft.toInt(), dividerTop.toInt(), handleRight.toInt(), dividerBottom.toInt())

        val region = Region()
        region.setPath(path, Region(clip))