diff options
| author | 2025-02-26 13:37:09 -0800 | |
|---|---|---|
| committer | 2025-03-04 13:34:59 -0800 | |
| commit | a33c19b877205b941a3a67386cc1981c290d10d2 (patch) | |
| tree | c8a8db7f5699dd7bbcfb63a00ab92e31ffaa1890 | |
| parent | fd40754ef7b2372617094b1a3caec115af398742 (diff) | |
Break up DesktopTasksController#moveToDisplay
Break up DesktopTasksController#moveToDisplay into two smaller functions: one for split screen tasks, one for the rest of tasks.
Bug: 399411604
Test: manual
Flag: EXEMPT refactor
Change-Id: I0c8662b78425d477e203299b1fa8f24eeec462ab
| -rw-r--r-- | libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt | 85 |
1 files changed, 52 insertions, 33 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt index 301b79afd537..9e9cc513ea6a 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt @@ -1169,6 +1169,11 @@ class DesktopTasksController( return } + if (splitScreenController.isTaskInSplitScreen(task.taskId)) { + moveSplitPairToDisplay(task, displayId) + return + } + val wct = WindowContainerTransaction() val displayAreaInfo = rootTaskDisplayAreaOrganizer.getDisplayAreaInfo(displayId) if (displayAreaInfo == null) { @@ -1176,39 +1181,6 @@ class DesktopTasksController( return } - // check if the task is part of splitscreen - if ( - Flags.enableNonDefaultDisplaySplit() && - Flags.enableMoveToNextDisplayShortcut() && - splitScreenController.isTaskInSplitScreen(task.taskId) - ) { - val activeDeskId = taskRepository.getActiveDeskId(displayId) - logV("moveToDisplay: moving split root to displayId=%d", displayId) - val stageCoordinatorRootTaskToken = - splitScreenController.multiDisplayProvider.getDisplayRootForDisplayId( - DEFAULT_DISPLAY - ) - wct.reparent(stageCoordinatorRootTaskToken, displayAreaInfo.token, true /* onTop */) - val deactivationRunnable = - if (activeDeskId != null) { - // Split is being placed on top of an existing desk in the target display. Make - // sure it is cleaned up. - performDesktopExitCleanUp( - wct = wct, - deskId = activeDeskId, - displayId = displayId, - willExitDesktop = true, - shouldEndUpAtHome = false, - ) - } else { - null - } - val transition = - transitions.startTransition(TRANSIT_CHANGE, wct, moveToDisplayTransitionHandler) - deactivationRunnable?.invoke(transition) - return - } - val destinationDeskId = taskRepository.getDefaultDeskId(displayId) if (destinationDeskId == null) { logW("moveToDisplay: desk not found for display: $displayId") @@ -1270,6 +1242,53 @@ class DesktopTasksController( } /** + * Move split pair associated with the [task] to display with [displayId]. + * + * No-op if task is already on that display per [RunningTaskInfo.displayId]. + */ + private fun moveSplitPairToDisplay(task: RunningTaskInfo, displayId: Int) { + if (!splitScreenController.isTaskInSplitScreen(task.taskId)) { + return + } + + if (!Flags.enableNonDefaultDisplaySplit() || !Flags.enableMoveToNextDisplayShortcut()) { + return + } + + val wct = WindowContainerTransaction() + val displayAreaInfo = rootTaskDisplayAreaOrganizer.getDisplayAreaInfo(displayId) + if (displayAreaInfo == null) { + logW("moveSplitPairToDisplay: display not found") + return + } + + val activeDeskId = taskRepository.getActiveDeskId(displayId) + logV("moveSplitPairToDisplay: moving split root to displayId=%d", displayId) + + val stageCoordinatorRootTaskToken = + splitScreenController.multiDisplayProvider.getDisplayRootForDisplayId(DEFAULT_DISPLAY) + wct.reparent(stageCoordinatorRootTaskToken, displayAreaInfo.token, true /* onTop */) + + val deactivationRunnable = + if (activeDeskId != null) { + // Split is being placed on top of an existing desk in the target display. Make + // sure it is cleaned up. + performDesktopExitCleanUp( + wct = wct, + deskId = activeDeskId, + displayId = displayId, + willExitDesktop = true, + shouldEndUpAtHome = false, + ) + } else { + null + } + val transition = transitions.startTransition(TRANSIT_CHANGE, wct, /* handler= */ null) + deactivationRunnable?.invoke(transition) + return + } + + /** * Quick-resizes a desktop task, toggling between a fullscreen state (represented by the stable * bounds) and a free floating state (either the last saved bounds if available or the default * bounds otherwise). |