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

Commit 436035ad authored by Graciela Wissen Putri's avatar Graciela Wissen Putri
Browse files

Use getStableBounds if we are in desktop mode

Don't use getStableBoundsForDesktopMode as it can be incorrect if insets
were updated in runtime. If already in desktop mode, getStableBounds
should return correct insets.

Flag: EXEMPT bug fix
Bug: 406182386
Test: atest DesktopTasksControllerTest
Change-Id: Iea0110cef8027b684b4c5d45f97d9a1e68d37af3
parent 3ada4be7
Loading
Loading
Loading
Loading
+13 −5
Original line number Diff line number Diff line
@@ -1631,7 +1631,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(
@@ -2909,8 +2910,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)
            }
        }
@@ -3338,9 +3340,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
@@ -1239,9 +1239,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)
@@ -1259,7 +1262,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)
@@ -1284,7 +1287,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)