Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/tiling/DesktopTilingDecorViewModel.kt +8 −28 Original line number Diff line number Diff line Loading @@ -215,19 +215,6 @@ class DesktopTilingDecorViewModel( } fun getRightSnapBoundsIfTiled(displayId: Int): Rect { val deskId = getCurrentActiveDeskForDisplay(displayId) if (deskId == null) { logW( "Attempted to get right tiling snap bounds with no active desktop for displayId=%d.", displayId, ) return Rect() } val tilingBounds = tilingHandlerByUserAndDeskId[currentUserId]?.get(deskId)?.getRightSnapBoundsIfTiled() if (tilingBounds != null) { return tilingBounds } val displayLayout = displayController.getDisplayLayout(displayId) val stableBounds = Rect() displayLayout?.getStableBounds(stableBounds) Loading @@ -240,23 +227,13 @@ class DesktopTilingDecorViewModel( stableBounds.right, stableBounds.bottom, ) return snapBounds val deskId = getCurrentActiveDeskForDisplay(displayId) ?: return snapBounds val tilingHandler = tilingHandlerByUserAndDeskId[currentUserId]?.get(deskId) return tilingHandler?.getRightSnapBoundsIfTiled() ?: snapBounds } fun getLeftSnapBoundsIfTiled(displayId: Int): Rect { val deskId = getCurrentActiveDeskForDisplay(displayId) if (deskId == null) { logW( "Attempted to get left tiling snap bounds with no active desktop for displayId=%d.", displayId, ) return Rect() } val tilingBounds = tilingHandlerByUserAndDeskId[currentUserId]?.get(deskId)?.getLeftSnapBoundsIfTiled() if (tilingBounds != null) { return tilingBounds } val displayLayout = displayController.getDisplayLayout(displayId) val stableBounds = Rect() displayLayout?.getStableBounds(stableBounds) Loading @@ -268,7 +245,10 @@ class DesktopTilingDecorViewModel( context.resources.getDimensionPixelSize(R.dimen.split_divider_bar_width) / 2, stableBounds.bottom, ) return snapBounds val deskId = getCurrentActiveDeskForDisplay(displayId) ?: return snapBounds val tilingHandler = tilingHandlerByUserAndDeskId[currentUserId]?.get(deskId) return tilingHandler?.getLeftSnapBoundsIfTiled() ?: snapBounds } /** Notifies tiling of a desk being deactivated. */ Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/tiling/DesktopTilingDecorViewModelTest.kt +9 −0 Original line number Diff line number Diff line Loading @@ -400,6 +400,15 @@ class DesktopTilingDecorViewModelTest : ShellTestCase() { .isEqualTo(Rect(12, 7, 8, 9)) } @Test fun getTiledAppBounds_NoActiveDesk() { whenever(desktopRepository.getActiveDeskId(any())).thenReturn(null) assertThat(desktopTilingDecorViewModel.getLeftSnapBoundsIfTiled(2)) .isEqualTo(Rect(6, 7, 2, 9)) assertThat(desktopTilingDecorViewModel.getRightSnapBoundsIfTiled(2)) .isEqualTo(Rect(12, 7, 8, 9)) } companion object { private val BOUNDS = Rect(1, 2, 3, 4) private val STABLE_BOUNDS = Rect(6, 7, 8, 9) Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/tiling/DesktopTilingDecorViewModel.kt +8 −28 Original line number Diff line number Diff line Loading @@ -215,19 +215,6 @@ class DesktopTilingDecorViewModel( } fun getRightSnapBoundsIfTiled(displayId: Int): Rect { val deskId = getCurrentActiveDeskForDisplay(displayId) if (deskId == null) { logW( "Attempted to get right tiling snap bounds with no active desktop for displayId=%d.", displayId, ) return Rect() } val tilingBounds = tilingHandlerByUserAndDeskId[currentUserId]?.get(deskId)?.getRightSnapBoundsIfTiled() if (tilingBounds != null) { return tilingBounds } val displayLayout = displayController.getDisplayLayout(displayId) val stableBounds = Rect() displayLayout?.getStableBounds(stableBounds) Loading @@ -240,23 +227,13 @@ class DesktopTilingDecorViewModel( stableBounds.right, stableBounds.bottom, ) return snapBounds val deskId = getCurrentActiveDeskForDisplay(displayId) ?: return snapBounds val tilingHandler = tilingHandlerByUserAndDeskId[currentUserId]?.get(deskId) return tilingHandler?.getRightSnapBoundsIfTiled() ?: snapBounds } fun getLeftSnapBoundsIfTiled(displayId: Int): Rect { val deskId = getCurrentActiveDeskForDisplay(displayId) if (deskId == null) { logW( "Attempted to get left tiling snap bounds with no active desktop for displayId=%d.", displayId, ) return Rect() } val tilingBounds = tilingHandlerByUserAndDeskId[currentUserId]?.get(deskId)?.getLeftSnapBoundsIfTiled() if (tilingBounds != null) { return tilingBounds } val displayLayout = displayController.getDisplayLayout(displayId) val stableBounds = Rect() displayLayout?.getStableBounds(stableBounds) Loading @@ -268,7 +245,10 @@ class DesktopTilingDecorViewModel( context.resources.getDimensionPixelSize(R.dimen.split_divider_bar_width) / 2, stableBounds.bottom, ) return snapBounds val deskId = getCurrentActiveDeskForDisplay(displayId) ?: return snapBounds val tilingHandler = tilingHandlerByUserAndDeskId[currentUserId]?.get(deskId) return tilingHandler?.getLeftSnapBoundsIfTiled() ?: snapBounds } /** Notifies tiling of a desk being deactivated. */ Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/tiling/DesktopTilingDecorViewModelTest.kt +9 −0 Original line number Diff line number Diff line Loading @@ -400,6 +400,15 @@ class DesktopTilingDecorViewModelTest : ShellTestCase() { .isEqualTo(Rect(12, 7, 8, 9)) } @Test fun getTiledAppBounds_NoActiveDesk() { whenever(desktopRepository.getActiveDeskId(any())).thenReturn(null) assertThat(desktopTilingDecorViewModel.getLeftSnapBoundsIfTiled(2)) .isEqualTo(Rect(6, 7, 2, 9)) assertThat(desktopTilingDecorViewModel.getRightSnapBoundsIfTiled(2)) .isEqualTo(Rect(12, 7, 8, 9)) } companion object { private val BOUNDS = Rect(1, 2, 3, 4) private val STABLE_BOUNDS = Rect(6, 7, 8, 9) Loading