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

Commit 26e89044 authored by Orhan Uysal's avatar Orhan Uysal Committed by Android (Google) Code Review
Browse files

Merge "Refactor enterDesktop." into main

parents c3c6024d 5fffc31f
Loading
Loading
Loading
Loading
+8 −9
Original line number Diff line number Diff line
@@ -255,7 +255,10 @@ class DesktopTasksController(
                2 -> {
                    // Split-screen case where there are two focused tasks, then we find the child
                    // task to move to desktop.
                    val splitFocusedTask = findChildFocusedTask(allFocusedTasks)
                    val splitFocusedTask =
                        if (allFocusedTasks[0].taskId == allFocusedTasks[1].parentTaskId)
                            allFocusedTasks[1]
                        else allFocusedTasks[0]
                    moveToDesktop(splitFocusedTask)
                }
                1 -> {
@@ -263,21 +266,17 @@ class DesktopTasksController(
                    moveToDesktop(allFocusedTasks[0].taskId)
                }
                else -> {
                    KtProtoLog.v(
                    KtProtoLog.w(
                        WM_SHELL_DESKTOP_MODE,
                        "DesktopTasksController: Cannot enter desktop expected less " +
                                "than 3 focused tasks but found " + allFocusedTasks.size
                        "DesktopTasksController: Cannot enter desktop, expected less " +
                                "than 3 focused tasks but found %d",
                        allFocusedTasks.size
                    )
                }
            }
        }
    }

    private fun findChildFocusedTask(allFocusedTasks: List<RunningTaskInfo>): RunningTaskInfo {
        if (allFocusedTasks[0].taskId == allFocusedTasks[1].parentTaskId) return allFocusedTasks[1]
        return allFocusedTasks[0]
    }

    /** Move a task with given `taskId` to desktop */
    fun moveToDesktop(
            taskId: Int,