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

Commit 88149130 authored by Gustav Sennton's avatar Gustav Sennton
Browse files

Make ACTION_CANCEL cancel drag-to-desktop

Before this CL ACTION_CANCEL wouldn't properly finish the enter-desktop
transition, making it possible to get stuck in the middle of that
transition.

Test: manual: start app-handle drag with one finger, then tap the screen
with another finger -> ensure the app goes back to fullscreen.
Bug: 373031959
Flag: EXEMPT TODO
Change-Id: Id691042d285e9a80db02fcc9fad9c3fea0fcbdfe

Change-Id: I36c811bb78ac73bf2d276c94e2af2ea6b4f2f2db
parent b00c0520
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -2049,6 +2049,18 @@ class DesktopTasksController(
            ?.onTaskbarCornerRoundingUpdate(doesAnyTaskRequireTaskbarRounding(taskInfo.displayId))
    }

    /**
     * Cancel the drag-to-desktop transition.
     *
     * @param taskInfo the task being dragged.
     */
    fun onDragPositioningCancelThroughStatusBar(
        taskInfo: RunningTaskInfo,
    ) {
        interactionJankMonitor.cancel(CUJ_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG_HOLD)
        cancelDragToDesktop(taskInfo)
    }

    /**
     * Perform checks required when drag ends under status bar area.
     *
+34 −29
Original line number Diff line number Diff line
@@ -1290,6 +1290,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
                }
                break;
            }
            case MotionEvent.ACTION_CANCEL:
            case MotionEvent.ACTION_UP: {
                if (mTransitionDragActive) {
                    final DesktopModeVisualIndicator.DragStartState dragStartState =
@@ -1304,32 +1305,11 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
                        // Though this isn't a hover event, we need to update handle's hover state
                        // as it likely will change.
                        relevantDecor.updateHoverAndPressStatus(ev);
                        DesktopModeVisualIndicator.IndicatorType resultType =
                                mDesktopTasksController.onDragPositioningEndThroughStatusBar(
                                        new PointF(ev.getRawX(), ev.getRawY()),
                                        relevantDecor.mTaskInfo,
                                        relevantDecor.mTaskSurface);
                        // If we are entering split select, handle will no longer be visible and
                        // should not be receiving any input.
                        if (resultType == TO_SPLIT_LEFT_INDICATOR
                                || resultType == TO_SPLIT_RIGHT_INDICATOR) {
                            relevantDecor.disposeStatusBarInputLayer();
                            // We should also dispose the other split task's input layer if
                            // applicable.
                            final int splitPosition = mSplitScreenController
                                    .getSplitPosition(relevantDecor.mTaskInfo.taskId);
                            if (splitPosition != SPLIT_POSITION_UNDEFINED) {
                                final int oppositePosition =
                                        splitPosition == SPLIT_POSITION_TOP_OR_LEFT
                                                ? SPLIT_POSITION_BOTTOM_OR_RIGHT
                                                : SPLIT_POSITION_TOP_OR_LEFT;
                                final RunningTaskInfo oppositeTaskInfo =
                                        mSplitScreenController.getTaskInfo(oppositePosition);
                                if (oppositeTaskInfo != null) {
                                    mWindowDecorByTaskId.get(oppositeTaskInfo.taskId)
                                            .disposeStatusBarInputLayer();
                                }
                            }
                        if (ev.getActionMasked() == ACTION_CANCEL) {
                            mDesktopTasksController.onDragPositioningCancelThroughStatusBar(
                                    relevantDecor.mTaskInfo);
                        } else {
                            endDragToDesktop(ev, relevantDecor);
                        }
                        mMoveToDesktopAnimator = null;
                        return;
@@ -1378,10 +1358,35 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
                }
                break;
            }
        }
    }

            case MotionEvent.ACTION_CANCEL: {
                mTransitionDragActive = false;
                mMoveToDesktopAnimator = null;
    private void endDragToDesktop(MotionEvent ev, DesktopModeWindowDecoration relevantDecor) {
        DesktopModeVisualIndicator.IndicatorType resultType =
                mDesktopTasksController.onDragPositioningEndThroughStatusBar(
                        new PointF(ev.getRawX(), ev.getRawY()),
                        relevantDecor.mTaskInfo,
                        relevantDecor.mTaskSurface);
        // If we are entering split select, handle will no longer be visible and
        // should not be receiving any input.
        if (resultType == TO_SPLIT_LEFT_INDICATOR
                || resultType == TO_SPLIT_RIGHT_INDICATOR) {
            relevantDecor.disposeStatusBarInputLayer();
            // We should also dispose the other split task's input layer if
            // applicable.
            final int splitPosition = mSplitScreenController
                    .getSplitPosition(relevantDecor.mTaskInfo.taskId);
            if (splitPosition != SPLIT_POSITION_UNDEFINED) {
                final int oppositePosition =
                        splitPosition == SPLIT_POSITION_TOP_OR_LEFT
                                ? SPLIT_POSITION_BOTTOM_OR_RIGHT
                                : SPLIT_POSITION_TOP_OR_LEFT;
                final RunningTaskInfo oppositeTaskInfo =
                        mSplitScreenController.getTaskInfo(oppositePosition);
                if (oppositeTaskInfo != null) {
                    mWindowDecorByTaskId.get(oppositeTaskInfo.taskId)
                            .disposeStatusBarInputLayer();
                }
            }
        }
    }