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

Commit 37c0acd1 authored by Daichi Hirono's avatar Daichi Hirono
Browse files

Ignore wallpaper task when moving task to next display

When moving a task to the next display, the move is skipped if the
target display has a focused non-desktop task. The desktop wallpaper can
be considered a focused task, which prevents moving a task to an empty
desktop.

This change filters out the wallpaper task from this check, allowing
tasks to be moved to a display that is only showing the wallpaper.

Test: DesktopTasksControllerTest
Flag: com.android.window.flags.enable_move_to_next_display_shortcut
Bug: 441791586
Change-Id: I44579b207d6d6cbf13baf28a1f77bf14c749c0f1
parent ef439db2
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -2338,7 +2338,10 @@ class DesktopTasksController(
                )
                return@moveToNextDisplay false
            }
            val focusedNonDesktopTasks = getFocusedNonDesktopTasks(displayId, userId)
            val focusedNonDesktopTasks =
                getFocusedNonDesktopTasks(displayId, userId).filter {
                    !DesktopWallpaperActivity.isWallpaperTask(it)
                }
            if (!focusedNonDesktopTasks.isEmpty()) {
                logD(
                    "moveToNextDesktopDisplay: Skip displayId=$displayId as it has focused " +
+31 −0
Original line number Diff line number Diff line
@@ -4548,6 +4548,37 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
            )
    }
    @Test
    fun moveToNextDesktopDisplay_moveIfDestinationFocusesDesktopWallpaper() {
        // 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
        fullscreenTask.baseIntent =
            Intent().apply { component = DesktopWallpaperActivity.wallpaperActivityComponent }
        // Set up a task on the default display
        val task = setUpFreeformTask(displayId = DEFAULT_DISPLAY)
        controller.moveToNextDesktopDisplay(
            taskId = task.taskId,
            userId = taskRepository.userId,
            enterReason = EnterReason.UNKNOWN_ENTER,
        )
        verify(transitions)
            .startTransition(
                eq(TRANSIT_CHANGE),
                any<WindowContainerTransaction>(),
                isA(DesktopModeMoveToDisplayTransitionHandler::class.java),
            )
    }
    @Test
    fun getTaskWindowingMode() {
        val fullscreenTask = setUpFullscreenTask()