Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +33 −25 Original line number Diff line number Diff line Loading @@ -639,16 +639,23 @@ class DesktopTasksController( /** * Quick-resize to the right or left half of the stable bounds. * * @param taskInfo current task that is being snap-resized via dragging or maximize menu button * @param currentDragBounds current position of the task leash being dragged (or current task * bounds if being snapped resize via maximize menu button) * @param position the portion of the screen (RIGHT or LEFT) we want to snap the task to. */ fun snapToHalfScreen(taskInfo: RunningTaskInfo, position: SnapPosition) { fun snapToHalfScreen( taskInfo: RunningTaskInfo, currentDragBounds: Rect, position: SnapPosition ) { val destinationBounds = getSnapBounds(taskInfo, position) if (destinationBounds == taskInfo.configuration.windowConfiguration.bounds) return val wct = WindowContainerTransaction().setBounds(taskInfo.token, destinationBounds) if (Transitions.ENABLE_SHELL_TRANSITIONS) { toggleResizeDesktopTaskTransitionHandler.startTransition(wct) toggleResizeDesktopTaskTransitionHandler.startTransition(wct, currentDragBounds) } else { shellTaskOrganizer.applyTransaction(wct) } Loading Loading @@ -1266,7 +1273,7 @@ class DesktopTasksController( taskSurface: SurfaceControl, inputX: Float, taskTop: Float ): DesktopModeVisualIndicator.IndicatorType { ): IndicatorType { // If the visual indicator does not exist, create it. val indicator = visualIndicator Loading @@ -1289,13 +1296,15 @@ class DesktopTasksController( * @param taskInfo the task being dragged. * @param position position of surface when drag ends. * @param inputCoordinate the coordinates of the motion event * @param taskBounds the updated bounds of the task being dragged. * @param currentDragBounds the current bounds of where the visible task is (might be actual * task bounds or just task leash) * @param validDragArea the bounds of where the task can be dragged within the display. */ fun onDragPositioningEnd( taskInfo: RunningTaskInfo, position: Point, inputCoordinate: PointF, taskBounds: Rect, currentDragBounds: Rect, validDragArea: Rect ) { if (taskInfo.configuration.windowConfiguration.windowingMode != WINDOWING_MODE_FREEFORM) { Loading @@ -1305,41 +1314,40 @@ class DesktopTasksController( val indicator = visualIndicator ?: return val indicatorType = indicator.updateIndicatorType( PointF(inputCoordinate.x, taskBounds.top.toFloat()), PointF(inputCoordinate.x, currentDragBounds.top.toFloat()), taskInfo.windowingMode ) when (indicatorType) { DesktopModeVisualIndicator.IndicatorType.TO_FULLSCREEN_INDICATOR -> { IndicatorType.TO_FULLSCREEN_INDICATOR -> { moveToFullscreenWithAnimation( taskInfo, position, DesktopModeTransitionSource.TASK_DRAG ) } DesktopModeVisualIndicator.IndicatorType.TO_SPLIT_LEFT_INDICATOR -> { IndicatorType.TO_SPLIT_LEFT_INDICATOR -> { releaseVisualIndicator() snapToHalfScreen(taskInfo, SnapPosition.LEFT) snapToHalfScreen(taskInfo, currentDragBounds, SnapPosition.LEFT) } DesktopModeVisualIndicator.IndicatorType.TO_SPLIT_RIGHT_INDICATOR -> { IndicatorType.TO_SPLIT_RIGHT_INDICATOR -> { releaseVisualIndicator() snapToHalfScreen(taskInfo, SnapPosition.RIGHT) snapToHalfScreen(taskInfo, currentDragBounds, SnapPosition.RIGHT) } DesktopModeVisualIndicator.IndicatorType.NO_INDICATOR -> { // If task bounds are outside valid drag area, snap them inward and perform a // transaction to set bounds. if ( IndicatorType.NO_INDICATOR -> { // If task bounds are outside valid drag area, snap them inward DragPositioningCallbackUtility.snapTaskBoundsIfNecessary( taskBounds, currentDragBounds, validDragArea ) ) { // Update task bounds so that the task position will match the position of its leash val wct = WindowContainerTransaction() wct.setBounds(taskInfo.token, taskBounds) wct.setBounds(taskInfo.token, currentDragBounds) transitions.startTransition(TRANSIT_CHANGE, wct, null) } releaseVisualIndicator() } DesktopModeVisualIndicator.IndicatorType.TO_DESKTOP_INDICATOR -> { IndicatorType.TO_DESKTOP_INDICATOR -> { throw IllegalArgumentException( "Should not be receiving TO_DESKTOP_INDICATOR for " + "a freeform task." ) Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/ToggleResizeDesktopTaskTransitionHandler.kt +14 −4 Original line number Diff line number Diff line Loading @@ -45,15 +45,24 @@ class ToggleResizeDesktopTaskTransitionHandler( private lateinit var onTaskResizeAnimationListener: OnTaskResizeAnimationListener private var boundsAnimator: Animator? = null private var initialBounds: Rect? = null constructor( transitions: Transitions, interactionJankMonitor: InteractionJankMonitor ) : this(transitions, Supplier { SurfaceControl.Transaction() }, interactionJankMonitor) /** Starts a quick resize transition. */ fun startTransition(wct: WindowContainerTransaction) { /** * Starts a quick resize transition. * * @param wct WindowContainerTransaction that will update core about the task changes applied * @param taskLeashBounds current bounds of the task leash (Note: not guaranteed to be the * bounds of the actual task). This is provided so that the animation * resizing can begin where the task leash currently is for smoother UX. */ fun startTransition(wct: WindowContainerTransaction, taskLeashBounds: Rect? = null) { transitions.startTransition(TRANSIT_DESKTOP_MODE_TOGGLE_RESIZE, wct, this) initialBounds = taskLeashBounds } fun setOnTaskResizeAnimationListener(listener: OnTaskResizeAnimationListener) { Loading @@ -70,7 +79,7 @@ class ToggleResizeDesktopTaskTransitionHandler( val change = findRelevantChange(info) val leash = change.leash val taskId = checkNotNull(change.taskInfo).taskId val startBounds = change.startAbsBounds val startBounds = initialBounds ?: change.startAbsBounds val endBounds = change.endAbsBounds val tx = transactionSupplier.get() Loading @@ -92,7 +101,7 @@ class ToggleResizeDesktopTaskTransitionHandler( onTaskResizeAnimationListener.onAnimationStart( taskId, startTransaction, startBounds startBounds, ) }, onEnd = { Loading @@ -106,6 +115,7 @@ class ToggleResizeDesktopTaskTransitionHandler( .show(leash) onTaskResizeAnimationListener.onAnimationEnd(taskId) finishCallback.onTransitionFinished(null) initialBounds = null boundsAnimator = null interactionJankMonitor.end( Cuj.CUJ_DESKTOP_MODE_MAXIMIZE_WINDOW) Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java +8 −4 Original line number Diff line number Diff line Loading @@ -297,7 +297,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { mDisplayInsetsController.addInsetsChangedListener(mContext.getDisplayId(), new DesktopModeOnInsetsChangedListener()); mDesktopTasksController.setOnTaskResizeAnimationListener( new DeskopModeOnTaskResizeAnimationListener()); new DesktopModeOnTaskResizeAnimationListener()); try { mWindowManager.registerSystemGestureExclusionListener(mGestureExclusionListener, mContext.getDisplayId()); Loading Loading @@ -437,6 +437,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { return; } mDesktopTasksController.snapToHalfScreen(decoration.mTaskInfo, decoration.mTaskInfo.configuration.windowConfiguration.getBounds(), left ? SnapPosition.LEFT : SnapPosition.RIGHT); decoration.closeHandleMenu(); decoration.closeMaximizeMenu(); Loading Loading @@ -767,6 +768,9 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { (int) (e.getRawY(dragPointerIdx) - e.getY(dragPointerIdx))); final Rect newTaskBounds = mDragPositioningCallback.onDragPositioningEnd( e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx)); // Tasks bounds haven't actually been updated (only its leash), so pass to // DesktopTasksController to allow secondary transformations (i.e. snap resizing // or transforming to fullscreen) before setting new task bounds. mDesktopTasksController.onDragPositioningEnd(taskInfo, position, new PointF(e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx)), newTaskBounds, decoration.calculateValidDragArea()); Loading Loading @@ -1267,7 +1271,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { pw.println(innerPrefix + "mWindowDecorByTaskId=" + mWindowDecorByTaskId); } private class DeskopModeOnTaskResizeAnimationListener private class DesktopModeOnTaskResizeAnimationListener implements OnTaskResizeAnimationListener { @Override public void onAnimationStart(int taskId, Transaction t, Rect bounds) { Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/FluidResizeTaskPositioner.java +0 −3 Original line number Diff line number Diff line Loading @@ -152,11 +152,8 @@ class FluidResizeTaskPositioner implements DragPositioningCallback, } mDragResizeEndTransition = mTransitions.startTransition(TRANSIT_CHANGE, wct, this); } else if (mCtrlType == CTRL_TYPE_UNDEFINED) { final WindowContainerTransaction wct = new WindowContainerTransaction(); DragPositioningCallbackUtility.updateTaskBounds(mRepositionTaskBounds, mTaskBoundsAtDragStart, mRepositionStartPoint, x, y); wct.setBounds(mWindowDecoration.mTaskInfo.token, mRepositionTaskBounds); mTransitions.startTransition(TRANSIT_CHANGE, wct, this); } mTaskBoundsAtDragStart.setEmpty(); Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/VeiledResizeTaskPositioner.java +0 −7 Original line number Diff line number Diff line Loading @@ -163,15 +163,8 @@ public class VeiledResizeTaskPositioner implements DragPositioningCallback, } else { DragPositioningCallbackUtility.updateTaskBounds(mRepositionTaskBounds, mTaskBoundsAtDragStart, mRepositionStartPoint, x, y); if (!mTaskBoundsAtDragStart.equals(mRepositionTaskBounds)) { final WindowContainerTransaction wct = new WindowContainerTransaction(); wct.setBounds(mDesktopWindowDecoration.mTaskInfo.token, mRepositionTaskBounds); mTransitions.startTransition(TRANSIT_CHANGE, wct, this); } else { // Drag-move ended where it originally started, no need to update WM. mInteractionJankMonitor.end(CUJ_DESKTOP_MODE_DRAG_WINDOW); } } mCtrlType = CTRL_TYPE_UNDEFINED; mTaskBoundsAtDragStart.setEmpty(); Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +33 −25 Original line number Diff line number Diff line Loading @@ -639,16 +639,23 @@ class DesktopTasksController( /** * Quick-resize to the right or left half of the stable bounds. * * @param taskInfo current task that is being snap-resized via dragging or maximize menu button * @param currentDragBounds current position of the task leash being dragged (or current task * bounds if being snapped resize via maximize menu button) * @param position the portion of the screen (RIGHT or LEFT) we want to snap the task to. */ fun snapToHalfScreen(taskInfo: RunningTaskInfo, position: SnapPosition) { fun snapToHalfScreen( taskInfo: RunningTaskInfo, currentDragBounds: Rect, position: SnapPosition ) { val destinationBounds = getSnapBounds(taskInfo, position) if (destinationBounds == taskInfo.configuration.windowConfiguration.bounds) return val wct = WindowContainerTransaction().setBounds(taskInfo.token, destinationBounds) if (Transitions.ENABLE_SHELL_TRANSITIONS) { toggleResizeDesktopTaskTransitionHandler.startTransition(wct) toggleResizeDesktopTaskTransitionHandler.startTransition(wct, currentDragBounds) } else { shellTaskOrganizer.applyTransaction(wct) } Loading Loading @@ -1266,7 +1273,7 @@ class DesktopTasksController( taskSurface: SurfaceControl, inputX: Float, taskTop: Float ): DesktopModeVisualIndicator.IndicatorType { ): IndicatorType { // If the visual indicator does not exist, create it. val indicator = visualIndicator Loading @@ -1289,13 +1296,15 @@ class DesktopTasksController( * @param taskInfo the task being dragged. * @param position position of surface when drag ends. * @param inputCoordinate the coordinates of the motion event * @param taskBounds the updated bounds of the task being dragged. * @param currentDragBounds the current bounds of where the visible task is (might be actual * task bounds or just task leash) * @param validDragArea the bounds of where the task can be dragged within the display. */ fun onDragPositioningEnd( taskInfo: RunningTaskInfo, position: Point, inputCoordinate: PointF, taskBounds: Rect, currentDragBounds: Rect, validDragArea: Rect ) { if (taskInfo.configuration.windowConfiguration.windowingMode != WINDOWING_MODE_FREEFORM) { Loading @@ -1305,41 +1314,40 @@ class DesktopTasksController( val indicator = visualIndicator ?: return val indicatorType = indicator.updateIndicatorType( PointF(inputCoordinate.x, taskBounds.top.toFloat()), PointF(inputCoordinate.x, currentDragBounds.top.toFloat()), taskInfo.windowingMode ) when (indicatorType) { DesktopModeVisualIndicator.IndicatorType.TO_FULLSCREEN_INDICATOR -> { IndicatorType.TO_FULLSCREEN_INDICATOR -> { moveToFullscreenWithAnimation( taskInfo, position, DesktopModeTransitionSource.TASK_DRAG ) } DesktopModeVisualIndicator.IndicatorType.TO_SPLIT_LEFT_INDICATOR -> { IndicatorType.TO_SPLIT_LEFT_INDICATOR -> { releaseVisualIndicator() snapToHalfScreen(taskInfo, SnapPosition.LEFT) snapToHalfScreen(taskInfo, currentDragBounds, SnapPosition.LEFT) } DesktopModeVisualIndicator.IndicatorType.TO_SPLIT_RIGHT_INDICATOR -> { IndicatorType.TO_SPLIT_RIGHT_INDICATOR -> { releaseVisualIndicator() snapToHalfScreen(taskInfo, SnapPosition.RIGHT) snapToHalfScreen(taskInfo, currentDragBounds, SnapPosition.RIGHT) } DesktopModeVisualIndicator.IndicatorType.NO_INDICATOR -> { // If task bounds are outside valid drag area, snap them inward and perform a // transaction to set bounds. if ( IndicatorType.NO_INDICATOR -> { // If task bounds are outside valid drag area, snap them inward DragPositioningCallbackUtility.snapTaskBoundsIfNecessary( taskBounds, currentDragBounds, validDragArea ) ) { // Update task bounds so that the task position will match the position of its leash val wct = WindowContainerTransaction() wct.setBounds(taskInfo.token, taskBounds) wct.setBounds(taskInfo.token, currentDragBounds) transitions.startTransition(TRANSIT_CHANGE, wct, null) } releaseVisualIndicator() } DesktopModeVisualIndicator.IndicatorType.TO_DESKTOP_INDICATOR -> { IndicatorType.TO_DESKTOP_INDICATOR -> { throw IllegalArgumentException( "Should not be receiving TO_DESKTOP_INDICATOR for " + "a freeform task." ) Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/ToggleResizeDesktopTaskTransitionHandler.kt +14 −4 Original line number Diff line number Diff line Loading @@ -45,15 +45,24 @@ class ToggleResizeDesktopTaskTransitionHandler( private lateinit var onTaskResizeAnimationListener: OnTaskResizeAnimationListener private var boundsAnimator: Animator? = null private var initialBounds: Rect? = null constructor( transitions: Transitions, interactionJankMonitor: InteractionJankMonitor ) : this(transitions, Supplier { SurfaceControl.Transaction() }, interactionJankMonitor) /** Starts a quick resize transition. */ fun startTransition(wct: WindowContainerTransaction) { /** * Starts a quick resize transition. * * @param wct WindowContainerTransaction that will update core about the task changes applied * @param taskLeashBounds current bounds of the task leash (Note: not guaranteed to be the * bounds of the actual task). This is provided so that the animation * resizing can begin where the task leash currently is for smoother UX. */ fun startTransition(wct: WindowContainerTransaction, taskLeashBounds: Rect? = null) { transitions.startTransition(TRANSIT_DESKTOP_MODE_TOGGLE_RESIZE, wct, this) initialBounds = taskLeashBounds } fun setOnTaskResizeAnimationListener(listener: OnTaskResizeAnimationListener) { Loading @@ -70,7 +79,7 @@ class ToggleResizeDesktopTaskTransitionHandler( val change = findRelevantChange(info) val leash = change.leash val taskId = checkNotNull(change.taskInfo).taskId val startBounds = change.startAbsBounds val startBounds = initialBounds ?: change.startAbsBounds val endBounds = change.endAbsBounds val tx = transactionSupplier.get() Loading @@ -92,7 +101,7 @@ class ToggleResizeDesktopTaskTransitionHandler( onTaskResizeAnimationListener.onAnimationStart( taskId, startTransaction, startBounds startBounds, ) }, onEnd = { Loading @@ -106,6 +115,7 @@ class ToggleResizeDesktopTaskTransitionHandler( .show(leash) onTaskResizeAnimationListener.onAnimationEnd(taskId) finishCallback.onTransitionFinished(null) initialBounds = null boundsAnimator = null interactionJankMonitor.end( Cuj.CUJ_DESKTOP_MODE_MAXIMIZE_WINDOW) Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java +8 −4 Original line number Diff line number Diff line Loading @@ -297,7 +297,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { mDisplayInsetsController.addInsetsChangedListener(mContext.getDisplayId(), new DesktopModeOnInsetsChangedListener()); mDesktopTasksController.setOnTaskResizeAnimationListener( new DeskopModeOnTaskResizeAnimationListener()); new DesktopModeOnTaskResizeAnimationListener()); try { mWindowManager.registerSystemGestureExclusionListener(mGestureExclusionListener, mContext.getDisplayId()); Loading Loading @@ -437,6 +437,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { return; } mDesktopTasksController.snapToHalfScreen(decoration.mTaskInfo, decoration.mTaskInfo.configuration.windowConfiguration.getBounds(), left ? SnapPosition.LEFT : SnapPosition.RIGHT); decoration.closeHandleMenu(); decoration.closeMaximizeMenu(); Loading Loading @@ -767,6 +768,9 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { (int) (e.getRawY(dragPointerIdx) - e.getY(dragPointerIdx))); final Rect newTaskBounds = mDragPositioningCallback.onDragPositioningEnd( e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx)); // Tasks bounds haven't actually been updated (only its leash), so pass to // DesktopTasksController to allow secondary transformations (i.e. snap resizing // or transforming to fullscreen) before setting new task bounds. mDesktopTasksController.onDragPositioningEnd(taskInfo, position, new PointF(e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx)), newTaskBounds, decoration.calculateValidDragArea()); Loading Loading @@ -1267,7 +1271,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { pw.println(innerPrefix + "mWindowDecorByTaskId=" + mWindowDecorByTaskId); } private class DeskopModeOnTaskResizeAnimationListener private class DesktopModeOnTaskResizeAnimationListener implements OnTaskResizeAnimationListener { @Override public void onAnimationStart(int taskId, Transaction t, Rect bounds) { Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/FluidResizeTaskPositioner.java +0 −3 Original line number Diff line number Diff line Loading @@ -152,11 +152,8 @@ class FluidResizeTaskPositioner implements DragPositioningCallback, } mDragResizeEndTransition = mTransitions.startTransition(TRANSIT_CHANGE, wct, this); } else if (mCtrlType == CTRL_TYPE_UNDEFINED) { final WindowContainerTransaction wct = new WindowContainerTransaction(); DragPositioningCallbackUtility.updateTaskBounds(mRepositionTaskBounds, mTaskBoundsAtDragStart, mRepositionStartPoint, x, y); wct.setBounds(mWindowDecoration.mTaskInfo.token, mRepositionTaskBounds); mTransitions.startTransition(TRANSIT_CHANGE, wct, this); } mTaskBoundsAtDragStart.setEmpty(); Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/VeiledResizeTaskPositioner.java +0 −7 Original line number Diff line number Diff line Loading @@ -163,15 +163,8 @@ public class VeiledResizeTaskPositioner implements DragPositioningCallback, } else { DragPositioningCallbackUtility.updateTaskBounds(mRepositionTaskBounds, mTaskBoundsAtDragStart, mRepositionStartPoint, x, y); if (!mTaskBoundsAtDragStart.equals(mRepositionTaskBounds)) { final WindowContainerTransaction wct = new WindowContainerTransaction(); wct.setBounds(mDesktopWindowDecoration.mTaskInfo.token, mRepositionTaskBounds); mTransitions.startTransition(TRANSIT_CHANGE, wct, this); } else { // Drag-move ended where it originally started, no need to update WM. mInteractionJankMonitor.end(CUJ_DESKTOP_MODE_DRAG_WINDOW); } } mCtrlType = CTRL_TYPE_UNDEFINED; mTaskBoundsAtDragStart.setEmpty(); Loading