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

Commit 757618c0 authored by Maryam Dehaini's avatar Maryam Dehaini Committed by Automerger Merge Worker
Browse files

Merge "If task dragged to outer disallowed area, position back under the area"...

Merge "If task dragged to outer disallowed area, position back under the area" into udc-qpr-dev am: 5132a790 am: 9e152da6

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



Change-Id: I7b22fb29b548a059cc631bdffa8a4846596ade4f
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 7d7bf93f 9e152da6
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -419,4 +419,8 @@
    <dimen name="freeform_resize_handle">15dp</dimen>

    <dimen name="freeform_resize_corner">44dp</dimen>

    <!-- The height of the area at the top of the screen where a freeform task will transition to
    fullscreen if dragged until the top bound of the task is within the area. -->
    <dimen name="desktop_mode_transition_area_height">16dp</dimen>
</resources>
+10 −8
Original line number Diff line number Diff line
@@ -100,6 +100,10 @@ class DesktopTasksController(
        }
    }

    private val transitionAreaHeight
        get() = context.resources.getDimensionPixelSize(
                com.android.wm.shell.R.dimen.desktop_mode_transition_area_height)

    init {
        desktopMode = DesktopModeImpl()
        if (DesktopModeStatus.isProto2Enabled()) {
@@ -700,13 +704,12 @@ class DesktopTasksController(
            y: Float
    ) {
        if (taskInfo.windowingMode == WINDOWING_MODE_FREEFORM) {
            val statusBarHeight = getStatusBarHeight(taskInfo)
            if (y <= statusBarHeight && visualIndicator == null) {
            if (y <= transitionAreaHeight && visualIndicator == null) {
                visualIndicator = DesktopModeVisualIndicator(syncQueue, taskInfo,
                        displayController, context, taskSurface, shellTaskOrganizer,
                        rootTaskDisplayAreaOrganizer)
                visualIndicator?.createFullscreenIndicatorWithAnimatedBounds()
            } else if (y > statusBarHeight && visualIndicator != null) {
            } else if (y > transitionAreaHeight && visualIndicator != null) {
                releaseVisualIndicator()
            }
        }
@@ -726,8 +729,7 @@ class DesktopTasksController(
            y: Float,
            windowDecor: DesktopModeWindowDecoration
    ) {
        val statusBarHeight = getStatusBarHeight(taskInfo)
        if (y <= statusBarHeight && taskInfo.windowingMode == WINDOWING_MODE_FREEFORM) {
        if (y <= transitionAreaHeight && taskInfo.windowingMode == WINDOWING_MODE_FREEFORM) {
            windowDecor.incrementRelayoutBlock()
            moveToFullscreenWithAnimation(taskInfo, position)
        }
@@ -746,9 +748,9 @@ class DesktopTasksController(
            taskSurface: SurfaceControl,
            y: Float
    ) {
        // If the motion event is above the status bar, return since we do not need to show the
        // visual indicator at this point.
        if (y < getStatusBarHeight(taskInfo)) {
        // If the motion event is above the status bar and the visual indicator is not yet visible,
        // return since we do not need to show the visual indicator at this point.
        if (y < getStatusBarHeight(taskInfo) && visualIndicator == null) {
            return
        }
        if (visualIndicator == null) {
+1 −1
Original line number Diff line number Diff line
@@ -193,7 +193,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel {

        final DragPositioningCallback dragPositioningCallback =
                new FluidResizeTaskPositioner(mTaskOrganizer, windowDecoration, mDisplayController,
                        null /* disallowedAreaForEndBounds */);
                        0 /* disallowedAreaForEndBoundsHeight */);
        final CaptionTouchEventListener touchEventListener =
                new CaptionTouchEventListener(taskInfo, dragPositioningCallback);
        windowDecoration.setCaptionListeners(touchEventListener, touchEventListener);
+8 −15
Original line number Diff line number Diff line
@@ -845,7 +845,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
        windowDecoration.createResizeVeil();

        final DragPositioningCallback dragPositioningCallback = createDragPositioningCallback(
                windowDecoration, taskInfo);
                windowDecoration);
        final DesktopModeTouchEventListener touchEventListener =
                new DesktopModeTouchEventListener(taskInfo, dragPositioningCallback);

@@ -858,24 +858,17 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
        incrementEventReceiverTasks(taskInfo.displayId);
    }
    private DragPositioningCallback createDragPositioningCallback(
            @NonNull DesktopModeWindowDecoration windowDecoration,
            @NonNull RunningTaskInfo taskInfo) {
        final int screenWidth = mDisplayController.getDisplayLayout(taskInfo.displayId).width();
        final Rect disallowedAreaForEndBounds;
        if (DesktopModeStatus.isProto2Enabled()) {
            disallowedAreaForEndBounds = new Rect(0, 0, screenWidth,
                    getStatusBarHeight(taskInfo.displayId));
        } else {
            disallowedAreaForEndBounds = null;
        }
            @NonNull DesktopModeWindowDecoration windowDecoration) {
        final int transitionAreaHeight = mContext.getResources().getDimensionPixelSize(
                R.dimen.desktop_mode_transition_area_height);
        if (!DesktopModeStatus.isVeiledResizeEnabled()) {
            return new FluidResizeTaskPositioner(mTaskOrganizer, windowDecoration,
                    mDisplayController, disallowedAreaForEndBounds, mDragStartListener,
                    mTransactionFactory);
                    mDisplayController, mDragStartListener, mTransactionFactory,
                    transitionAreaHeight);
        } else {
            return new VeiledResizeTaskPositioner(mTaskOrganizer, windowDecoration,
                    mDisplayController, disallowedAreaForEndBounds, mDragStartListener,
                    mTransitions);
                    mDisplayController, mDragStartListener, mTransitions,
                    transitionAreaHeight);
        }
    }

+18 −3
Original line number Diff line number Diff line
@@ -83,8 +83,6 @@ public class DragPositioningCallbackUtility {
        // Make sure the new resizing destination in any direction falls within the stable bounds.
        // If not, set the bounds back to the old location that was valid to avoid conflicts with
        // some regions such as the gesture area.
        displayController.getDisplayLayout(windowDecoration.mDisplay.getDisplayId())
                .getStableBounds(stableBounds);
        if ((ctrlType & CTRL_TYPE_LEFT) != 0) {
            final int candidateLeft = repositionTaskBounds.left + (int) delta.x;
            repositionTaskBounds.left = (candidateLeft > stableBounds.left)
@@ -136,7 +134,7 @@ public class DragPositioningCallbackUtility {
                repositionTaskBounds.top);
    }

    static void updateTaskBounds(Rect repositionTaskBounds, Rect taskBoundsAtDragStart,
    private static void updateTaskBounds(Rect repositionTaskBounds, Rect taskBoundsAtDragStart,
            PointF repositionStartPoint, float x, float y) {
        final float deltaX = x - repositionStartPoint.x;
        final float deltaY = y - repositionStartPoint.y;
@@ -144,6 +142,23 @@ public class DragPositioningCallbackUtility {
        repositionTaskBounds.offset((int) deltaX, (int) deltaY);
    }

    /**
     * Updates repositionTaskBounds to the final bounds of the task after the drag is finished. If
     * the bounds are outside of the stable bounds, they are shifted to place task at the top of the
     * stable bounds.
     */
    static void onDragEnd(Rect repositionTaskBounds, Rect taskBoundsAtDragStart, Rect stableBounds,
            PointF repositionStartPoint, float x, float y)  {
        updateTaskBounds(repositionTaskBounds, taskBoundsAtDragStart, repositionStartPoint,
                x, y);

        // If task is outside of stable bounds (in the status bar area), shift the task down.
        if (stableBounds.top > repositionTaskBounds.top) {
            final int yShift =  stableBounds.top - repositionTaskBounds.top;
            repositionTaskBounds.offset(0, yShift);
        }
    }

    /**
     * Apply a bounds change to a task.
     * @param windowDecoration decor of task we are changing bounds for
Loading