Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecorViewModel.java +3 −1 Original line number Diff line number Diff line Loading @@ -468,7 +468,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel, FocusT case MotionEvent.ACTION_DOWN: { mDragPointerId = e.getPointerId(0); mDragPositioningCallback.onDragPositioningStart( 0 /* ctrlType */, e.getRawX(0), e.getRawY(0)); 0 /* ctrlType */, e.getDisplayId(), e.getRawX(0), e.getRawY(0)); mIsDragging = false; return false; } Loading @@ -481,6 +481,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel, FocusT if (decoration.isHandlingDragResize()) break; final int dragPointerIdx = e.findPointerIndex(mDragPointerId); mDragPositioningCallback.onDragPositioningMove( e.getDisplayId(), e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx)); mIsDragging = true; return true; Loading @@ -492,6 +493,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel, FocusT } final int dragPointerIdx = e.findPointerIndex(mDragPointerId); final Rect newTaskBounds = mDragPositioningCallback.onDragPositioningEnd( e.getDisplayId(), e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx)); DragPositioningCallbackUtility.snapTaskBoundsIfNecessary(newTaskBounds, mWindowDecorByTaskId.get(mTaskId).calculateValidDragArea()); Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java +3 −1 Original line number Diff line number Diff line Loading @@ -1140,7 +1140,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel, if (dragAllowed) { mDragPointerId = e.getPointerId(0); final Rect initialBounds = mDragPositioningCallback.onDragPositioningStart( 0 /* ctrlType */, e.getRawX(0), 0 /* ctrlType */, e.getDisplayId(), e.getRawX(0), e.getRawY(0)); updateDragStatus(e.getActionMasked()); mOnDragStartInitialBounds.set(initialBounds); Loading @@ -1161,6 +1161,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel, } final int dragPointerIdx = e.findPointerIndex(mDragPointerId); final Rect newTaskBounds = mDragPositioningCallback.onDragPositioningMove( e.getDisplayId(), e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx)); mDesktopTasksController.onDragPositioningMove(taskInfo, decoration.mTaskSurface, Loading Loading @@ -1191,6 +1192,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel, (int) (e.getRawX(dragPointerIdx) - e.getX(dragPointerIdx)), (int) (e.getRawY(dragPointerIdx) - e.getY(dragPointerIdx))); final Rect newTaskBounds = mDragPositioningCallback.onDragPositioningEnd( e.getDisplayId(), 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 Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DragPositioningCallback.java +8 −3 Original line number Diff line number Diff line Loading @@ -41,25 +41,30 @@ public interface DragPositioningCallback { * * @param ctrlType {@link CtrlType} indicating the direction of resizing, use * {@code 0} to indicate it's a move * @param displayId the ID of the display where the drag starts * @param x x coordinate in window decoration coordinate system where the drag starts * @param y y coordinate in window decoration coordinate system where the drag starts * @return the starting task bounds */ Rect onDragPositioningStart(@CtrlType int ctrlType, float x, float y); Rect onDragPositioningStart(@CtrlType int ctrlType, int displayId, float x, float y); /** * Called when the pointer moves during a drag-resize or drag-move. * * @param displayId the ID of the display where the pointer is currently located * @param x x coordinate in window decoration coordinate system of the new pointer location * @param y y coordinate in window decoration coordinate system of the new pointer location * @return the updated task bounds */ Rect onDragPositioningMove(float x, float y); Rect onDragPositioningMove(int displayId, float x, float y); /** * Called when a drag-resize or drag-move stops. * * @param displayId the ID of the display where the pointer is located when drag stops * @param x x coordinate in window decoration coordinate system where the drag resize stops * @param y y coordinate in window decoration coordinate system where the drag resize stops * @return the final bounds for the dragged task */ Rect onDragPositioningEnd(float x, float y); Rect onDragPositioningEnd(int displayId, float x, float y); } libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DragResizeInputListener.java +4 −3 Original line number Diff line number Diff line Loading @@ -454,7 +454,7 @@ class DragResizeInputListener implements AutoCloseable { ProtoLog.d(WM_SHELL_DESKTOP_MODE, "%s: Handling action down, update ctrlType to %d", TAG, ctrlType); mDragStartTaskBounds = mCallback.onDragPositioningStart(ctrlType, rawX, rawY); e.getDisplayId(), rawX, rawY); mLastMotionEventOnDown = e; mResizeTrigger = (ctrlType == CTRL_TYPE_BOTTOM || ctrlType == CTRL_TYPE_TOP || ctrlType == CTRL_TYPE_RIGHT || ctrlType == CTRL_TYPE_LEFT) Loading Loading @@ -489,7 +489,8 @@ class DragResizeInputListener implements AutoCloseable { } final float rawX = e.getRawX(dragPointerIndex); final float rawY = e.getRawY(dragPointerIndex); final Rect taskBounds = mCallback.onDragPositioningMove(rawX, rawY); final Rect taskBounds = mCallback.onDragPositioningMove(e.getDisplayId(), rawX, rawY); updateInputSinkRegionForDrag(taskBounds); result = true; break; Loading @@ -505,7 +506,7 @@ class DragResizeInputListener implements AutoCloseable { TAG, e.getActionMasked()); break; } final Rect taskBounds = mCallback.onDragPositioningEnd( final Rect taskBounds = mCallback.onDragPositioningEnd(e.getDisplayId(), e.getRawX(dragPointerIndex), e.getRawY(dragPointerIndex)); // If taskBounds has changed, setGeometry will be called and update the // sink region. Otherwise, we should revert it here. Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/FixedAspectRatioTaskPositionerDecorator.kt +27 −26 Original line number Diff line number Diff line Loading @@ -47,10 +47,11 @@ class FixedAspectRatioTaskPositionerDecorator ( private var startingAspectRatio = 0f private var isTaskPortrait = false override fun onDragPositioningStart(@CtrlType ctrlType: Int, x: Float, y: Float): Rect { override fun onDragPositioningStart( @CtrlType ctrlType: Int, displayId: Int, x: Float, y: Float): Rect { originalCtrlType = ctrlType if (!requiresFixedAspectRatio()) { return super.onDragPositioningStart(originalCtrlType, x, y) return super.onDragPositioningStart(originalCtrlType, displayId, x, y) } lastRepositionedBounds.set(getBounds(windowDecoration.mTaskInfo)) Loading @@ -72,27 +73,27 @@ class FixedAspectRatioTaskPositionerDecorator ( val verticalMidPoint = lastRepositionedBounds.top + (startingBoundHeight / 2) edgeResizeCtrlType = originalCtrlType + if (y < verticalMidPoint) CTRL_TYPE_TOP else CTRL_TYPE_BOTTOM super.onDragPositioningStart(edgeResizeCtrlType, x, y) super.onDragPositioningStart(edgeResizeCtrlType, displayId, x, y) } CTRL_TYPE_TOP, CTRL_TYPE_BOTTOM -> { val horizontalMidPoint = lastRepositionedBounds.left + (startingBoundWidth / 2) edgeResizeCtrlType = originalCtrlType + if (x < horizontalMidPoint) CTRL_TYPE_LEFT else CTRL_TYPE_RIGHT super.onDragPositioningStart(edgeResizeCtrlType, x, y) super.onDragPositioningStart(edgeResizeCtrlType, displayId, x, y) } // If resize is corner resize, no alteration to the ctrlType needs to be made. else -> { edgeResizeCtrlType = CTRL_TYPE_UNDEFINED super.onDragPositioningStart(originalCtrlType, x, y) super.onDragPositioningStart(originalCtrlType, displayId, x, y) } } ) return lastRepositionedBounds } override fun onDragPositioningMove(x: Float, y: Float): Rect { override fun onDragPositioningMove(displayId: Int, x: Float, y: Float): Rect { if (!requiresFixedAspectRatio()) { return super.onDragPositioningMove(x, y) return super.onDragPositioningMove(displayId, x, y) } val diffX = x - lastValidPoint.x Loading @@ -103,7 +104,7 @@ class FixedAspectRatioTaskPositionerDecorator ( // Drag coordinate falls within valid region (90 - 180 degrees or 270- 360 // degrees from the corner the previous valid point). Allow resize with adjusted // coordinates to maintain aspect ratio. lastRepositionedBounds.set(dragAdjustedMove(x, y)) lastRepositionedBounds.set(dragAdjustedMove(displayId, x, y)) } } CTRL_TYPE_BOTTOM + CTRL_TYPE_LEFT, CTRL_TYPE_TOP + CTRL_TYPE_RIGHT -> { Loading @@ -111,28 +112,28 @@ class FixedAspectRatioTaskPositionerDecorator ( // Drag coordinate falls within valid region (180 - 270 degrees or 0 - 90 // degrees from the corner the previous valid point). Allow resize with adjusted // coordinates to maintain aspect ratio. lastRepositionedBounds.set(dragAdjustedMove(x, y)) lastRepositionedBounds.set(dragAdjustedMove(displayId, x, y)) } } CTRL_TYPE_LEFT, CTRL_TYPE_RIGHT -> { // If resize is on left or right edge, always adjust the y coordinate. val adjustedY = getScaledChangeForY(x) lastValidPoint.set(x, adjustedY) lastRepositionedBounds.set(super.onDragPositioningMove(x, adjustedY)) lastRepositionedBounds.set(super.onDragPositioningMove(displayId, x, adjustedY)) } CTRL_TYPE_TOP, CTRL_TYPE_BOTTOM -> { // If resize is on top or bottom edge, always adjust the x coordinate. val adjustedX = getScaledChangeForX(y) lastValidPoint.set(adjustedX, y) lastRepositionedBounds.set(super.onDragPositioningMove(adjustedX, y)) lastRepositionedBounds.set(super.onDragPositioningMove(displayId, adjustedX, y)) } } return lastRepositionedBounds } override fun onDragPositioningEnd(x: Float, y: Float): Rect { override fun onDragPositioningEnd(displayId: Int, x: Float, y: Float): Rect { if (!requiresFixedAspectRatio()) { return super.onDragPositioningEnd(x, y) return super.onDragPositioningEnd(displayId, x, y) } val diffX = x - lastValidPoint.x Loading @@ -144,55 +145,55 @@ class FixedAspectRatioTaskPositionerDecorator ( // Drag coordinate falls within valid region (90 - 180 degrees or 270- 360 // degrees from the corner the previous valid point). End resize with adjusted // coordinates to maintain aspect ratio. return dragAdjustedEnd(x, y) return dragAdjustedEnd(displayId, x, y) } // If end of resize is not within valid region, end resize from last valid // coordinates. return super.onDragPositioningEnd(lastValidPoint.x, lastValidPoint.y) return super.onDragPositioningEnd(displayId, lastValidPoint.x, lastValidPoint.y) } CTRL_TYPE_BOTTOM + CTRL_TYPE_LEFT, CTRL_TYPE_TOP + CTRL_TYPE_RIGHT -> { if ((diffX > 0 && diffY < 0) || (diffX < 0 && diffY > 0)) { // Drag coordinate falls within valid region (180 - 260 degrees or 0 - 90 // degrees from the corner the previous valid point). End resize with adjusted // coordinates to maintain aspect ratio. return dragAdjustedEnd(x, y) return dragAdjustedEnd(displayId, x, y) } // If end of resize is not within valid region, end resize from last valid // coordinates. return super.onDragPositioningEnd(lastValidPoint.x, lastValidPoint.y) return super.onDragPositioningEnd(displayId, lastValidPoint.x, lastValidPoint.y) } CTRL_TYPE_LEFT, CTRL_TYPE_RIGHT -> { // If resize is on left or right edge, always adjust the y coordinate. return super.onDragPositioningEnd(x, getScaledChangeForY(x)) return super.onDragPositioningEnd(displayId, x, getScaledChangeForY(x)) } CTRL_TYPE_TOP, CTRL_TYPE_BOTTOM -> { // If resize is on top or bottom edge, always adjust the x coordinate. return super.onDragPositioningEnd(getScaledChangeForX(y), y) return super.onDragPositioningEnd(displayId, getScaledChangeForX(y), y) } else -> { return super.onDragPositioningEnd(x, y) return super.onDragPositioningEnd(displayId, x, y) } } } private fun dragAdjustedMove(x: Float, y: Float): Rect { private fun dragAdjustedMove(displayId: Int, x: Float, y: Float): Rect { val absDiffX = abs(x - lastValidPoint.x) val absDiffY = abs(y - lastValidPoint.y) if (absDiffY < absDiffX) { lastValidPoint.set(getScaledChangeForX(y), y) return super.onDragPositioningMove(getScaledChangeForX(y), y) return super.onDragPositioningMove(displayId, getScaledChangeForX(y), y) } lastValidPoint.set(x, getScaledChangeForY(x)) return super.onDragPositioningMove(x, getScaledChangeForY(x)) return super.onDragPositioningMove(displayId, x, getScaledChangeForY(x)) } private fun dragAdjustedEnd(x: Float, y: Float): Rect { private fun dragAdjustedEnd(displayId: Int, x: Float, y: Float): Rect { val absDiffX = abs(x - lastValidPoint.x) val absDiffY = abs(y - lastValidPoint.y) if (absDiffY < absDiffX) { return super.onDragPositioningEnd(getScaledChangeForX(y), y) return super.onDragPositioningEnd(displayId, getScaledChangeForX(y), y) } return super.onDragPositioningEnd(x, getScaledChangeForY(x)) return super.onDragPositioningEnd(displayId, x, getScaledChangeForY(x)) } /** Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecorViewModel.java +3 −1 Original line number Diff line number Diff line Loading @@ -468,7 +468,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel, FocusT case MotionEvent.ACTION_DOWN: { mDragPointerId = e.getPointerId(0); mDragPositioningCallback.onDragPositioningStart( 0 /* ctrlType */, e.getRawX(0), e.getRawY(0)); 0 /* ctrlType */, e.getDisplayId(), e.getRawX(0), e.getRawY(0)); mIsDragging = false; return false; } Loading @@ -481,6 +481,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel, FocusT if (decoration.isHandlingDragResize()) break; final int dragPointerIdx = e.findPointerIndex(mDragPointerId); mDragPositioningCallback.onDragPositioningMove( e.getDisplayId(), e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx)); mIsDragging = true; return true; Loading @@ -492,6 +493,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel, FocusT } final int dragPointerIdx = e.findPointerIndex(mDragPointerId); final Rect newTaskBounds = mDragPositioningCallback.onDragPositioningEnd( e.getDisplayId(), e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx)); DragPositioningCallbackUtility.snapTaskBoundsIfNecessary(newTaskBounds, mWindowDecorByTaskId.get(mTaskId).calculateValidDragArea()); Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java +3 −1 Original line number Diff line number Diff line Loading @@ -1140,7 +1140,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel, if (dragAllowed) { mDragPointerId = e.getPointerId(0); final Rect initialBounds = mDragPositioningCallback.onDragPositioningStart( 0 /* ctrlType */, e.getRawX(0), 0 /* ctrlType */, e.getDisplayId(), e.getRawX(0), e.getRawY(0)); updateDragStatus(e.getActionMasked()); mOnDragStartInitialBounds.set(initialBounds); Loading @@ -1161,6 +1161,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel, } final int dragPointerIdx = e.findPointerIndex(mDragPointerId); final Rect newTaskBounds = mDragPositioningCallback.onDragPositioningMove( e.getDisplayId(), e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx)); mDesktopTasksController.onDragPositioningMove(taskInfo, decoration.mTaskSurface, Loading Loading @@ -1191,6 +1192,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel, (int) (e.getRawX(dragPointerIdx) - e.getX(dragPointerIdx)), (int) (e.getRawY(dragPointerIdx) - e.getY(dragPointerIdx))); final Rect newTaskBounds = mDragPositioningCallback.onDragPositioningEnd( e.getDisplayId(), 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 Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DragPositioningCallback.java +8 −3 Original line number Diff line number Diff line Loading @@ -41,25 +41,30 @@ public interface DragPositioningCallback { * * @param ctrlType {@link CtrlType} indicating the direction of resizing, use * {@code 0} to indicate it's a move * @param displayId the ID of the display where the drag starts * @param x x coordinate in window decoration coordinate system where the drag starts * @param y y coordinate in window decoration coordinate system where the drag starts * @return the starting task bounds */ Rect onDragPositioningStart(@CtrlType int ctrlType, float x, float y); Rect onDragPositioningStart(@CtrlType int ctrlType, int displayId, float x, float y); /** * Called when the pointer moves during a drag-resize or drag-move. * * @param displayId the ID of the display where the pointer is currently located * @param x x coordinate in window decoration coordinate system of the new pointer location * @param y y coordinate in window decoration coordinate system of the new pointer location * @return the updated task bounds */ Rect onDragPositioningMove(float x, float y); Rect onDragPositioningMove(int displayId, float x, float y); /** * Called when a drag-resize or drag-move stops. * * @param displayId the ID of the display where the pointer is located when drag stops * @param x x coordinate in window decoration coordinate system where the drag resize stops * @param y y coordinate in window decoration coordinate system where the drag resize stops * @return the final bounds for the dragged task */ Rect onDragPositioningEnd(float x, float y); Rect onDragPositioningEnd(int displayId, float x, float y); }
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DragResizeInputListener.java +4 −3 Original line number Diff line number Diff line Loading @@ -454,7 +454,7 @@ class DragResizeInputListener implements AutoCloseable { ProtoLog.d(WM_SHELL_DESKTOP_MODE, "%s: Handling action down, update ctrlType to %d", TAG, ctrlType); mDragStartTaskBounds = mCallback.onDragPositioningStart(ctrlType, rawX, rawY); e.getDisplayId(), rawX, rawY); mLastMotionEventOnDown = e; mResizeTrigger = (ctrlType == CTRL_TYPE_BOTTOM || ctrlType == CTRL_TYPE_TOP || ctrlType == CTRL_TYPE_RIGHT || ctrlType == CTRL_TYPE_LEFT) Loading Loading @@ -489,7 +489,8 @@ class DragResizeInputListener implements AutoCloseable { } final float rawX = e.getRawX(dragPointerIndex); final float rawY = e.getRawY(dragPointerIndex); final Rect taskBounds = mCallback.onDragPositioningMove(rawX, rawY); final Rect taskBounds = mCallback.onDragPositioningMove(e.getDisplayId(), rawX, rawY); updateInputSinkRegionForDrag(taskBounds); result = true; break; Loading @@ -505,7 +506,7 @@ class DragResizeInputListener implements AutoCloseable { TAG, e.getActionMasked()); break; } final Rect taskBounds = mCallback.onDragPositioningEnd( final Rect taskBounds = mCallback.onDragPositioningEnd(e.getDisplayId(), e.getRawX(dragPointerIndex), e.getRawY(dragPointerIndex)); // If taskBounds has changed, setGeometry will be called and update the // sink region. Otherwise, we should revert it here. Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/FixedAspectRatioTaskPositionerDecorator.kt +27 −26 Original line number Diff line number Diff line Loading @@ -47,10 +47,11 @@ class FixedAspectRatioTaskPositionerDecorator ( private var startingAspectRatio = 0f private var isTaskPortrait = false override fun onDragPositioningStart(@CtrlType ctrlType: Int, x: Float, y: Float): Rect { override fun onDragPositioningStart( @CtrlType ctrlType: Int, displayId: Int, x: Float, y: Float): Rect { originalCtrlType = ctrlType if (!requiresFixedAspectRatio()) { return super.onDragPositioningStart(originalCtrlType, x, y) return super.onDragPositioningStart(originalCtrlType, displayId, x, y) } lastRepositionedBounds.set(getBounds(windowDecoration.mTaskInfo)) Loading @@ -72,27 +73,27 @@ class FixedAspectRatioTaskPositionerDecorator ( val verticalMidPoint = lastRepositionedBounds.top + (startingBoundHeight / 2) edgeResizeCtrlType = originalCtrlType + if (y < verticalMidPoint) CTRL_TYPE_TOP else CTRL_TYPE_BOTTOM super.onDragPositioningStart(edgeResizeCtrlType, x, y) super.onDragPositioningStart(edgeResizeCtrlType, displayId, x, y) } CTRL_TYPE_TOP, CTRL_TYPE_BOTTOM -> { val horizontalMidPoint = lastRepositionedBounds.left + (startingBoundWidth / 2) edgeResizeCtrlType = originalCtrlType + if (x < horizontalMidPoint) CTRL_TYPE_LEFT else CTRL_TYPE_RIGHT super.onDragPositioningStart(edgeResizeCtrlType, x, y) super.onDragPositioningStart(edgeResizeCtrlType, displayId, x, y) } // If resize is corner resize, no alteration to the ctrlType needs to be made. else -> { edgeResizeCtrlType = CTRL_TYPE_UNDEFINED super.onDragPositioningStart(originalCtrlType, x, y) super.onDragPositioningStart(originalCtrlType, displayId, x, y) } } ) return lastRepositionedBounds } override fun onDragPositioningMove(x: Float, y: Float): Rect { override fun onDragPositioningMove(displayId: Int, x: Float, y: Float): Rect { if (!requiresFixedAspectRatio()) { return super.onDragPositioningMove(x, y) return super.onDragPositioningMove(displayId, x, y) } val diffX = x - lastValidPoint.x Loading @@ -103,7 +104,7 @@ class FixedAspectRatioTaskPositionerDecorator ( // Drag coordinate falls within valid region (90 - 180 degrees or 270- 360 // degrees from the corner the previous valid point). Allow resize with adjusted // coordinates to maintain aspect ratio. lastRepositionedBounds.set(dragAdjustedMove(x, y)) lastRepositionedBounds.set(dragAdjustedMove(displayId, x, y)) } } CTRL_TYPE_BOTTOM + CTRL_TYPE_LEFT, CTRL_TYPE_TOP + CTRL_TYPE_RIGHT -> { Loading @@ -111,28 +112,28 @@ class FixedAspectRatioTaskPositionerDecorator ( // Drag coordinate falls within valid region (180 - 270 degrees or 0 - 90 // degrees from the corner the previous valid point). Allow resize with adjusted // coordinates to maintain aspect ratio. lastRepositionedBounds.set(dragAdjustedMove(x, y)) lastRepositionedBounds.set(dragAdjustedMove(displayId, x, y)) } } CTRL_TYPE_LEFT, CTRL_TYPE_RIGHT -> { // If resize is on left or right edge, always adjust the y coordinate. val adjustedY = getScaledChangeForY(x) lastValidPoint.set(x, adjustedY) lastRepositionedBounds.set(super.onDragPositioningMove(x, adjustedY)) lastRepositionedBounds.set(super.onDragPositioningMove(displayId, x, adjustedY)) } CTRL_TYPE_TOP, CTRL_TYPE_BOTTOM -> { // If resize is on top or bottom edge, always adjust the x coordinate. val adjustedX = getScaledChangeForX(y) lastValidPoint.set(adjustedX, y) lastRepositionedBounds.set(super.onDragPositioningMove(adjustedX, y)) lastRepositionedBounds.set(super.onDragPositioningMove(displayId, adjustedX, y)) } } return lastRepositionedBounds } override fun onDragPositioningEnd(x: Float, y: Float): Rect { override fun onDragPositioningEnd(displayId: Int, x: Float, y: Float): Rect { if (!requiresFixedAspectRatio()) { return super.onDragPositioningEnd(x, y) return super.onDragPositioningEnd(displayId, x, y) } val diffX = x - lastValidPoint.x Loading @@ -144,55 +145,55 @@ class FixedAspectRatioTaskPositionerDecorator ( // Drag coordinate falls within valid region (90 - 180 degrees or 270- 360 // degrees from the corner the previous valid point). End resize with adjusted // coordinates to maintain aspect ratio. return dragAdjustedEnd(x, y) return dragAdjustedEnd(displayId, x, y) } // If end of resize is not within valid region, end resize from last valid // coordinates. return super.onDragPositioningEnd(lastValidPoint.x, lastValidPoint.y) return super.onDragPositioningEnd(displayId, lastValidPoint.x, lastValidPoint.y) } CTRL_TYPE_BOTTOM + CTRL_TYPE_LEFT, CTRL_TYPE_TOP + CTRL_TYPE_RIGHT -> { if ((diffX > 0 && diffY < 0) || (diffX < 0 && diffY > 0)) { // Drag coordinate falls within valid region (180 - 260 degrees or 0 - 90 // degrees from the corner the previous valid point). End resize with adjusted // coordinates to maintain aspect ratio. return dragAdjustedEnd(x, y) return dragAdjustedEnd(displayId, x, y) } // If end of resize is not within valid region, end resize from last valid // coordinates. return super.onDragPositioningEnd(lastValidPoint.x, lastValidPoint.y) return super.onDragPositioningEnd(displayId, lastValidPoint.x, lastValidPoint.y) } CTRL_TYPE_LEFT, CTRL_TYPE_RIGHT -> { // If resize is on left or right edge, always adjust the y coordinate. return super.onDragPositioningEnd(x, getScaledChangeForY(x)) return super.onDragPositioningEnd(displayId, x, getScaledChangeForY(x)) } CTRL_TYPE_TOP, CTRL_TYPE_BOTTOM -> { // If resize is on top or bottom edge, always adjust the x coordinate. return super.onDragPositioningEnd(getScaledChangeForX(y), y) return super.onDragPositioningEnd(displayId, getScaledChangeForX(y), y) } else -> { return super.onDragPositioningEnd(x, y) return super.onDragPositioningEnd(displayId, x, y) } } } private fun dragAdjustedMove(x: Float, y: Float): Rect { private fun dragAdjustedMove(displayId: Int, x: Float, y: Float): Rect { val absDiffX = abs(x - lastValidPoint.x) val absDiffY = abs(y - lastValidPoint.y) if (absDiffY < absDiffX) { lastValidPoint.set(getScaledChangeForX(y), y) return super.onDragPositioningMove(getScaledChangeForX(y), y) return super.onDragPositioningMove(displayId, getScaledChangeForX(y), y) } lastValidPoint.set(x, getScaledChangeForY(x)) return super.onDragPositioningMove(x, getScaledChangeForY(x)) return super.onDragPositioningMove(displayId, x, getScaledChangeForY(x)) } private fun dragAdjustedEnd(x: Float, y: Float): Rect { private fun dragAdjustedEnd(displayId: Int, x: Float, y: Float): Rect { val absDiffX = abs(x - lastValidPoint.x) val absDiffY = abs(y - lastValidPoint.y) if (absDiffY < absDiffX) { return super.onDragPositioningEnd(getScaledChangeForX(y), y) return super.onDragPositioningEnd(displayId, getScaledChangeForX(y), y) } return super.onDragPositioningEnd(x, getScaledChangeForY(x)) return super.onDragPositioningEnd(displayId, x, getScaledChangeForY(x)) } /** Loading