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

Commit 066cebf8 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Move focused task when using taskId 0" into main

parents a705a150 ee8c73b7
Loading
Loading
Loading
Loading
+21 −5
Original line number Diff line number Diff line
@@ -54,13 +54,23 @@ class DesktopModeShellCommandHandler(
            pw.println("Error: task id should be provided as arguments")
            return false
        }
        val taskId =
        var taskId =
            try {
                args[1].toInt()
            } catch (e: NumberFormatException) {
                pw.println("Error: task id should be an integer")
                return false
            }

        if (taskId == 0) {
            taskId = focusTransitionObserver.globallyFocusedTaskId
        }

        if (taskId == INVALID_TASK_ID) {
            pw.println("Error: no appropriate task found")
            return false
        }

        if (!DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue) {
            return controller.moveTaskToDefaultDeskAndActivate(taskId, transitionSource = UNKNOWN)
        }
@@ -257,14 +267,20 @@ class DesktopModeShellCommandHandler(

    override fun printShellCommandHelp(pw: PrintWriter, prefix: String) {
        if (!DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue) {
            pw.println("$prefix moveTaskToDesk <taskId> ")
            pw.println("$prefix  Move a task with given id to desktop mode.")
            pw.println("$prefix moveTaskToDesk <taskId|0>")
            pw.println(
                "$prefix  Move a task with given id to desktop mode. " +
                    "TaskId 0 means focused task on the default display."
            )
            pw.println("$prefix moveToNextDisplay <taskId> ")
            pw.println("$prefix  Move a task with given id to next display.")
            return
        }
        pw.println("$prefix moveTaskToDesk <taskId> <deskId>")
        pw.println("$prefix  Move a task with given id to the given desk and activate it.")
        pw.println("$prefix moveTaskToDesk <taskId|0> <deskId>")
        pw.println(
            "$prefix  Move a task with given id to the given desk and activate it. " +
                "TaskId 0 means focused task on the default display."
        )
        pw.println("$prefix moveToNextDisplay <taskId>")
        pw.println("$prefix  Move a task with given id to next display.")
        pw.println("$prefix createDesk <displayId>")
+5 −1
Original line number Diff line number Diff line
@@ -370,7 +370,11 @@ class DesktopTasksController(
    /** Returns whether the given display has an active desk. */
    fun isAnyDeskActive(displayId: Int): Boolean = taskRepository.isAnyDeskActive(displayId)

    /** Moves focused task to desktop mode for given [displayId]. */
    /**
     * Moves focused task to desktop mode for given [displayId].
     *
     * TODO(b/405381458): use focusTransitionObserver to get the focused task on a certain display
     */
    fun moveFocusedTaskToDesktop(displayId: Int, transitionSource: DesktopModeTransitionSource) {
        val allFocusedTasks = getAllFocusedTasks(displayId)
        when (allFocusedTasks.size) {