Reset mouse pointer to default when moving away from the window edge
Bug: 28476151 Change-Id: I15bd2408fb3b7fc58fc9936318c0ec9eda504c22
This commit is contained in:
@@ -18,16 +18,14 @@ package com.android.server.wm;
|
||||
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Region;
|
||||
import android.view.DisplayInfo;
|
||||
import android.hardware.input.InputManager;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.InputDevice;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.WindowManagerPolicy.PointerEventListener;
|
||||
|
||||
import com.android.server.wm.WindowManagerService.H;
|
||||
|
||||
import static android.view.PointerIcon.STYLE_NOT_SPECIFIED;
|
||||
import static android.view.PointerIcon.STYLE_DEFAULT;
|
||||
import static android.view.PointerIcon.STYLE_HORIZONTAL_DOUBLE_ARROW;
|
||||
import static android.view.PointerIcon.STYLE_VERTICAL_DOUBLE_ARROW;
|
||||
import static android.view.PointerIcon.STYLE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW;
|
||||
@@ -89,44 +87,37 @@ public class TaskTapPointerEventListener implements PointerEventListener {
|
||||
final int x = (int) motionEvent.getX();
|
||||
final int y = (int) motionEvent.getY();
|
||||
final Task task = mDisplayContent.findTaskForControlPoint(x, y);
|
||||
InputDevice inputDevice = motionEvent.getDevice();
|
||||
if (task == null || inputDevice == null) {
|
||||
mPointerIconShape = STYLE_NOT_SPECIFIED;
|
||||
break;
|
||||
int iconShape = STYLE_NOT_SPECIFIED;
|
||||
if (task != null) {
|
||||
task.getDimBounds(mTmpRect);
|
||||
if (!mTmpRect.isEmpty() && !mTmpRect.contains(x, y)) {
|
||||
if (x < mTmpRect.left) {
|
||||
iconShape =
|
||||
(y < mTmpRect.top) ? STYLE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW :
|
||||
(y > mTmpRect.bottom) ? STYLE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW :
|
||||
STYLE_HORIZONTAL_DOUBLE_ARROW;
|
||||
} else if (x > mTmpRect.right) {
|
||||
iconShape =
|
||||
(y < mTmpRect.top) ? STYLE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW :
|
||||
(y > mTmpRect.bottom) ? STYLE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW :
|
||||
STYLE_HORIZONTAL_DOUBLE_ARROW;
|
||||
} else if (y < mTmpRect.top || y > mTmpRect.bottom) {
|
||||
iconShape = STYLE_VERTICAL_DOUBLE_ARROW;
|
||||
}
|
||||
}
|
||||
}
|
||||
task.getDimBounds(mTmpRect);
|
||||
if (!mTmpRect.isEmpty() && !mTmpRect.contains(x, y)) {
|
||||
int iconShape = STYLE_DEFAULT;
|
||||
if (x < mTmpRect.left) {
|
||||
iconShape =
|
||||
(y < mTmpRect.top) ? STYLE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW :
|
||||
(y > mTmpRect.bottom) ? STYLE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW :
|
||||
STYLE_HORIZONTAL_DOUBLE_ARROW;
|
||||
} else if (x > mTmpRect.right) {
|
||||
iconShape =
|
||||
(y < mTmpRect.top) ? STYLE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW :
|
||||
(y > mTmpRect.bottom) ? STYLE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW :
|
||||
STYLE_HORIZONTAL_DOUBLE_ARROW;
|
||||
} else if (y < mTmpRect.top || y > mTmpRect.bottom) {
|
||||
iconShape = STYLE_VERTICAL_DOUBLE_ARROW;
|
||||
if (mPointerIconShape != iconShape) {
|
||||
mPointerIconShape = iconShape;
|
||||
if (mPointerIconShape == STYLE_NOT_SPECIFIED) {
|
||||
// Find the underlying window and ask it restore the pointer icon.
|
||||
mService.mH.obtainMessage(H.RESTORE_POINTER_ICON,
|
||||
x, y, mDisplayContent).sendToTarget();
|
||||
} else {
|
||||
InputManager.getInstance().setPointerIconShape(mPointerIconShape);
|
||||
}
|
||||
if (mPointerIconShape != iconShape) {
|
||||
mPointerIconShape = iconShape;
|
||||
inputDevice.setPointerShape(iconShape);
|
||||
}
|
||||
} else {
|
||||
mPointerIconShape = STYLE_NOT_SPECIFIED;
|
||||
}
|
||||
} break;
|
||||
|
||||
case MotionEvent.ACTION_HOVER_EXIT:
|
||||
mPointerIconShape = STYLE_NOT_SPECIFIED;
|
||||
InputDevice inputDevice = motionEvent.getDevice();
|
||||
if (inputDevice != null) {
|
||||
inputDevice.setPointerShape(STYLE_DEFAULT);
|
||||
}
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_UP:
|
||||
case MotionEvent.ACTION_POINTER_UP: {
|
||||
stopTwoFingerScroll();
|
||||
|
||||
@@ -7891,6 +7891,8 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
|
||||
public static final int NOTIFY_DOCKED_STACK_MINIMIZED_CHANGED = 53;
|
||||
|
||||
public static final int RESTORE_POINTER_ICON = 54;
|
||||
|
||||
/**
|
||||
* Used to denote that an integer field in a message will not be used.
|
||||
*/
|
||||
@@ -8520,6 +8522,12 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
mAmInternal.notifyDockedStackMinimizedChanged(msg.arg1 == 1);
|
||||
}
|
||||
break;
|
||||
case RESTORE_POINTER_ICON: {
|
||||
synchronized (mWindowMap) {
|
||||
restorePointerIconLocked((DisplayContent)msg.obj, msg.arg1, msg.arg2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (DEBUG_WINDOW_TRACE) {
|
||||
Slog.v(TAG_WM, "handleMessage: exit");
|
||||
|
||||
Reference in New Issue
Block a user