Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +11 −18 Original line number Diff line number Diff line Loading @@ -588,7 +588,7 @@ class DesktopTasksController( if (taskBoundsBeforeMaximize != null) { destinationBounds.set(taskBoundsBeforeMaximize) } else { getDefaultDesktopTaskBounds(displayLayout, destinationBounds) destinationBounds.set(getDefaultDesktopTaskBounds(displayLayout)) } } else { // Save current bounds so that task can be restored back to original bounds if necessary Loading Loading @@ -624,18 +624,14 @@ class DesktopTasksController( } } private fun getDefaultDesktopTaskBounds(displayLayout: DisplayLayout, outBounds: Rect) { private fun getDefaultDesktopTaskBounds(displayLayout: DisplayLayout): Rect { // TODO(b/319819547): Account for app constraints so apps do not become letterboxed val screenBounds = Rect(0, 0, displayLayout.width(), displayLayout.height()) // Update width and height with default desktop mode values val desiredWidth = screenBounds.width().times(DESKTOP_MODE_INITIAL_BOUNDS_SCALE).toInt() val desiredHeight = screenBounds.height().times(DESKTOP_MODE_INITIAL_BOUNDS_SCALE).toInt() outBounds.set(0, 0, desiredWidth, desiredHeight) // Center the task in screen bounds outBounds.offset( screenBounds.centerX() - outBounds.centerX(), screenBounds.centerY() - outBounds.centerY() ) val desiredWidth = (displayLayout.width() * DESKTOP_MODE_INITIAL_BOUNDS_SCALE).toInt() val desiredHeight = (displayLayout.height() * DESKTOP_MODE_INITIAL_BOUNDS_SCALE).toInt() val heightOffset = (displayLayout.height() - desiredHeight) / 2 val widthOffset = (displayLayout.width() - desiredWidth) / 2 return Rect(widthOffset, heightOffset, desiredWidth + widthOffset, desiredHeight + heightOffset) } private fun getSnapBounds(taskInfo: RunningTaskInfo, position: SnapPosition): Rect { Loading Loading @@ -1090,17 +1086,14 @@ class DesktopTasksController( * @param taskInfo the task being dragged. * @param y height of drag, to be checked against status bar height. */ fun onDragPositioningEndThroughStatusBar( inputCoordinates: PointF, taskInfo: RunningTaskInfo, freeformBounds: Rect ) { fun onDragPositioningEndThroughStatusBar(inputCoordinates: PointF, taskInfo: RunningTaskInfo) { val indicator = visualIndicator ?: return val indicatorType = indicator .updateIndicatorType(inputCoordinates, taskInfo.windowingMode) when (indicatorType) { DesktopModeVisualIndicator.IndicatorType.TO_DESKTOP_INDICATOR -> { finalizeDragToDesktop(taskInfo, freeformBounds) val displayLayout = displayController.getDisplayLayout(taskInfo.displayId) ?: return finalizeDragToDesktop(taskInfo, getDefaultDesktopTaskBounds(displayLayout)) } DesktopModeVisualIndicator.IndicatorType.NO_INDICATOR, DesktopModeVisualIndicator.IndicatorType.TO_FULLSCREEN_INDICATOR -> { Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java +1 −21 Original line number Diff line number Diff line Loading @@ -858,10 +858,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { // as it likely will change. relevantDecor.updateHoverAndPressStatus(ev); mDesktopTasksController.onDragPositioningEndThroughStatusBar( new PointF(ev.getRawX(), ev.getRawY()), relevantDecor.mTaskInfo, calculateFreeformBounds(ev.getDisplayId(), DesktopTasksController.DESKTOP_MODE_INITIAL_BOUNDS_SCALE)); new PointF(ev.getRawX(), ev.getRawY()), relevantDecor.mTaskInfo); mMoveToDesktopAnimator = null; return; } else { Loading Loading @@ -913,23 +910,6 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { } } /** * Gets bounds of a scaled window centered relative to the screen bounds * @param scale the amount to scale to relative to the Screen Bounds */ private Rect calculateFreeformBounds(int displayId, float scale) { // TODO(b/319819547): Account for app constraints so apps do not become letterboxed final DisplayLayout displayLayout = mDisplayController.getDisplayLayout(displayId); final int screenWidth = displayLayout.width(); final int screenHeight = displayLayout.height(); final float adjustmentPercentage = (1f - scale) / 2; return new Rect((int) (screenWidth * adjustmentPercentage), (int) (screenHeight * adjustmentPercentage), (int) (screenWidth * (adjustmentPercentage + scale)), (int) (screenHeight * (adjustmentPercentage + scale))); } @Nullable private DesktopModeWindowDecoration getRelevantWindowDecor(MotionEvent ev) { final DesktopModeWindowDecoration focusedDecor = getFocusedDecor(); Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +11 −18 Original line number Diff line number Diff line Loading @@ -588,7 +588,7 @@ class DesktopTasksController( if (taskBoundsBeforeMaximize != null) { destinationBounds.set(taskBoundsBeforeMaximize) } else { getDefaultDesktopTaskBounds(displayLayout, destinationBounds) destinationBounds.set(getDefaultDesktopTaskBounds(displayLayout)) } } else { // Save current bounds so that task can be restored back to original bounds if necessary Loading Loading @@ -624,18 +624,14 @@ class DesktopTasksController( } } private fun getDefaultDesktopTaskBounds(displayLayout: DisplayLayout, outBounds: Rect) { private fun getDefaultDesktopTaskBounds(displayLayout: DisplayLayout): Rect { // TODO(b/319819547): Account for app constraints so apps do not become letterboxed val screenBounds = Rect(0, 0, displayLayout.width(), displayLayout.height()) // Update width and height with default desktop mode values val desiredWidth = screenBounds.width().times(DESKTOP_MODE_INITIAL_BOUNDS_SCALE).toInt() val desiredHeight = screenBounds.height().times(DESKTOP_MODE_INITIAL_BOUNDS_SCALE).toInt() outBounds.set(0, 0, desiredWidth, desiredHeight) // Center the task in screen bounds outBounds.offset( screenBounds.centerX() - outBounds.centerX(), screenBounds.centerY() - outBounds.centerY() ) val desiredWidth = (displayLayout.width() * DESKTOP_MODE_INITIAL_BOUNDS_SCALE).toInt() val desiredHeight = (displayLayout.height() * DESKTOP_MODE_INITIAL_BOUNDS_SCALE).toInt() val heightOffset = (displayLayout.height() - desiredHeight) / 2 val widthOffset = (displayLayout.width() - desiredWidth) / 2 return Rect(widthOffset, heightOffset, desiredWidth + widthOffset, desiredHeight + heightOffset) } private fun getSnapBounds(taskInfo: RunningTaskInfo, position: SnapPosition): Rect { Loading Loading @@ -1090,17 +1086,14 @@ class DesktopTasksController( * @param taskInfo the task being dragged. * @param y height of drag, to be checked against status bar height. */ fun onDragPositioningEndThroughStatusBar( inputCoordinates: PointF, taskInfo: RunningTaskInfo, freeformBounds: Rect ) { fun onDragPositioningEndThroughStatusBar(inputCoordinates: PointF, taskInfo: RunningTaskInfo) { val indicator = visualIndicator ?: return val indicatorType = indicator .updateIndicatorType(inputCoordinates, taskInfo.windowingMode) when (indicatorType) { DesktopModeVisualIndicator.IndicatorType.TO_DESKTOP_INDICATOR -> { finalizeDragToDesktop(taskInfo, freeformBounds) val displayLayout = displayController.getDisplayLayout(taskInfo.displayId) ?: return finalizeDragToDesktop(taskInfo, getDefaultDesktopTaskBounds(displayLayout)) } DesktopModeVisualIndicator.IndicatorType.NO_INDICATOR, DesktopModeVisualIndicator.IndicatorType.TO_FULLSCREEN_INDICATOR -> { Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java +1 −21 Original line number Diff line number Diff line Loading @@ -858,10 +858,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { // as it likely will change. relevantDecor.updateHoverAndPressStatus(ev); mDesktopTasksController.onDragPositioningEndThroughStatusBar( new PointF(ev.getRawX(), ev.getRawY()), relevantDecor.mTaskInfo, calculateFreeformBounds(ev.getDisplayId(), DesktopTasksController.DESKTOP_MODE_INITIAL_BOUNDS_SCALE)); new PointF(ev.getRawX(), ev.getRawY()), relevantDecor.mTaskInfo); mMoveToDesktopAnimator = null; return; } else { Loading Loading @@ -913,23 +910,6 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { } } /** * Gets bounds of a scaled window centered relative to the screen bounds * @param scale the amount to scale to relative to the Screen Bounds */ private Rect calculateFreeformBounds(int displayId, float scale) { // TODO(b/319819547): Account for app constraints so apps do not become letterboxed final DisplayLayout displayLayout = mDisplayController.getDisplayLayout(displayId); final int screenWidth = displayLayout.width(); final int screenHeight = displayLayout.height(); final float adjustmentPercentage = (1f - scale) / 2; return new Rect((int) (screenWidth * adjustmentPercentage), (int) (screenHeight * adjustmentPercentage), (int) (screenWidth * (adjustmentPercentage + scale)), (int) (screenHeight * (adjustmentPercentage + scale))); } @Nullable private DesktopModeWindowDecoration getRelevantWindowDecor(MotionEvent ev) { final DesktopModeWindowDecoration focusedDecor = getFocusedDecor(); Loading