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

Commit 97cbdecf authored by mattsziklay's avatar mattsziklay Committed by Matt Sziklay
Browse files

Update drag resizing to prioritize close button.

Removes the pilfer pointers call on ACTION_DOWN for drag handles, as
this prevented clicking on the close button in the area where the
button and the top right corner handle intersected. Instead, we add
pilfer calls to ACTION_MOVE and ACTION_UP/CANCEL events to prevent
click events triggering during a drag resize.

Because DesktopModeWindowDecorViewModel's EventHandler handles
MotionEvents before DragResizeInputListener's handler, this CL also
adds a check to ensure a drag reposition is not performed while a drag
resize handle is being touched. Previously this was avoided by
pilfering on ACTION_DOWN, before any ACTION_MOVE could be handled.

Lastly, this CL changes the timing of showing resize veil to first
ACTION_MOVE instead of ACTION_DOWN to prevent briefly showing the veil
while closing a task.

Bug: 318633921
Test: Manual, confirm that top corner handles can both handle button
clicks and drag resizes while still preventing input to tasks behind it.
Test: atest VeiledResizeTaskPositionerTest,
FluidResizeTaskPositionerTest

Change-Id: Ie3937d2a41de925c233d9474eb7495c5b8b0ac89
parent e8c4c3b0
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -271,6 +271,9 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel {
                    if (e.findPointerIndex(mDragPointerId) == -1) {
                        mDragPointerId = e.getPointerId(0);
                    }
                    final CaptionWindowDecoration decoration = mWindowDecorByTaskId.get(mTaskId);
                    // If a decor's resize drag zone is active, don't also try to reposition it.
                    if (decoration.isHandlingDragResize()) break;
                    final int dragPointerIdx = e.findPointerIndex(mDragPointerId);
                    mDragPositioningCallback.onDragPositioningMove(
                            e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx));
+4 −0
Original line number Diff line number Diff line
@@ -286,6 +286,10 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
        closeBackground.setTintList(buttonTintColor);
    }

    boolean isHandlingDragResize() {
        return mDragResizeListener.isHandlingDragResize();
    }

    private void closeDragResizeListener() {
        if (mDragResizeListener == null) {
            return;
+3 −1
Original line number Diff line number Diff line
@@ -491,8 +491,11 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
                    return true;
                }
                case MotionEvent.ACTION_MOVE: {
                    mShouldClick = false;
                    final DesktopModeWindowDecoration decoration =
                            mWindowDecorByTaskId.get(mTaskId);
                    // If a decor's resize drag zone is active, don't also try to reposition it.
                    if (decoration.isHandlingDragResize()) break;
                    decoration.closeMaximizeMenu();
                    if (e.findPointerIndex(mDragPointerId) == -1) {
                        mDragPointerId = e.getPointerId(0);
@@ -505,7 +508,6 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
                            e.getRawX(dragPointerIdx),
                            newTaskBounds));
                    mIsDragging = true;
                    mShouldClick = false;
                    return true;
                }
                case MotionEvent.ACTION_UP:
+4 −0
Original line number Diff line number Diff line
@@ -387,6 +387,10 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
        return mHandleMenu != null;
    }

    boolean isHandlingDragResize() {
        return mDragResizeListener.isHandlingDragResize();
    }

    private void loadAppInfo() {
        String packageName = mTaskInfo.realActivity.getPackageName();
        PackageManager pm = mContext.getApplicationContext().getPackageManager();
+10 −1
Original line number Diff line number Diff line
@@ -320,6 +320,10 @@ class DragResizeInputListener implements AutoCloseable {
        }
    }

    boolean isHandlingDragResize() {
        return mInputEventReceiver.isHandlingEvents();
    }

    @Override
    public void close() {
        mInputEventReceiver.dispose();
@@ -386,6 +390,10 @@ class DragResizeInputListener implements AutoCloseable {
            finishInputEvent(inputEvent, handleInputEvent(inputEvent));
        }

        boolean isHandlingEvents() {
            return mShouldHandleEvents;
        }

        private boolean handleInputEvent(InputEvent inputEvent) {
            if (!(inputEvent instanceof MotionEvent)) {
                return false;
@@ -409,7 +417,6 @@ class DragResizeInputListener implements AutoCloseable {
                        mShouldHandleEvents = isInResizeHandleBounds(x, y);
                    }
                    if (mShouldHandleEvents) {
                        mInputManager.pilferPointers(mInputChannel.getToken());
                        mDragPointerId = e.getPointerId(0);
                        float rawX = e.getRawX(0);
                        float rawY = e.getRawY(0);
@@ -427,6 +434,7 @@ class DragResizeInputListener implements AutoCloseable {
                    if (!mShouldHandleEvents) {
                        break;
                    }
                    mInputManager.pilferPointers(mInputChannel.getToken());
                    int dragPointerIndex = e.findPointerIndex(mDragPointerId);
                    float rawX = e.getRawX(dragPointerIndex);
                    float rawY = e.getRawY(dragPointerIndex);
@@ -437,6 +445,7 @@ class DragResizeInputListener implements AutoCloseable {
                }
                case MotionEvent.ACTION_UP:
                case MotionEvent.ACTION_CANCEL: {
                    mInputManager.pilferPointers(mInputChannel.getToken());
                    if (mShouldHandleEvents) {
                        int dragPointerIndex = e.findPointerIndex(mDragPointerId);
                        final Rect taskBounds = mCallback.onDragPositioningEnd(
Loading