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

Commit 08559dc5 authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Use correct task bounds when moved from fullscreen to freeform stack

When we are moving a task to the freeform stack, get the launch bounds
to use or layout in stack vs. using the existing bounds that can be
null.

Also, prevent moving a task to the freeform stack if freeform isn't supported.

Bug: 27157914
Change-Id: I0d86baa6141961b92a436107b5c5bb1316570558
parent 12a30e88
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -2226,6 +2226,11 @@ public final class ActivityStackSupervisor implements DisplayListener {
            return;
        }

        if (stackId == FREEFORM_WORKSPACE_STACK_ID && !mService.mSupportsFreeformWindowManagement) {
            throw new IllegalArgumentException("moveTaskToStack:"
                    + "Attempt to move task " + taskId + " to unsupported freeform stack");
        }

        final ActivityRecord topActivity = task.getTopActivity();
        final int sourceStackId = task.stack != null ? task.stack.mStackId : INVALID_STACK_ID;
        final boolean mightReplaceWindow =
@@ -2260,10 +2265,13 @@ public final class ActivityStackSupervisor implements DisplayListener {
            // Make sure the task has the appropriate bounds/size for the stack it is in.
            if (stackId == FULLSCREEN_WORKSPACE_STACK_ID && task.mBounds != null) {
                kept = resizeTaskLocked(task, stack.mBounds, RESIZE_MODE_SYSTEM, !mightReplaceWindow);
            } else if (stackId == FREEFORM_WORKSPACE_STACK_ID
                    && task.mBounds == null && task.mLastNonFullscreenBounds != null) {
                kept = resizeTaskLocked(task, task.mLastNonFullscreenBounds,
                        RESIZE_MODE_SYSTEM, !mightReplaceWindow);
            } else if (stackId == FREEFORM_WORKSPACE_STACK_ID) {
                Rect bounds = task.getLaunchBounds();
                if (bounds == null) {
                    stack.layoutTaskInStack(task, null);
                    bounds = task.mBounds;
                }
                kept = resizeTaskLocked(task, bounds, RESIZE_MODE_FORCED, !mightReplaceWindow);
            } else if (stackId == DOCKED_STACK_ID || stackId == PINNED_STACK_ID) {
                kept = resizeTaskLocked(task, stack.mBounds, RESIZE_MODE_SYSTEM, !mightReplaceWindow);
            }