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

Commit e3c98685 authored by Graciela Putri's avatar Graciela Putri Committed by Android (Google) Code Review
Browse files

Merge "Use getStableBounds if we are in desktop mode" into main

parents 3c1ff994 436035ad
Loading
Loading
Loading
Loading
+13 −5
Original line number Diff line number Diff line
@@ -1676,7 +1676,8 @@ class DesktopTasksController(
        val bounds = calculateDefaultDesktopTaskBounds(displayLayout)
        val deskId = getOrCreateDefaultDeskId(displayId) ?: return
        if (DesktopModeFlags.ENABLE_CASCADING_WINDOWS.isTrue) {
            cascadeWindow(bounds, displayLayout, deskId)
            val stableBounds = Rect().apply { displayLayout.getStableBounds(this) }
            cascadeWindow(bounds, displayLayout, deskId, stableBounds)
        }
        val pendingIntent =
            PendingIntent.getActivityAsUser(
@@ -2949,8 +2950,9 @@ class DesktopTasksController(
        ) {
            val displayLayout = displayController.getDisplayLayout(task.displayId)
            if (displayLayout != null) {
                val stableBounds = Rect().apply { displayLayout.getStableBounds(this) }
                val initialBounds = Rect(task.configuration.windowConfiguration.bounds)
                cascadeWindow(initialBounds, displayLayout, deskId)
                cascadeWindow(initialBounds, displayLayout, deskId, stableBounds)
                wct.setBounds(task.token, initialBounds)
            }
        }
@@ -3430,9 +3432,15 @@ class DesktopTasksController(
        )
    }

    private fun cascadeWindow(bounds: Rect, displayLayout: DisplayLayout, deskId: Int) {
        val stableBounds = Rect()
    private fun cascadeWindow(
        bounds: Rect,
        displayLayout: DisplayLayout,
        deskId: Int,
        stableBounds: Rect = Rect(),
    ) {
        if (stableBounds.isEmpty) {
            displayLayout.getStableBoundsForDesktopMode(stableBounds)
        }

        val activeTasks = taskRepository.getExpandedTasksIdsInDeskOrdered(deskId)
        activeTasks
+7 −4
Original line number Diff line number Diff line
@@ -1304,9 +1304,12 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
    @Test
    @EnableFlags(Flags.FLAG_ENABLE_CASCADING_WINDOWS)
    fun handleRequest_newFreeformTaskLaunch_cascadeApplied() {
        val stableBounds =
            Rect(0, 0, DISPLAY_DIMENSION_LONG, DISPLAY_DIMENSION_SHORT - TASKBAR_FRAME_HEIGHT)
        whenever(displayLayout.getStableBounds(any())).thenAnswer { i ->
            (i.arguments.first() as Rect).set(stableBounds)
        }
        setUpLandscapeDisplay()
        val stableBounds = Rect()
        displayLayout.getStableBoundsForDesktopMode(stableBounds)

        setUpFreeformTask(bounds = DEFAULT_LANDSCAPE_BOUNDS)
        val freeformTask = setUpFreeformTask(bounds = DEFAULT_LANDSCAPE_BOUNDS, active = false)
@@ -1324,7 +1327,7 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
    fun handleRequest_newFreeformTaskLaunch_newDesk_desksCascadeIndependently() {
        setUpLandscapeDisplay()
        val stableBounds = Rect()
        displayLayout.getStableBoundsForDesktopMode(stableBounds)
        displayLayout.getStableBounds(stableBounds)

        // Launch freeform tasks in default desk.
        setUpFreeformTask(bounds = DEFAULT_LANDSCAPE_BOUNDS)
@@ -1349,7 +1352,7 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
    fun handleRequest_freeformTaskAlreadyExistsInDesktopMode_cascadeNotApplied() {
        setUpLandscapeDisplay()
        val stableBounds = Rect()
        displayLayout.getStableBoundsForDesktopMode(stableBounds)
        displayLayout.getStableBounds(stableBounds)

        setUpFreeformTask(bounds = DEFAULT_LANDSCAPE_BOUNDS)
        val freeformTask = setUpFreeformTask(bounds = DEFAULT_LANDSCAPE_BOUNDS)