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

Commit 8a356787 authored by mattsziklay's avatar mattsziklay Committed by Matt Sziklay
Browse files

Have multi instance options respect cascading window placement.

Adds launch bounds to the AcitivtyOptions used for multi instance
Intents. These launch bounds are calculated with the cascading window
placement.

Fix: 372301129
Test: Manual
Flag: com.android.window.flags.enable_desktop_windowing_multi_instance_features
Flag: com.android.window.flags.enable_cascading_windows
Change-Id: I968ec3b1f7f82a101093d859eac445bd3b516c63
parent 766c5b94
Loading
Loading
Loading
Loading
+30 −13
Original line number Diff line number Diff line
@@ -515,7 +515,6 @@ class DesktopTasksController(
        wct.setWindowingMode(task.token, WINDOWING_MODE_UNDEFINED)

        transitions.startTransition(TRANSIT_CHANGE, wct, null /* handler */)

    }

    private fun exitSplitIfApplicable(wct: WindowContainerTransaction, taskInfo: RunningTaskInfo) {
@@ -657,7 +656,6 @@ class DesktopTasksController(
        wct.reparent(task.token, displayAreaInfo.token, true /* onTop */)

        transitions.startTransition(TRANSIT_CHANGE, wct, null /* handler */)

    }

    /** Moves a task in/out of full immersive state within the desktop. */
@@ -733,7 +731,6 @@ class DesktopTasksController(
        val wct = WindowContainerTransaction().setBounds(taskInfo.token, destinationBounds)

        toggleResizeDesktopTaskTransitionHandler.startTransition(wct)

    }

    private fun getMaximizeBounds(taskInfo: RunningTaskInfo, stableBounds: Rect): Rect {
@@ -845,7 +842,6 @@ class DesktopTasksController(
        val wct = WindowContainerTransaction().setBounds(taskInfo.token, destinationBounds)

        toggleResizeDesktopTaskTransitionHandler.startTransition(wct, currentDragBounds)

    }

    @VisibleForTesting
@@ -1240,10 +1236,23 @@ class DesktopTasksController(
                error("Invalid windowing mode: ${callingTask.windowingMode}")
            }
        }
        val bounds = when (newTaskWindowingMode) {
            WINDOWING_MODE_FREEFORM -> {
                displayController.getDisplayLayout(callingTask.displayId)
                    ?.let { getInitialBounds(it, callingTask) }
            }
            WINDOWING_MODE_MULTI_WINDOW -> {
                Rect()
            }
            else -> {
                error("Invalid windowing mode: $newTaskWindowingMode")
            }
        }
        return ActivityOptions.makeBasic().apply {
            launchWindowingMode = newTaskWindowingMode
            pendingIntentBackgroundActivityStartMode =
                ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOW_ALWAYS
            launchBounds = bounds
        }
    }

@@ -1399,15 +1408,7 @@ class DesktopTasksController(
            } else {
                WINDOWING_MODE_FREEFORM
            }
        val initialBounds = if (ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS.isTrue()) {
            calculateInitialBounds(displayLayout, taskInfo)
        } else {
            getDefaultDesktopTaskBounds(displayLayout)
        }

        if (DesktopModeFlags.ENABLE_CASCADING_WINDOWS.isTrue()) {
            cascadeWindow(taskInfo, initialBounds, displayLayout)
        }
        val initialBounds = getInitialBounds(displayLayout, taskInfo)

        if (canChangeTaskPosition(taskInfo)) {
            wct.setBounds(taskInfo.token, initialBounds)
@@ -1419,6 +1420,22 @@ class DesktopTasksController(
        }
    }

    private fun getInitialBounds(
        displayLayout: DisplayLayout,
        taskInfo: RunningTaskInfo
    ): Rect {
        val bounds = if (ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS.isTrue) {
            calculateInitialBounds(displayLayout, taskInfo)
        } else {
            getDefaultDesktopTaskBounds(displayLayout)
        }

        if (DesktopModeFlags.ENABLE_CASCADING_WINDOWS.isTrue) {
            cascadeWindow(taskInfo, bounds, displayLayout)
        }
        return bounds
    }

    private fun addMoveToFullscreenChanges(
        wct: WindowContainerTransaction,
        taskInfo: RunningTaskInfo