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

Commit 89e01e9d authored by Omar Elmekkawy's avatar Omar Elmekkawy
Browse files

Bring all tiled tasks to front upon tiling tasks.

Bring all tiled tasks to front upon tiling a new task, to avoid weird
looking UI when one tiled task is hidden behind other tasks, and another
one in front.

Flag: com.android.window.flags.enable_tile_resizing
Test: Unit tests and on device testing
Bug: 416770975
Change-Id: If544b1122d0c162eb04e40067b2777d0ab1df3e0
parent cfa9a2a5
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -142,7 +142,10 @@ class DesktopTilingWindowDecoration(
        isDarkMode = isTaskInDarkMode(taskInfo)
        // Observe drag resizing to break tiling if a task is drag resized.
        desktopModeWindowDecoration.addDragResizeListener(this)
        val callback = { initTilingForDisplayIfNeeded(taskInfo.configuration, isFirstTiledApp) }
        val callback: () -> Unit = {
            initTilingForDisplayIfNeeded(taskInfo.configuration, isFirstTiledApp)
            moveTiledPairToFront(taskInfo.taskId, taskInfo.isFocused)
        }
        updateDesktopRepository(taskInfo.taskId, snapPosition = position)
        if (isTiled) {
            val wct = WindowContainerTransaction().setBounds(taskInfo.token, destinationBounds)
+42 −0
Original line number Diff line number Diff line
@@ -334,9 +334,14 @@ class DesktopTilingWindowDecorationTest : ShellTestCase() {
            BOUNDS,
            destinationBoundsOverride = null,
        )

        verify(toggleResizeDesktopTaskTransitionHandler, times(2))
            .startTransition(capture(wctCaptor), any(), capture(callbackCaptor))
        (callbackCaptor.value).invoke()
        // Ensures tiling isn't brought to front if tasks aren't focused, for example when
        // initializing tiling from persistence.
        verify(transitions, never()).startTransition(eq(TRANSIT_TO_FRONT), any(), eq(null))

        task1.isFocused = true

        assertThat(tilingDecoration.moveTiledPairToFront(task1.taskId, isFocusedOnDisplay = true))
@@ -344,6 +349,43 @@ class DesktopTilingWindowDecorationTest : ShellTestCase() {
        verify(transitions, times(1)).startTransition(eq(TRANSIT_TO_FRONT), any(), eq(null))
    }

    @Test
    fun taskTiled_broughtToFront_uponTilingFocusedTasks() {
        val task1 = createVisibleTask()
        val task2 = createVisibleTask()
        val stableBounds = STABLE_BOUNDS_MOCK
        whenever(displayController.getDisplayLayout(any())).thenReturn(displayLayout)
        whenever(displayLayout.getStableBounds(any())).thenAnswer { i ->
            (i.arguments.first() as Rect).set(stableBounds)
        }
        whenever(context.resources).thenReturn(resources)
        whenever(resources.getDimensionPixelSize(any())).thenReturn(split_divider_width)
        whenever(userRepositories.current.isVisibleTask(eq(task1.taskId))).thenReturn(true)
        whenever(userRepositories.current.isVisibleTask(eq(task2.taskId))).thenReturn(true)
        task1.isFocused = true
        task2.isFocused = true

        tilingDecoration.onAppTiled(
            task1,
            desktopWindowDecoration,
            DesktopTasksController.SnapPosition.RIGHT,
            BOUNDS,
            destinationBoundsOverride = null,
        )
        tilingDecoration.onAppTiled(
            task2,
            desktopWindowDecoration,
            DesktopTasksController.SnapPosition.LEFT,
            BOUNDS,
            destinationBoundsOverride = null,
        )
        verify(toggleResizeDesktopTaskTransitionHandler, times(2))
            .startTransition(capture(wctCaptor), any(), capture(callbackCaptor))
        (callbackCaptor.value).invoke()

        verify(transitions, times(1)).startTransition(eq(TRANSIT_TO_FRONT), any(), eq(null))
    }

    @Test
    fun taskTiled_broughtToFront_bringToFront() {
        val task1 = createVisibleTask()