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

Commit 70c1afa3 authored by Pierre Barbier de Reuille's avatar Pierre Barbier de Reuille
Browse files

Always reorder surfaces on focus change

If the focus change, the surfaces must always be re-ordered, or the
divider ends up behind the focused task, which prevents inputs from
reacing it.

Fix: 377960322
Test: atest DesktopTilingWindowDecorationTest
Flag: com.android.window.flags.enable_tile_resizing
Change-Id: I6c3bd961eb673c1b94038dcfe652539df2af1f48
parent b39c74af
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -492,9 +492,8 @@ class DesktopTilingWindowDecoration(

    // Only called if [taskInfo] relates to a focused task
    private fun isTilingRefocused(taskInfo: RunningTaskInfo): Boolean {
        return !isTilingFocused &&
            (taskInfo.taskId == leftTaskResizingHelper?.taskInfo?.taskId ||
                taskInfo.taskId == rightTaskResizingHelper?.taskInfo?.taskId)
        return taskInfo.taskId == leftTaskResizingHelper?.taskInfo?.taskId ||
                taskInfo.taskId == rightTaskResizingHelper?.taskInfo?.taskId
    }

    private fun buildTiledTasksMoveToFront(leftOnTop: Boolean): WindowContainerTransaction {
+35 −28
Original line number Diff line number Diff line
@@ -124,7 +124,7 @@ class DesktopTilingWindowDecorationTest : ShellTestCase() {

    @Test
    fun taskTiled_toCorrectBounds_leftTile() {
        val task1 = createFreeformTask()
        val task1 = createVisibleTask()
        val stableBounds = STABLE_BOUNDS_MOCK
        whenever(displayController.getDisplayLayout(any())).thenReturn(displayLayout)
        whenever(displayLayout.getStableBounds(any())).thenAnswer { i ->
@@ -151,7 +151,7 @@ class DesktopTilingWindowDecorationTest : ShellTestCase() {
    @Test
    fun taskTiled_toCorrectBounds_rightTile() {
        // Setup
        val task1 = createFreeformTask()
        val task1 = createVisibleTask()
        val stableBounds = STABLE_BOUNDS_MOCK
        whenever(displayController.getDisplayLayout(any())).thenReturn(displayLayout)
        whenever(displayLayout.getStableBounds(any())).thenAnswer { i ->
@@ -177,7 +177,7 @@ class DesktopTilingWindowDecorationTest : ShellTestCase() {

    @Test
    fun taskTiled_notAnimated_whenTilingPositionNotChange() {
        val task1 = createFreeformTask()
        val task1 = createVisibleTask()
        val stableBounds = STABLE_BOUNDS_MOCK
        whenever(displayController.getDisplayLayout(any())).thenReturn(displayLayout)
        whenever(displayLayout.getStableBounds(any())).thenAnswer { i ->
@@ -213,8 +213,8 @@ class DesktopTilingWindowDecorationTest : ShellTestCase() {

    @Test
    fun taskNotTiled_notBroughtToFront_tilingNotInitialised() {
        val task1 = createFreeformTask()
        val task2 = createFreeformTask()
        val task1 = createVisibleTask()
        val task2 = createVisibleTask()
        val stableBounds = STABLE_BOUNDS_MOCK
        whenever(displayController.getDisplayLayout(any())).thenReturn(displayLayout)
        whenever(displayLayout.getStableBounds(any())).thenAnswer { i ->
@@ -236,9 +236,9 @@ class DesktopTilingWindowDecorationTest : ShellTestCase() {

    @Test
    fun taskNotTiled_notBroughtToFront_taskNotTiled() {
        val task1 = createFreeformTask()
        val task2 = createFreeformTask()
        val task3 = createFreeformTask()
        val task1 = createVisibleTask()
        val task2 = createVisibleTask()
        val task3 = createVisibleTask()
        val stableBounds = STABLE_BOUNDS_MOCK
        whenever(displayController.getDisplayLayout(any())).thenReturn(displayLayout)
        whenever(displayLayout.getStableBounds(any())).thenAnswer { i ->
@@ -265,9 +265,9 @@ class DesktopTilingWindowDecorationTest : ShellTestCase() {
    }

    @Test
    fun taskTiled_broughtToFront_alreadyInFrontNoAction() {
        val task1 = createFreeformTask()
        val task2 = createFreeformTask()
    fun taskTiled_broughtToFront_alreadyInFrontStillReorder() {
        val task1 = createVisibleTask()
        val task2 = createVisibleTask()
        val stableBounds = STABLE_BOUNDS_MOCK
        whenever(displayController.getDisplayLayout(any())).thenReturn(displayLayout)
        whenever(displayLayout.getStableBounds(any())).thenAnswer { i ->
@@ -275,6 +275,8 @@ class DesktopTilingWindowDecorationTest : ShellTestCase() {
        }
        whenever(context.resources).thenReturn(resources)
        whenever(resources.getDimensionPixelSize(any())).thenReturn(split_divider_width)
        whenever(desktopRepository.isVisibleTask(eq(task1.taskId))).thenReturn(true)
        whenever(desktopRepository.isVisibleTask(eq(task2.taskId))).thenReturn(true)

        tilingDecoration.onAppTiled(
            task1,
@@ -290,15 +292,15 @@ class DesktopTilingWindowDecorationTest : ShellTestCase() {
        )
        task1.isFocused = true

        assertThat(tilingDecoration.moveTiledPairToFront(task1)).isFalse()
        verify(transitions, never()).startTransition(any(), any(), any())
        assertThat(tilingDecoration.moveTiledPairToFront(task1, isTaskFocused = true)).isTrue()
        verify(transitions, times(1)).startTransition(eq(TRANSIT_TO_FRONT), any(), eq(null))
    }

    @Test
    fun taskTiled_broughtToFront_bringToFront() {
        val task1 = createFreeformTask()
        val task2 = createFreeformTask()
        val task3 = createFreeformTask()
        val task1 = createVisibleTask()
        val task2 = createVisibleTask()
        val task3 = createVisibleTask()
        val stableBounds = STABLE_BOUNDS_MOCK
        whenever(displayLayout.getStableBounds(any())).thenAnswer { i ->
            (i.arguments.first() as Rect).set(stableBounds)
@@ -329,9 +331,9 @@ class DesktopTilingWindowDecorationTest : ShellTestCase() {

    @Test
    fun taskTiled_broughtToFront_taskInfoNotUpdated_bringToFront() {
        val task1 = createFreeformTask()
        val task2 = createFreeformTask()
        val task3 = createFreeformTask()
        val task1 = createVisibleTask()
        val task2 = createVisibleTask()
        val task3 = createVisibleTask()
        val stableBounds = STABLE_BOUNDS_MOCK
        whenever(displayLayout.getStableBounds(any())).thenAnswer { i ->
            (i.arguments.first() as Rect).set(stableBounds)
@@ -361,8 +363,8 @@ class DesktopTilingWindowDecorationTest : ShellTestCase() {
    @Test
    fun taskTiledTasks_NotResized_BeforeTouchEndArrival() {
        // Setup
        val task1 = createFreeformTask()
        val task2 = createFreeformTask()
        val task1 = createVisibleTask()
        val task2 = createVisibleTask()
        val stableBounds = STABLE_BOUNDS_MOCK
        whenever(displayController.getDisplayLayout(any())).thenReturn(displayLayout)
        whenever(displayLayout.getStableBounds(any())).thenAnswer { i ->
@@ -428,8 +430,8 @@ class DesktopTilingWindowDecorationTest : ShellTestCase() {
    @Test
    fun tiledTasksResizedUsingDividerHandle_shouldLogResizingEvents() {
        // Setup
        val task1 = createFreeformTask()
        val task2 = createFreeformTask()
        val task1 = createVisibleTask()
        val task2 = createVisibleTask()
        val stableBounds = STABLE_BOUNDS_MOCK
        whenever(displayController.getDisplayLayout(any())).thenReturn(displayLayout)
        whenever(displayLayout.getStableBounds(any())).thenAnswer { i ->
@@ -487,7 +489,7 @@ class DesktopTilingWindowDecorationTest : ShellTestCase() {

    @Test
    fun taskTiled_shouldBeRemoved_whenTileBroken() {
        val task1 = createFreeformTask()
        val task1 = createVisibleTask()
        val stableBounds = STABLE_BOUNDS_MOCK
        whenever(displayController.getDisplayLayout(any())).thenReturn(displayLayout)
        whenever(displayLayout.getStableBounds(any())).thenAnswer { i ->
@@ -516,8 +518,8 @@ class DesktopTilingWindowDecorationTest : ShellTestCase() {

    @Test
    fun taskNotTiled_shouldNotBeRemoved_whenNotTiled() {
        val task1 = createFreeformTask()
        val task2 = createFreeformTask()
        val task1 = createVisibleTask()
        val task2 = createVisibleTask()
        val stableBounds = STABLE_BOUNDS_MOCK
        whenever(displayController.getDisplayLayout(any())).thenReturn(displayLayout)
        whenever(displayLayout.getStableBounds(any())).thenAnswer { i ->
@@ -545,8 +547,8 @@ class DesktopTilingWindowDecorationTest : ShellTestCase() {

    @Test
    fun tasksTiled_shouldBeRemoved_whenSessionDestroyed() {
        val task1 = createFreeformTask()
        val task2 = createFreeformTask()
        val task1 = createVisibleTask()
        val task2 = createVisibleTask()
        val stableBounds = STABLE_BOUNDS_MOCK
        whenever(displayController.getDisplayLayout(any())).thenReturn(displayLayout)
        whenever(displayLayout.getStableBounds(any())).thenAnswer { i ->
@@ -610,6 +612,11 @@ class DesktopTilingWindowDecorationTest : ShellTestCase() {
        return Rect(stableBounds.left, stableBounds.top, rightBound, stableBounds.bottom)
    }

    private fun createVisibleTask() =
        createFreeformTask().also {
            whenever(desktopRepository.isVisibleTask(eq(it.taskId))).thenReturn(true)
        }

    companion object {
        private val NON_STABLE_BOUNDS_MOCK = Rect(50, 55, 100, 100)
        private val STABLE_BOUNDS_MOCK = Rect(0, 0, 100, 100)