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

Commit 00095bb1 authored by Daichi Hirono's avatar Daichi Hirono
Browse files

Do not move desktop task to the next display

This CL changes the move to next display shortcut (Ctrl + Action + D) so
that it does not move desktop tasks if the destination display has
focused non-desktop tasks (e.g. fullscreen, split screen)

Bug: 410637225
Test: DesktopTasksControllerTest
Test: run CD smoke tests https://android-build.corp.google.com/builds/abtd/run/L66200030013068147
Flag: com.android.window.flags.enable_move_to_next_display_shortcut
Change-Id: I3c723583bc76e0baabb05515132f67c40587b45e
parent c20eaa67
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -1903,7 +1903,22 @@ class DesktopTasksController(
    /** Move task to the next display which can host desktop tasks. */
    fun moveToNextDesktopDisplay(taskId: Int) =
        moveToNextDisplay(taskId) { displayId ->
            desktopState.isDesktopModeSupportedOnDisplay(displayId)
            if (!desktopState.isDesktopModeSupportedOnDisplay(displayId)) {
                logD(
                    "moveToNextDesktopDisplay: Skip displayId=$displayId as desktop mode " +
                        "is not supported."
                )
                return@moveToNextDisplay false
            }
            if (!getFocusedNonDesktopTasks(displayId).isEmpty()) {
                logD(
                    "moveToNextDesktopDisplay: Skip displayId=$displayId as the focused " +
                        "task is not desktop task focused non desktop tasks."
                )
                return@moveToNextDisplay false
            }
            logD("moveToNextDesktopDisplay: Choose displayId=$displayId for the next display.")
            return@moveToNextDisplay true
        }

    /**
+25 −0
Original line number Diff line number Diff line
@@ -4112,6 +4112,31 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
        moveToNextDesktopDisplay_moveIifDesktopModeSupportedOnDestination(false)
    }

    @Test
    fun moveToNextDesktopDisplay_dontMoveIfDestinationFocusesFullscreenTask() {
        // Set up displays
        whenever(rootTaskDisplayAreaOrganizer.displayIds)
            .thenReturn(intArrayOf(DEFAULT_DISPLAY, SECOND_DISPLAY))
        taskRepository.addDesk(displayId = SECOND_DISPLAY, deskId = 2)
        desktopState.overrideDesktopModeSupportPerDisplay[SECOND_DISPLAY] = true

        // Set up a focused fullscreen task on the secondary display
        val fullscreenTask = setUpFullscreenTask(displayId = SECOND_DISPLAY)
        fullscreenTask.isFocused = true

        // Set up a task on the default display
        val task = setUpFreeformTask(displayId = DEFAULT_DISPLAY)

        controller.moveToNextDesktopDisplay(task.taskId)

        verify(transitions, never())
            .startTransition(
                eq(TRANSIT_CHANGE),
                any<WindowContainerTransaction>(),
                isA(DesktopModeMoveToDisplayTransitionHandler::class.java),
            )
    }

    @Test
    fun getTaskWindowingMode() {
        val fullscreenTask = setUpFullscreenTask()