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

Commit 9521b73f authored by Garfield Tan's avatar Garfield Tan Committed by Automerger Merge Worker
Browse files

Merge "Fix a few issues with mouse cursors and resize handles" into...

Merge "Fix a few issues with mouse cursors and resize handles" into udc-qpr-dev am: 34ca8b1c am: 5f08a299

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23863415



Change-Id: I7f5399774aa91d8f5dcf5eea469cad03e9c01979
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 1547161e 5f08a299
Loading
Loading
Loading
Loading
+23 −4
Original line number Original line Diff line number Diff line
@@ -336,6 +336,7 @@ class DragResizeInputListener implements AutoCloseable {
        private final Runnable mConsumeBatchEventRunnable;
        private final Runnable mConsumeBatchEventRunnable;
        private boolean mConsumeBatchEventScheduled;
        private boolean mConsumeBatchEventScheduled;
        private boolean mShouldHandleEvents;
        private boolean mShouldHandleEvents;
        private int mLastCursorType = PointerIcon.TYPE_DEFAULT;


        private TaskResizeInputEventReceiver(
        private TaskResizeInputEventReceiver(
                InputChannel inputChannel, Handler handler, Choreographer choreographer) {
                InputChannel inputChannel, Handler handler, Choreographer choreographer) {
@@ -437,7 +438,6 @@ class DragResizeInputListener implements AutoCloseable {
                    break;
                    break;
                }
                }
                case MotionEvent.ACTION_HOVER_EXIT:
                case MotionEvent.ACTION_HOVER_EXIT:
                    mInputManager.setPointerIconType(PointerIcon.TYPE_DEFAULT);
                    result = true;
                    result = true;
                    break;
                    break;
            }
            }
@@ -477,8 +477,14 @@ class DragResizeInputListener implements AutoCloseable {
            if (y > mTaskHeight - mTaskCornerRadius) {
            if (y > mTaskHeight - mTaskCornerRadius) {
                ctrlType |= CTRL_TYPE_BOTTOM;
                ctrlType |= CTRL_TYPE_BOTTOM;
            }
            }
            // Check distances from the center if it's in one of four corners.
            if ((ctrlType & (CTRL_TYPE_LEFT | CTRL_TYPE_RIGHT)) != 0
                    && (ctrlType & (CTRL_TYPE_TOP | CTRL_TYPE_BOTTOM)) != 0) {
                return checkDistanceFromCenter(ctrlType, x, y);
                return checkDistanceFromCenter(ctrlType, x, y);
            }
            }
            // Otherwise, we should make sure we don't resize tasks inside task bounds.
            return (x < 0 || y < 0 || x >= mTaskWidth || y >= mTaskHeight) ? ctrlType : 0;
        }


        // If corner input is not within appropriate distance of corner radius, do not use it.
        // If corner input is not within appropriate distance of corner radius, do not use it.
        // If input is not on a corner or is within valid distance, return ctrlType.
        // If input is not on a corner or is within valid distance, return ctrlType.
@@ -511,7 +517,8 @@ class DragResizeInputListener implements AutoCloseable {
                    break;
                    break;
                }
                }
                default: {
                default: {
                    return ctrlType;
                    throw new IllegalArgumentException("ctrlType should be complex, but it's 0x"
                            + Integer.toHexString(ctrlType));
                }
                }
            }
            }
            double distanceFromCenter = Math.hypot(x - centerX, y - centerY);
            double distanceFromCenter = Math.hypot(x - centerX, y - centerY);
@@ -564,7 +571,19 @@ class DragResizeInputListener implements AutoCloseable {
                    cursorType = PointerIcon.TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW;
                    cursorType = PointerIcon.TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW;
                    break;
                    break;
            }
            }
            // Only update the cursor type to default once so that views behind the decor container
            // layer that aren't in the active resizing regions have chances to update the cursor
            // type. We would like to enforce the cursor type by setting the cursor type multilple
            // times in active regions because we shouldn't allow the views behind to change it, as
            // we'll pilfer the gesture initiated in this area. This is necessary because 1) we
            // should allow the views behind regions only for touches to set the cursor type; and 2)
            // there is a small region out of each rounded corner that's inside the task bounds,
            // where views in the task can receive input events because we can't set touch regions
            // of input sinks to have rounded corners.
            if (mLastCursorType != cursorType || cursorType != PointerIcon.TYPE_DEFAULT) {
                mInputManager.setPointerIconType(cursorType);
                mInputManager.setPointerIconType(cursorType);
                mLastCursorType = cursorType;
            }
        }
        }
    }
    }
}
}
 No newline at end of file