Merge "Rename DragResizeCallback to DragPositioningCallback." into tm-qpr-dev am: c52342b106
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21036774 Change-Id: Ie0277c3dadc32bc624027c31b8c17a9a52aa0ae9 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -174,7 +174,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel {
|
|||||||
final CaptionTouchEventListener touchEventListener =
|
final CaptionTouchEventListener touchEventListener =
|
||||||
new CaptionTouchEventListener(taskInfo, taskPositioner);
|
new CaptionTouchEventListener(taskInfo, taskPositioner);
|
||||||
windowDecoration.setCaptionListeners(touchEventListener, touchEventListener);
|
windowDecoration.setCaptionListeners(touchEventListener, touchEventListener);
|
||||||
windowDecoration.setDragResizeCallback(taskPositioner);
|
windowDecoration.setDragPositioningCallback(taskPositioner);
|
||||||
windowDecoration.setDragDetector(touchEventListener.mDragDetector);
|
windowDecoration.setDragDetector(touchEventListener.mDragDetector);
|
||||||
windowDecoration.relayout(taskInfo, startT, finishT);
|
windowDecoration.relayout(taskInfo, startT, finishT);
|
||||||
setupCaptionColor(taskInfo, windowDecoration);
|
setupCaptionColor(taskInfo, windowDecoration);
|
||||||
@@ -185,17 +185,17 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel {
|
|||||||
|
|
||||||
private final int mTaskId;
|
private final int mTaskId;
|
||||||
private final WindowContainerToken mTaskToken;
|
private final WindowContainerToken mTaskToken;
|
||||||
private final DragResizeCallback mDragResizeCallback;
|
private final DragPositioningCallback mDragPositioningCallback;
|
||||||
private final DragDetector mDragDetector;
|
private final DragDetector mDragDetector;
|
||||||
|
|
||||||
private int mDragPointerId = -1;
|
private int mDragPointerId = -1;
|
||||||
|
|
||||||
private CaptionTouchEventListener(
|
private CaptionTouchEventListener(
|
||||||
RunningTaskInfo taskInfo,
|
RunningTaskInfo taskInfo,
|
||||||
DragResizeCallback dragResizeCallback) {
|
DragPositioningCallback dragPositioningCallback) {
|
||||||
mTaskId = taskInfo.taskId;
|
mTaskId = taskInfo.taskId;
|
||||||
mTaskToken = taskInfo.token;
|
mTaskToken = taskInfo.token;
|
||||||
mDragResizeCallback = dragResizeCallback;
|
mDragPositioningCallback = dragPositioningCallback;
|
||||||
mDragDetector = new DragDetector(this);
|
mDragDetector = new DragDetector(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,20 +247,20 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel {
|
|||||||
switch (e.getActionMasked()) {
|
switch (e.getActionMasked()) {
|
||||||
case MotionEvent.ACTION_DOWN: {
|
case MotionEvent.ACTION_DOWN: {
|
||||||
mDragPointerId = e.getPointerId(0);
|
mDragPointerId = e.getPointerId(0);
|
||||||
mDragResizeCallback.onDragResizeStart(
|
mDragPositioningCallback.onDragPositioningStart(
|
||||||
0 /* ctrlType */, e.getRawX(0), e.getRawY(0));
|
0 /* ctrlType */, e.getRawX(0), e.getRawY(0));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MotionEvent.ACTION_MOVE: {
|
case MotionEvent.ACTION_MOVE: {
|
||||||
int dragPointerIdx = e.findPointerIndex(mDragPointerId);
|
int dragPointerIdx = e.findPointerIndex(mDragPointerId);
|
||||||
mDragResizeCallback.onDragResizeMove(
|
mDragPositioningCallback.onDragPositioningMove(
|
||||||
e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx));
|
e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MotionEvent.ACTION_UP:
|
case MotionEvent.ACTION_UP:
|
||||||
case MotionEvent.ACTION_CANCEL: {
|
case MotionEvent.ACTION_CANCEL: {
|
||||||
int dragPointerIdx = e.findPointerIndex(mDragPointerId);
|
int dragPointerIdx = e.findPointerIndex(mDragPointerId);
|
||||||
mDragResizeCallback.onDragResizeEnd(
|
mDragPositioningCallback.onDragPositioningEnd(
|
||||||
e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx));
|
e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
|
|||||||
|
|
||||||
private View.OnClickListener mOnCaptionButtonClickListener;
|
private View.OnClickListener mOnCaptionButtonClickListener;
|
||||||
private View.OnTouchListener mOnCaptionTouchListener;
|
private View.OnTouchListener mOnCaptionTouchListener;
|
||||||
private DragResizeCallback mDragResizeCallback;
|
private DragPositioningCallback mDragPositioningCallback;
|
||||||
private DragResizeInputListener mDragResizeListener;
|
private DragResizeInputListener mDragResizeListener;
|
||||||
private DragDetector mDragDetector;
|
private DragDetector mDragDetector;
|
||||||
|
|
||||||
@@ -78,8 +78,8 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
|
|||||||
mOnCaptionTouchListener = onCaptionTouchListener;
|
mOnCaptionTouchListener = onCaptionTouchListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDragResizeCallback(DragResizeCallback dragResizeCallback) {
|
void setDragPositioningCallback(DragPositioningCallback dragPositioningCallback) {
|
||||||
mDragResizeCallback = dragResizeCallback;
|
mDragPositioningCallback = dragPositioningCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDragDetector(DragDetector dragDetector) {
|
void setDragDetector(DragDetector dragDetector) {
|
||||||
@@ -151,7 +151,7 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
|
|||||||
mChoreographer,
|
mChoreographer,
|
||||||
mDisplay.getDisplayId(),
|
mDisplay.getDisplayId(),
|
||||||
mDecorationContainerSurface,
|
mDecorationContainerSurface,
|
||||||
mDragResizeCallback);
|
mDragPositioningCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
final int touchSlop = ViewConfiguration.get(mResult.mRootView.getContext())
|
final int touchSlop = ViewConfiguration.get(mResult.mRootView.getContext())
|
||||||
|
|||||||
@@ -209,17 +209,17 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
|
|||||||
|
|
||||||
private final int mTaskId;
|
private final int mTaskId;
|
||||||
private final WindowContainerToken mTaskToken;
|
private final WindowContainerToken mTaskToken;
|
||||||
private final DragResizeCallback mDragResizeCallback;
|
private final DragPositioningCallback mDragPositioningCallback;
|
||||||
private final DragDetector mDragDetector;
|
private final DragDetector mDragDetector;
|
||||||
|
|
||||||
private int mDragPointerId = -1;
|
private int mDragPointerId = -1;
|
||||||
|
|
||||||
private DesktopModeTouchEventListener(
|
private DesktopModeTouchEventListener(
|
||||||
RunningTaskInfo taskInfo,
|
RunningTaskInfo taskInfo,
|
||||||
DragResizeCallback dragResizeCallback) {
|
DragPositioningCallback dragPositioningCallback) {
|
||||||
mTaskId = taskInfo.taskId;
|
mTaskId = taskInfo.taskId;
|
||||||
mTaskToken = taskInfo.token;
|
mTaskToken = taskInfo.token;
|
||||||
mDragResizeCallback = dragResizeCallback;
|
mDragPositioningCallback = dragPositioningCallback;
|
||||||
mDragDetector = new DragDetector(this);
|
mDragDetector = new DragDetector(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,13 +283,13 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
|
|||||||
switch (e.getActionMasked()) {
|
switch (e.getActionMasked()) {
|
||||||
case MotionEvent.ACTION_DOWN: {
|
case MotionEvent.ACTION_DOWN: {
|
||||||
mDragPointerId = e.getPointerId(0);
|
mDragPointerId = e.getPointerId(0);
|
||||||
mDragResizeCallback.onDragResizeStart(
|
mDragPositioningCallback.onDragPositioningStart(
|
||||||
0 /* ctrlType */, e.getRawX(0), e.getRawY(0));
|
0 /* ctrlType */, e.getRawX(0), e.getRawY(0));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MotionEvent.ACTION_MOVE: {
|
case MotionEvent.ACTION_MOVE: {
|
||||||
final int dragPointerIdx = e.findPointerIndex(mDragPointerId);
|
final int dragPointerIdx = e.findPointerIndex(mDragPointerId);
|
||||||
mDragResizeCallback.onDragResizeMove(
|
mDragPositioningCallback.onDragPositioningMove(
|
||||||
e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx));
|
e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -298,7 +298,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
|
|||||||
final int dragPointerIdx = e.findPointerIndex(mDragPointerId);
|
final int dragPointerIdx = e.findPointerIndex(mDragPointerId);
|
||||||
final int statusBarHeight = mDisplayController
|
final int statusBarHeight = mDisplayController
|
||||||
.getDisplayLayout(taskInfo.displayId).stableInsets().top;
|
.getDisplayLayout(taskInfo.displayId).stableInsets().top;
|
||||||
mDragResizeCallback.onDragResizeEnd(
|
mDragPositioningCallback.onDragPositioningEnd(
|
||||||
e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx));
|
e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx));
|
||||||
if (e.getRawY(dragPointerIdx) <= statusBarHeight) {
|
if (e.getRawY(dragPointerIdx) <= statusBarHeight) {
|
||||||
if (DesktopModeStatus.isProto2Enabled()) {
|
if (DesktopModeStatus.isProto2Enabled()) {
|
||||||
@@ -557,7 +557,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
|
|||||||
final DesktopModeTouchEventListener touchEventListener =
|
final DesktopModeTouchEventListener touchEventListener =
|
||||||
new DesktopModeTouchEventListener(taskInfo, taskPositioner);
|
new DesktopModeTouchEventListener(taskInfo, taskPositioner);
|
||||||
windowDecoration.setCaptionListeners(touchEventListener, touchEventListener);
|
windowDecoration.setCaptionListeners(touchEventListener, touchEventListener);
|
||||||
windowDecoration.setDragResizeCallback(taskPositioner);
|
windowDecoration.setDragPositioningCallback(taskPositioner);
|
||||||
windowDecoration.setDragDetector(touchEventListener.mDragDetector);
|
windowDecoration.setDragDetector(touchEventListener.mDragDetector);
|
||||||
windowDecoration.relayout(taskInfo, startT, finishT);
|
windowDecoration.relayout(taskInfo, startT, finishT);
|
||||||
incrementEventReceiverTasks(taskInfo.displayId);
|
incrementEventReceiverTasks(taskInfo.displayId);
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
|
|||||||
|
|
||||||
private View.OnClickListener mOnCaptionButtonClickListener;
|
private View.OnClickListener mOnCaptionButtonClickListener;
|
||||||
private View.OnTouchListener mOnCaptionTouchListener;
|
private View.OnTouchListener mOnCaptionTouchListener;
|
||||||
private DragResizeCallback mDragResizeCallback;
|
private DragPositioningCallback mDragPositioningCallback;
|
||||||
private DragResizeInputListener mDragResizeListener;
|
private DragResizeInputListener mDragResizeListener;
|
||||||
private DragDetector mDragDetector;
|
private DragDetector mDragDetector;
|
||||||
|
|
||||||
@@ -90,8 +90,8 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
|
|||||||
mOnCaptionTouchListener = onCaptionTouchListener;
|
mOnCaptionTouchListener = onCaptionTouchListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDragResizeCallback(DragResizeCallback dragResizeCallback) {
|
void setDragPositioningCallback(DragPositioningCallback dragPositioningCallback) {
|
||||||
mDragResizeCallback = dragResizeCallback;
|
mDragPositioningCallback = dragPositioningCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDragDetector(DragDetector dragDetector) {
|
void setDragDetector(DragDetector dragDetector) {
|
||||||
@@ -179,7 +179,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
|
|||||||
mChoreographer,
|
mChoreographer,
|
||||||
mDisplay.getDisplayId(),
|
mDisplay.getDisplayId(),
|
||||||
mDecorationContainerSurface,
|
mDecorationContainerSurface,
|
||||||
mDragResizeCallback);
|
mDragPositioningCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
final int touchSlop = ViewConfiguration.get(mResult.mRootView.getContext())
|
final int touchSlop = ViewConfiguration.get(mResult.mRootView.getContext())
|
||||||
|
|||||||
@@ -19,28 +19,28 @@ package com.android.wm.shell.windowdecor;
|
|||||||
/**
|
/**
|
||||||
* Callback called when receiving drag-resize or drag-move related input events.
|
* Callback called when receiving drag-resize or drag-move related input events.
|
||||||
*/
|
*/
|
||||||
public interface DragResizeCallback {
|
public interface DragPositioningCallback {
|
||||||
/**
|
/**
|
||||||
* Called when a drag resize starts.
|
* Called when a drag-resize or drag-move starts.
|
||||||
*
|
*
|
||||||
* @param ctrlType {@link TaskPositioner.CtrlType} indicating the direction of resizing, use
|
* @param ctrlType {@link TaskPositioner.CtrlType} indicating the direction of resizing, use
|
||||||
* {@code 0} to indicate it's a move
|
* {@code 0} to indicate it's a move
|
||||||
* @param x x coordinate in window decoration coordinate system where the drag resize 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 resize starts
|
* @param y y coordinate in window decoration coordinate system where the drag starts
|
||||||
*/
|
*/
|
||||||
void onDragResizeStart(@TaskPositioner.CtrlType int ctrlType, float x, float y);
|
void onDragPositioningStart(@TaskPositioner.CtrlType int ctrlType, float x, float y);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the pointer moves during a drag resize.
|
* Called when the pointer moves during a drag-resize or drag-move.
|
||||||
* @param x x coordinate in window decoration coordinate system of the new pointer location
|
* @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
|
* @param y y coordinate in window decoration coordinate system of the new pointer location
|
||||||
*/
|
*/
|
||||||
void onDragResizeMove(float x, float y);
|
void onDragPositioningMove(float x, float y);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a drag resize stops.
|
* Called when a drag-resize or drag-move stops.
|
||||||
* @param x x coordinate in window decoration coordinate system where the drag resize 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
|
* @param y y coordinate in window decoration coordinate system where the drag resize stops
|
||||||
*/
|
*/
|
||||||
void onDragResizeEnd(float x, float y);
|
void onDragPositioningEnd(float x, float y);
|
||||||
}
|
}
|
||||||
@@ -62,7 +62,7 @@ class DragResizeInputListener implements AutoCloseable {
|
|||||||
private final SurfaceControl mDecorationSurface;
|
private final SurfaceControl mDecorationSurface;
|
||||||
private final InputChannel mInputChannel;
|
private final InputChannel mInputChannel;
|
||||||
private final TaskResizeInputEventReceiver mInputEventReceiver;
|
private final TaskResizeInputEventReceiver mInputEventReceiver;
|
||||||
private final com.android.wm.shell.windowdecor.DragResizeCallback mCallback;
|
private final DragPositioningCallback mCallback;
|
||||||
|
|
||||||
private int mWidth;
|
private int mWidth;
|
||||||
private int mHeight;
|
private int mHeight;
|
||||||
@@ -83,7 +83,7 @@ class DragResizeInputListener implements AutoCloseable {
|
|||||||
Choreographer choreographer,
|
Choreographer choreographer,
|
||||||
int displayId,
|
int displayId,
|
||||||
SurfaceControl decorationSurface,
|
SurfaceControl decorationSurface,
|
||||||
DragResizeCallback callback) {
|
DragPositioningCallback callback) {
|
||||||
mInputManager = context.getSystemService(InputManager.class);
|
mInputManager = context.getSystemService(InputManager.class);
|
||||||
mHandler = handler;
|
mHandler = handler;
|
||||||
mChoreographer = choreographer;
|
mChoreographer = choreographer;
|
||||||
@@ -293,7 +293,7 @@ class DragResizeInputListener implements AutoCloseable {
|
|||||||
float rawX = e.getRawX(0);
|
float rawX = e.getRawX(0);
|
||||||
float rawY = e.getRawY(0);
|
float rawY = e.getRawY(0);
|
||||||
int ctrlType = calculateCtrlType(isTouch, x, y);
|
int ctrlType = calculateCtrlType(isTouch, x, y);
|
||||||
mCallback.onDragResizeStart(ctrlType, rawX, rawY);
|
mCallback.onDragPositioningStart(ctrlType, rawX, rawY);
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -305,7 +305,7 @@ class DragResizeInputListener implements AutoCloseable {
|
|||||||
int dragPointerIndex = e.findPointerIndex(mDragPointerId);
|
int dragPointerIndex = e.findPointerIndex(mDragPointerId);
|
||||||
float rawX = e.getRawX(dragPointerIndex);
|
float rawX = e.getRawX(dragPointerIndex);
|
||||||
float rawY = e.getRawY(dragPointerIndex);
|
float rawY = e.getRawY(dragPointerIndex);
|
||||||
mCallback.onDragResizeMove(rawX, rawY);
|
mCallback.onDragPositioningMove(rawX, rawY);
|
||||||
result = true;
|
result = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -313,7 +313,7 @@ class DragResizeInputListener implements AutoCloseable {
|
|||||||
case MotionEvent.ACTION_CANCEL: {
|
case MotionEvent.ACTION_CANCEL: {
|
||||||
if (mShouldHandleEvents) {
|
if (mShouldHandleEvents) {
|
||||||
int dragPointerIndex = e.findPointerIndex(mDragPointerId);
|
int dragPointerIndex = e.findPointerIndex(mDragPointerId);
|
||||||
mCallback.onDragResizeEnd(
|
mCallback.onDragPositioningEnd(
|
||||||
e.getRawX(dragPointerIndex), e.getRawY(dragPointerIndex));
|
e.getRawX(dragPointerIndex), e.getRawY(dragPointerIndex));
|
||||||
}
|
}
|
||||||
mShouldHandleEvents = false;
|
mShouldHandleEvents = false;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import android.window.WindowContainerTransaction;
|
|||||||
|
|
||||||
import com.android.wm.shell.ShellTaskOrganizer;
|
import com.android.wm.shell.ShellTaskOrganizer;
|
||||||
|
|
||||||
class TaskPositioner implements DragResizeCallback {
|
class TaskPositioner implements DragPositioningCallback {
|
||||||
|
|
||||||
@IntDef({CTRL_TYPE_UNDEFINED, CTRL_TYPE_LEFT, CTRL_TYPE_RIGHT, CTRL_TYPE_TOP, CTRL_TYPE_BOTTOM})
|
@IntDef({CTRL_TYPE_UNDEFINED, CTRL_TYPE_LEFT, CTRL_TYPE_RIGHT, CTRL_TYPE_TOP, CTRL_TYPE_BOTTOM})
|
||||||
@interface CtrlType {}
|
@interface CtrlType {}
|
||||||
@@ -38,8 +38,8 @@ class TaskPositioner implements DragResizeCallback {
|
|||||||
private final WindowDecoration mWindowDecoration;
|
private final WindowDecoration mWindowDecoration;
|
||||||
|
|
||||||
private final Rect mTaskBoundsAtDragStart = new Rect();
|
private final Rect mTaskBoundsAtDragStart = new Rect();
|
||||||
private final PointF mResizeStartPoint = new PointF();
|
private final PointF mRepositionStartPoint = new PointF();
|
||||||
private final Rect mResizeTaskBounds = new Rect();
|
private final Rect mRepositionTaskBounds = new Rect();
|
||||||
private boolean mHasMoved = false;
|
private boolean mHasMoved = false;
|
||||||
|
|
||||||
private int mCtrlType;
|
private int mCtrlType;
|
||||||
@@ -57,7 +57,7 @@ class TaskPositioner implements DragResizeCallback {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDragResizeStart(int ctrlType, float x, float y) {
|
public void onDragPositioningStart(int ctrlType, float x, float y) {
|
||||||
mHasMoved = false;
|
mHasMoved = false;
|
||||||
|
|
||||||
mDragStartListener.onDragStart(mWindowDecoration.mTaskInfo.taskId);
|
mDragStartListener.onDragStart(mWindowDecoration.mTaskInfo.taskId);
|
||||||
@@ -65,11 +65,11 @@ class TaskPositioner implements DragResizeCallback {
|
|||||||
|
|
||||||
mTaskBoundsAtDragStart.set(
|
mTaskBoundsAtDragStart.set(
|
||||||
mWindowDecoration.mTaskInfo.configuration.windowConfiguration.getBounds());
|
mWindowDecoration.mTaskInfo.configuration.windowConfiguration.getBounds());
|
||||||
mResizeStartPoint.set(x, y);
|
mRepositionStartPoint.set(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDragResizeMove(float x, float y) {
|
public void onDragPositioningMove(float x, float y) {
|
||||||
final WindowContainerTransaction wct = new WindowContainerTransaction();
|
final WindowContainerTransaction wct = new WindowContainerTransaction();
|
||||||
if (changeBounds(wct, x, y)) {
|
if (changeBounds(wct, x, y)) {
|
||||||
// The task is being resized, send the |dragResizing| hint to core with the first
|
// The task is being resized, send the |dragResizing| hint to core with the first
|
||||||
@@ -84,7 +84,7 @@ class TaskPositioner implements DragResizeCallback {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDragResizeEnd(float x, float y) {
|
public void onDragPositioningEnd(float x, float y) {
|
||||||
// |mHasMoved| being false means there is no real change to the task bounds in WM core, so
|
// |mHasMoved| being false means there is no real change to the task bounds in WM core, so
|
||||||
// we don't need a WCT to finish it.
|
// we don't need a WCT to finish it.
|
||||||
if (mHasMoved) {
|
if (mHasMoved) {
|
||||||
@@ -96,42 +96,44 @@ class TaskPositioner implements DragResizeCallback {
|
|||||||
|
|
||||||
mCtrlType = CTRL_TYPE_UNDEFINED;
|
mCtrlType = CTRL_TYPE_UNDEFINED;
|
||||||
mTaskBoundsAtDragStart.setEmpty();
|
mTaskBoundsAtDragStart.setEmpty();
|
||||||
mResizeStartPoint.set(0, 0);
|
mRepositionStartPoint.set(0, 0);
|
||||||
mHasMoved = false;
|
mHasMoved = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean changeBounds(WindowContainerTransaction wct, float x, float y) {
|
private boolean changeBounds(WindowContainerTransaction wct, float x, float y) {
|
||||||
// |mResizeTaskBounds| is the bounds last reported if |mHasMoved| is true. If it's not true,
|
// |mRepositionTaskBounds| is the bounds last reported if |mHasMoved| is true. If it's not
|
||||||
// we can compare it against |mTaskBoundsAtDragStart|.
|
// true, we can compare it against |mTaskBoundsAtDragStart|.
|
||||||
final int oldLeft = mHasMoved ? mResizeTaskBounds.left : mTaskBoundsAtDragStart.left;
|
final int oldLeft = mHasMoved ? mRepositionTaskBounds.left : mTaskBoundsAtDragStart.left;
|
||||||
final int oldTop = mHasMoved ? mResizeTaskBounds.top : mTaskBoundsAtDragStart.top;
|
final int oldTop = mHasMoved ? mRepositionTaskBounds.top : mTaskBoundsAtDragStart.top;
|
||||||
final int oldRight = mHasMoved ? mResizeTaskBounds.right : mTaskBoundsAtDragStart.right;
|
final int oldRight = mHasMoved ? mRepositionTaskBounds.right : mTaskBoundsAtDragStart.right;
|
||||||
final int oldBottom = mHasMoved ? mResizeTaskBounds.bottom : mTaskBoundsAtDragStart.bottom;
|
final int oldBottom =
|
||||||
|
mHasMoved ? mRepositionTaskBounds.bottom : mTaskBoundsAtDragStart.bottom;
|
||||||
|
|
||||||
final float deltaX = x - mResizeStartPoint.x;
|
final float deltaX = x - mRepositionStartPoint.x;
|
||||||
final float deltaY = y - mResizeStartPoint.y;
|
final float deltaY = y - mRepositionStartPoint.y;
|
||||||
mResizeTaskBounds.set(mTaskBoundsAtDragStart);
|
mRepositionTaskBounds.set(mTaskBoundsAtDragStart);
|
||||||
if ((mCtrlType & CTRL_TYPE_LEFT) != 0) {
|
if ((mCtrlType & CTRL_TYPE_LEFT) != 0) {
|
||||||
mResizeTaskBounds.left += deltaX;
|
mRepositionTaskBounds.left += deltaX;
|
||||||
}
|
}
|
||||||
if ((mCtrlType & CTRL_TYPE_RIGHT) != 0) {
|
if ((mCtrlType & CTRL_TYPE_RIGHT) != 0) {
|
||||||
mResizeTaskBounds.right += deltaX;
|
mRepositionTaskBounds.right += deltaX;
|
||||||
}
|
}
|
||||||
if ((mCtrlType & CTRL_TYPE_TOP) != 0) {
|
if ((mCtrlType & CTRL_TYPE_TOP) != 0) {
|
||||||
mResizeTaskBounds.top += deltaY;
|
mRepositionTaskBounds.top += deltaY;
|
||||||
}
|
}
|
||||||
if ((mCtrlType & CTRL_TYPE_BOTTOM) != 0) {
|
if ((mCtrlType & CTRL_TYPE_BOTTOM) != 0) {
|
||||||
mResizeTaskBounds.bottom += deltaY;
|
mRepositionTaskBounds.bottom += deltaY;
|
||||||
}
|
}
|
||||||
if (mCtrlType == CTRL_TYPE_UNDEFINED) {
|
if (mCtrlType == CTRL_TYPE_UNDEFINED) {
|
||||||
mResizeTaskBounds.offset((int) deltaX, (int) deltaY);
|
mRepositionTaskBounds.offset((int) deltaX, (int) deltaY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldLeft == mResizeTaskBounds.left && oldTop == mResizeTaskBounds.top
|
if (oldLeft == mRepositionTaskBounds.left && oldTop == mRepositionTaskBounds.top
|
||||||
&& oldRight == mResizeTaskBounds.right && oldBottom == mResizeTaskBounds.bottom) {
|
&& oldRight == mRepositionTaskBounds.right
|
||||||
|
&& oldBottom == mRepositionTaskBounds.bottom) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
wct.setBounds(mWindowDecoration.mTaskInfo.token, mResizeTaskBounds);
|
wct.setBounds(mWindowDecoration.mTaskInfo.token, mRepositionTaskBounds);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,13 +66,13 @@ class TaskPositionerTest : ShellTestCase() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testDragResize_notMove_skipsTransactionOnEnd() {
|
fun testDragResize_notMove_skipsTransactionOnEnd() {
|
||||||
taskPositioner.onDragResizeStart(
|
taskPositioner.onDragPositioningStart(
|
||||||
CTRL_TYPE_TOP or CTRL_TYPE_RIGHT,
|
CTRL_TYPE_TOP or CTRL_TYPE_RIGHT,
|
||||||
STARTING_BOUNDS.left.toFloat(),
|
STARTING_BOUNDS.left.toFloat(),
|
||||||
STARTING_BOUNDS.top.toFloat()
|
STARTING_BOUNDS.top.toFloat()
|
||||||
)
|
)
|
||||||
|
|
||||||
taskPositioner.onDragResizeEnd(
|
taskPositioner.onDragPositioningEnd(
|
||||||
STARTING_BOUNDS.left.toFloat() + 10,
|
STARTING_BOUNDS.left.toFloat() + 10,
|
||||||
STARTING_BOUNDS.top.toFloat() + 10
|
STARTING_BOUNDS.top.toFloat() + 10
|
||||||
)
|
)
|
||||||
@@ -87,18 +87,18 @@ class TaskPositionerTest : ShellTestCase() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testDragResize_noEffectiveMove_skipsTransactionOnMoveAndEnd() {
|
fun testDragResize_noEffectiveMove_skipsTransactionOnMoveAndEnd() {
|
||||||
taskPositioner.onDragResizeStart(
|
taskPositioner.onDragPositioningStart(
|
||||||
CTRL_TYPE_TOP or CTRL_TYPE_RIGHT,
|
CTRL_TYPE_TOP or CTRL_TYPE_RIGHT,
|
||||||
STARTING_BOUNDS.left.toFloat(),
|
STARTING_BOUNDS.left.toFloat(),
|
||||||
STARTING_BOUNDS.top.toFloat()
|
STARTING_BOUNDS.top.toFloat()
|
||||||
)
|
)
|
||||||
|
|
||||||
taskPositioner.onDragResizeMove(
|
taskPositioner.onDragPositioningMove(
|
||||||
STARTING_BOUNDS.left.toFloat(),
|
STARTING_BOUNDS.left.toFloat(),
|
||||||
STARTING_BOUNDS.top.toFloat()
|
STARTING_BOUNDS.top.toFloat()
|
||||||
)
|
)
|
||||||
|
|
||||||
taskPositioner.onDragResizeEnd(
|
taskPositioner.onDragPositioningEnd(
|
||||||
STARTING_BOUNDS.left.toFloat() + 10,
|
STARTING_BOUNDS.left.toFloat() + 10,
|
||||||
STARTING_BOUNDS.top.toFloat() + 10
|
STARTING_BOUNDS.top.toFloat() + 10
|
||||||
)
|
)
|
||||||
@@ -113,13 +113,13 @@ class TaskPositionerTest : ShellTestCase() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testDragResize_hasEffectiveMove_issuesTransactionOnMoveAndEnd() {
|
fun testDragResize_hasEffectiveMove_issuesTransactionOnMoveAndEnd() {
|
||||||
taskPositioner.onDragResizeStart(
|
taskPositioner.onDragPositioningStart(
|
||||||
CTRL_TYPE_TOP or CTRL_TYPE_RIGHT,
|
CTRL_TYPE_TOP or CTRL_TYPE_RIGHT,
|
||||||
STARTING_BOUNDS.left.toFloat(),
|
STARTING_BOUNDS.left.toFloat(),
|
||||||
STARTING_BOUNDS.top.toFloat()
|
STARTING_BOUNDS.top.toFloat()
|
||||||
)
|
)
|
||||||
|
|
||||||
taskPositioner.onDragResizeMove(
|
taskPositioner.onDragPositioningMove(
|
||||||
STARTING_BOUNDS.left.toFloat() + 10,
|
STARTING_BOUNDS.left.toFloat() + 10,
|
||||||
STARTING_BOUNDS.top.toFloat()
|
STARTING_BOUNDS.top.toFloat()
|
||||||
)
|
)
|
||||||
@@ -133,7 +133,7 @@ class TaskPositionerTest : ShellTestCase() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
taskPositioner.onDragResizeEnd(
|
taskPositioner.onDragPositioningEnd(
|
||||||
STARTING_BOUNDS.left.toFloat() + 10,
|
STARTING_BOUNDS.left.toFloat() + 10,
|
||||||
STARTING_BOUNDS.top.toFloat() + 10
|
STARTING_BOUNDS.top.toFloat() + 10
|
||||||
)
|
)
|
||||||
@@ -150,7 +150,7 @@ class TaskPositionerTest : ShellTestCase() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testDragResize_move_skipsDragResizingFlag() {
|
fun testDragResize_move_skipsDragResizingFlag() {
|
||||||
taskPositioner.onDragResizeStart(
|
taskPositioner.onDragPositioningStart(
|
||||||
CTRL_TYPE_UNDEFINED, // Move
|
CTRL_TYPE_UNDEFINED, // Move
|
||||||
STARTING_BOUNDS.left.toFloat(),
|
STARTING_BOUNDS.left.toFloat(),
|
||||||
STARTING_BOUNDS.top.toFloat()
|
STARTING_BOUNDS.top.toFloat()
|
||||||
@@ -159,12 +159,12 @@ class TaskPositionerTest : ShellTestCase() {
|
|||||||
// Move the task 10px to the right.
|
// Move the task 10px to the right.
|
||||||
val newX = STARTING_BOUNDS.left.toFloat() + 10
|
val newX = STARTING_BOUNDS.left.toFloat() + 10
|
||||||
val newY = STARTING_BOUNDS.top.toFloat()
|
val newY = STARTING_BOUNDS.top.toFloat()
|
||||||
taskPositioner.onDragResizeMove(
|
taskPositioner.onDragPositioningMove(
|
||||||
newX,
|
newX,
|
||||||
newY
|
newY
|
||||||
)
|
)
|
||||||
|
|
||||||
taskPositioner.onDragResizeEnd(newX, newY)
|
taskPositioner.onDragPositioningEnd(newX, newY)
|
||||||
|
|
||||||
verify(mockShellTaskOrganizer, never()).applyTransaction(argThat { wct ->
|
verify(mockShellTaskOrganizer, never()).applyTransaction(argThat { wct ->
|
||||||
return@argThat wct.changes.any { (token, change) ->
|
return@argThat wct.changes.any { (token, change) ->
|
||||||
@@ -177,7 +177,7 @@ class TaskPositionerTest : ShellTestCase() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testDragResize_resize_setsDragResizingFlag() {
|
fun testDragResize_resize_setsDragResizingFlag() {
|
||||||
taskPositioner.onDragResizeStart(
|
taskPositioner.onDragPositioningStart(
|
||||||
CTRL_TYPE_RIGHT, // Resize right
|
CTRL_TYPE_RIGHT, // Resize right
|
||||||
STARTING_BOUNDS.left.toFloat(),
|
STARTING_BOUNDS.left.toFloat(),
|
||||||
STARTING_BOUNDS.top.toFloat()
|
STARTING_BOUNDS.top.toFloat()
|
||||||
@@ -186,12 +186,12 @@ class TaskPositionerTest : ShellTestCase() {
|
|||||||
// Resize the task by 10px to the right.
|
// Resize the task by 10px to the right.
|
||||||
val newX = STARTING_BOUNDS.right.toFloat() + 10
|
val newX = STARTING_BOUNDS.right.toFloat() + 10
|
||||||
val newY = STARTING_BOUNDS.top.toFloat()
|
val newY = STARTING_BOUNDS.top.toFloat()
|
||||||
taskPositioner.onDragResizeMove(
|
taskPositioner.onDragPositioningMove(
|
||||||
newX,
|
newX,
|
||||||
newY
|
newY
|
||||||
)
|
)
|
||||||
|
|
||||||
taskPositioner.onDragResizeEnd(newX, newY)
|
taskPositioner.onDragPositioningEnd(newX, newY)
|
||||||
|
|
||||||
verify(mockShellTaskOrganizer).applyTransaction(argThat { wct ->
|
verify(mockShellTaskOrganizer).applyTransaction(argThat { wct ->
|
||||||
return@argThat wct.changes.any { (token, change) ->
|
return@argThat wct.changes.any { (token, change) ->
|
||||||
|
|||||||
Reference in New Issue
Block a user