Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/tiling/DesktopTilingDecorViewModel.kt +1 −1 Original line number Diff line number Diff line Loading @@ -103,7 +103,7 @@ class DesktopTilingDecorViewModel( fun moveTaskToFrontIfTiled(taskInfo: RunningTaskInfo): Boolean { return tilingTransitionHandlerByDisplayId .get(taskInfo.displayId) ?.moveTiledPairToFront(taskInfo) ?: false ?.moveTiledPairToFront(taskInfo, isTaskFocused = true) ?: false } fun onOverviewAnimationStateChange(isRunning: Boolean) { Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/tiling/DesktopTilingWindowDecoration.kt +18 −8 Original line number Diff line number Diff line Loading @@ -230,14 +230,14 @@ class DesktopTilingWindowDecoration( ResizeTrigger.TILING_DIVIDER, motionEvent, leftTiledTask.taskInfo, displayController displayController, ) desktopModeEventLogger.logTaskResizingStarted( ResizeTrigger.TILING_DIVIDER, motionEvent, rightTiledTask.taskInfo, displayController displayController, ) } Loading Loading @@ -303,7 +303,7 @@ class DesktopTilingWindowDecoration( leftTiledTask.taskInfo, leftTiledTask.newBounds.height(), leftTiledTask.newBounds.width(), displayController displayController, ) desktopModeEventLogger.logTaskResizingEnded( Loading @@ -312,7 +312,7 @@ class DesktopTilingWindowDecoration( rightTiledTask.taskInfo, rightTiledTask.newBounds.height(), rightTiledTask.newBounds.width(), displayController displayController, ) if (leftTiledTask.newBounds == leftTiledTask.bounds) { Loading Loading @@ -471,9 +471,9 @@ class DesktopTilingWindowDecoration( } } // Only called if [taskInfo] relates to a focused task private fun isTilingFocusRemoved(taskInfo: RunningTaskInfo): Boolean { return taskInfo.isFocused && isTilingFocused && return isTilingFocused && taskInfo.taskId != leftTaskResizingHelper?.taskInfo?.taskId && taskInfo.taskId != rightTaskResizingHelper?.taskInfo?.taskId } Loading @@ -484,9 +484,9 @@ class DesktopTilingWindowDecoration( } } // Only called if [taskInfo] relates to a focused task private fun isTilingRefocused(taskInfo: RunningTaskInfo): Boolean { return !isTilingFocused && taskInfo.isFocused && (taskInfo.taskId == leftTaskResizingHelper?.taskInfo?.taskId || taskInfo.taskId == rightTaskResizingHelper?.taskInfo?.taskId) } Loading Loading @@ -573,9 +573,19 @@ class DesktopTilingWindowDecoration( removeTaskIfTiled(taskId, taskVanished = true, shouldDelayUpdate = true) } fun moveTiledPairToFront(taskInfo: RunningTaskInfo): Boolean { /** * Moves the tiled pair to the front of the task stack, if the [taskInfo] is focused and one of * the two tiled tasks. * * If specified, [isTaskFocused] will override [RunningTaskInfo.isFocused]. This is to be used * when called when the task will be focused, but the [taskInfo] hasn't been updated yet. */ fun moveTiledPairToFront(taskInfo: RunningTaskInfo, isTaskFocused: Boolean? = null): Boolean { if (!isTilingManagerInitialised) return false val isFocused = isTaskFocused ?: taskInfo.isFocused if (!isFocused) return false // If a task that isn't tiled is being focused, let the generic handler do the work. if (isTilingFocusRemoved(taskInfo)) { isTilingFocused = false Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/tiling/DesktopTilingDecorViewModelTest.kt +3 −2 Original line number Diff line number Diff line Loading @@ -24,8 +24,8 @@ import com.android.wm.shell.ShellTaskOrganizer import com.android.wm.shell.ShellTestCase import com.android.wm.shell.common.DisplayController import com.android.wm.shell.common.SyncTransactionQueue import com.android.wm.shell.desktopmode.DesktopRepository import com.android.wm.shell.desktopmode.DesktopModeEventLogger import com.android.wm.shell.desktopmode.DesktopRepository import com.android.wm.shell.desktopmode.DesktopTasksController import com.android.wm.shell.desktopmode.DesktopTestHelpers.Companion.createFreeformTask import com.android.wm.shell.desktopmode.ReturnToDragStartAnimator Loading Loading @@ -130,7 +130,8 @@ class DesktopTilingDecorViewModelTest : ShellTestCase() { ) desktopTilingDecorViewModel.moveTaskToFrontIfTiled(task1) verify(desktopTilingDecoration, times(1)).moveTiledPairToFront(any()) verify(desktopTilingDecoration, times(1)) .moveTiledPairToFront(any(), isTaskFocused = eq(true)) } @Test Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/tiling/DesktopTilingWindowDecorationTest.kt +31 −0 Original line number Diff line number Diff line Loading @@ -327,6 +327,37 @@ class DesktopTilingWindowDecorationTest : ShellTestCase() { verify(transitions, times(1)).startTransition(eq(TRANSIT_TO_FRONT), any(), eq(null)) } @Test fun taskTiled_broughtToFront_taskInfoNotUpdated_bringToFront() { val task1 = createFreeformTask() val task2 = createFreeformTask() val task3 = createFreeformTask() val stableBounds = STABLE_BOUNDS_MOCK 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(desktopWindowDecoration.getLeash()).thenReturn(surfaceControlMock) whenever(desktopRepository.isVisibleTask(any())).thenReturn(true) tilingDecoration.onAppTiled( task1, desktopWindowDecoration, DesktopTasksController.SnapPosition.RIGHT, BOUNDS, ) tilingDecoration.onAppTiled( task2, desktopWindowDecoration, DesktopTasksController.SnapPosition.LEFT, BOUNDS, ) assertThat(tilingDecoration.moveTiledPairToFront(task3, isTaskFocused = true)).isFalse() assertThat(tilingDecoration.moveTiledPairToFront(task1, isTaskFocused = true)).isTrue() verify(transitions, times(1)).startTransition(eq(TRANSIT_TO_FRONT), any(), eq(null)) } @Test fun taskTiledTasks_NotResized_BeforeTouchEndArrival() { // Setup Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/tiling/DesktopTilingDecorViewModel.kt +1 −1 Original line number Diff line number Diff line Loading @@ -103,7 +103,7 @@ class DesktopTilingDecorViewModel( fun moveTaskToFrontIfTiled(taskInfo: RunningTaskInfo): Boolean { return tilingTransitionHandlerByDisplayId .get(taskInfo.displayId) ?.moveTiledPairToFront(taskInfo) ?: false ?.moveTiledPairToFront(taskInfo, isTaskFocused = true) ?: false } fun onOverviewAnimationStateChange(isRunning: Boolean) { Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/tiling/DesktopTilingWindowDecoration.kt +18 −8 Original line number Diff line number Diff line Loading @@ -230,14 +230,14 @@ class DesktopTilingWindowDecoration( ResizeTrigger.TILING_DIVIDER, motionEvent, leftTiledTask.taskInfo, displayController displayController, ) desktopModeEventLogger.logTaskResizingStarted( ResizeTrigger.TILING_DIVIDER, motionEvent, rightTiledTask.taskInfo, displayController displayController, ) } Loading Loading @@ -303,7 +303,7 @@ class DesktopTilingWindowDecoration( leftTiledTask.taskInfo, leftTiledTask.newBounds.height(), leftTiledTask.newBounds.width(), displayController displayController, ) desktopModeEventLogger.logTaskResizingEnded( Loading @@ -312,7 +312,7 @@ class DesktopTilingWindowDecoration( rightTiledTask.taskInfo, rightTiledTask.newBounds.height(), rightTiledTask.newBounds.width(), displayController displayController, ) if (leftTiledTask.newBounds == leftTiledTask.bounds) { Loading Loading @@ -471,9 +471,9 @@ class DesktopTilingWindowDecoration( } } // Only called if [taskInfo] relates to a focused task private fun isTilingFocusRemoved(taskInfo: RunningTaskInfo): Boolean { return taskInfo.isFocused && isTilingFocused && return isTilingFocused && taskInfo.taskId != leftTaskResizingHelper?.taskInfo?.taskId && taskInfo.taskId != rightTaskResizingHelper?.taskInfo?.taskId } Loading @@ -484,9 +484,9 @@ class DesktopTilingWindowDecoration( } } // Only called if [taskInfo] relates to a focused task private fun isTilingRefocused(taskInfo: RunningTaskInfo): Boolean { return !isTilingFocused && taskInfo.isFocused && (taskInfo.taskId == leftTaskResizingHelper?.taskInfo?.taskId || taskInfo.taskId == rightTaskResizingHelper?.taskInfo?.taskId) } Loading Loading @@ -573,9 +573,19 @@ class DesktopTilingWindowDecoration( removeTaskIfTiled(taskId, taskVanished = true, shouldDelayUpdate = true) } fun moveTiledPairToFront(taskInfo: RunningTaskInfo): Boolean { /** * Moves the tiled pair to the front of the task stack, if the [taskInfo] is focused and one of * the two tiled tasks. * * If specified, [isTaskFocused] will override [RunningTaskInfo.isFocused]. This is to be used * when called when the task will be focused, but the [taskInfo] hasn't been updated yet. */ fun moveTiledPairToFront(taskInfo: RunningTaskInfo, isTaskFocused: Boolean? = null): Boolean { if (!isTilingManagerInitialised) return false val isFocused = isTaskFocused ?: taskInfo.isFocused if (!isFocused) return false // If a task that isn't tiled is being focused, let the generic handler do the work. if (isTilingFocusRemoved(taskInfo)) { isTilingFocused = false Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/tiling/DesktopTilingDecorViewModelTest.kt +3 −2 Original line number Diff line number Diff line Loading @@ -24,8 +24,8 @@ import com.android.wm.shell.ShellTaskOrganizer import com.android.wm.shell.ShellTestCase import com.android.wm.shell.common.DisplayController import com.android.wm.shell.common.SyncTransactionQueue import com.android.wm.shell.desktopmode.DesktopRepository import com.android.wm.shell.desktopmode.DesktopModeEventLogger import com.android.wm.shell.desktopmode.DesktopRepository import com.android.wm.shell.desktopmode.DesktopTasksController import com.android.wm.shell.desktopmode.DesktopTestHelpers.Companion.createFreeformTask import com.android.wm.shell.desktopmode.ReturnToDragStartAnimator Loading Loading @@ -130,7 +130,8 @@ class DesktopTilingDecorViewModelTest : ShellTestCase() { ) desktopTilingDecorViewModel.moveTaskToFrontIfTiled(task1) verify(desktopTilingDecoration, times(1)).moveTiledPairToFront(any()) verify(desktopTilingDecoration, times(1)) .moveTiledPairToFront(any(), isTaskFocused = eq(true)) } @Test Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/tiling/DesktopTilingWindowDecorationTest.kt +31 −0 Original line number Diff line number Diff line Loading @@ -327,6 +327,37 @@ class DesktopTilingWindowDecorationTest : ShellTestCase() { verify(transitions, times(1)).startTransition(eq(TRANSIT_TO_FRONT), any(), eq(null)) } @Test fun taskTiled_broughtToFront_taskInfoNotUpdated_bringToFront() { val task1 = createFreeformTask() val task2 = createFreeformTask() val task3 = createFreeformTask() val stableBounds = STABLE_BOUNDS_MOCK 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(desktopWindowDecoration.getLeash()).thenReturn(surfaceControlMock) whenever(desktopRepository.isVisibleTask(any())).thenReturn(true) tilingDecoration.onAppTiled( task1, desktopWindowDecoration, DesktopTasksController.SnapPosition.RIGHT, BOUNDS, ) tilingDecoration.onAppTiled( task2, desktopWindowDecoration, DesktopTasksController.SnapPosition.LEFT, BOUNDS, ) assertThat(tilingDecoration.moveTiledPairToFront(task3, isTaskFocused = true)).isFalse() assertThat(tilingDecoration.moveTiledPairToFront(task1, isTaskFocused = true)).isTrue() verify(transitions, times(1)).startTransition(eq(TRANSIT_TO_FRONT), any(), eq(null)) } @Test fun taskTiledTasks_NotResized_BeforeTouchEndArrival() { // Setup Loading