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

Commit 7f12e218 authored by Ben Lin's avatar Ben Lin
Browse files

Allow PIP window corners to be drag-resizable.

Alongside the corners outside the PIP window, allow the corners on the
PIP window to also start drag-resize.

Bug: 156126006
Test: Drag-resize from the PIP window corners and it works
Change-Id: I8af9d0de9c73b33349906a68525769c94c31a082
parent 4a8e2573
Loading
Loading
Loading
Loading
+44 −26
Original line number Diff line number Diff line
@@ -174,7 +174,21 @@ public class PipResizeGestureHandler {
        }
    }

    private boolean isWithinTouchRegion(int x, int y) {
    /**
     * Check whether the current x,y coordinate is within the region in which drag-resize should
     * start.
     * This consists of 4 small squares on the 4 corners of the PIP window, a quarter of which
     * overlaps with the PIP window while the rest goes outside of the PIP window.
     *  _ _           _ _
     * |_|_|_________|_|_|
     * |_|_|         |_|_|
     *   |     PIP     |
     *   |   WINDOW    |
     *  _|_           _|_
     * |_|_|_________|_|_|
     * |_|_|         |_|_|
     */
    public boolean isWithinTouchRegion(int x, int y) {
        final Rect currentPipBounds = mMotionHelper.getBounds();
        if (currentPipBounds == null) {
            return false;
@@ -195,12 +209,18 @@ public class PipResizeGestureHandler {
        mTmpRegion.op(mTmpBottomLeftCorner, Region.Op.UNION);
        mTmpRegion.op(mTmpBottomRightCorner, Region.Op.UNION);

        return mTmpRegion.contains(x, y);
    }

    private void setCtrlType(int x, int y) {
        final Rect currentPipBounds = mMotionHelper.getBounds();

        Rect movementBounds = mMovementBoundsSupplier.get();
        mDisplayBounds.set(movementBounds.left,
                movementBounds.top,
                movementBounds.right + currentPipBounds.width(),
                movementBounds.bottom + currentPipBounds.height());
        if (mTmpRegion.contains(x, y)) {

        if (mTmpTopLeftCorner.contains(x, y) && currentPipBounds.top != mDisplayBounds.top
                && currentPipBounds.left != mDisplayBounds.left) {
            mCtrlType |= CTRL_LEFT;
@@ -223,9 +243,6 @@ public class PipResizeGestureHandler {
            mCtrlType |= CTRL_LEFT;
            mCtrlType |= CTRL_BOTTOM;
        }
            return true;
        }
        return false;
    }

    private void onMotionEvent(MotionEvent ev) {
@@ -234,6 +251,7 @@ public class PipResizeGestureHandler {
            mLastResizeBounds.setEmpty();
            mAllowGesture = isWithinTouchRegion((int) ev.getX(), (int) ev.getY());
            if (mAllowGesture) {
                setCtrlType((int) ev.getX(), (int) ev.getY());
                mDownPoint.set(ev.getX(), ev.getY());
                mLastDownBounds.set(mMotionHelper.getBounds());
            }
+5 −0
Original line number Diff line number Diff line
@@ -573,6 +573,11 @@ public class PipTouchHandler {

        MotionEvent ev = (MotionEvent) inputEvent;


        if (mPipResizeGestureHandler.isWithinTouchRegion((int) ev.getX(), (int) ev.getY())) {
            return true;
        }

        if (mMagnetizedPip.maybeConsumeMotionEvent(ev)) {
            // If the first touch event occurs within the magnetic field, pass the ACTION_DOWN event
            // to the touch state. Touch state needs a DOWN event in order to later process MOVE