Merge "Reset mouse pointer to default when moving away from the window edge"

This commit is contained in:
TreeHugger Robot
2016-05-05 00:34:29 +00:00
committed by Android (Google) Code Review
2 changed files with 35 additions and 36 deletions

View File

@@ -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();

View File

@@ -7895,6 +7895,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.
*/
@@ -8524,6 +8526,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");