diff options
| -rw-r--r-- | services/core/java/com/android/server/wm/TaskTapPointerEventListener.java | 46 | ||||
| -rw-r--r-- | services/core/java/com/android/server/wm/WindowManagerService.java | 58 |
2 files changed, 29 insertions, 75 deletions
diff --git a/services/core/java/com/android/server/wm/TaskTapPointerEventListener.java b/services/core/java/com/android/server/wm/TaskTapPointerEventListener.java index 98033f637562..3dc512f44224 100644 --- a/services/core/java/com/android/server/wm/TaskTapPointerEventListener.java +++ b/services/core/java/com/android/server/wm/TaskTapPointerEventListener.java @@ -34,13 +34,7 @@ import static android.view.PointerIcon.STYLE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW; import static android.view.PointerIcon.STYLE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW; public class TaskTapPointerEventListener implements PointerEventListener { - private static final int TAP_TIMEOUT_MSEC = 300; - private static final float TAP_MOTION_SLOP_INCHES = 0.125f; - private final int mMotionSlop; - private float mDownX; - private float mDownY; - private int mPointerId; final private Region mTouchExcludeRegion = new Region(); private final WindowManagerService mService; private final DisplayContent mDisplayContent; @@ -55,8 +49,6 @@ public class TaskTapPointerEventListener implements PointerEventListener { DisplayContent displayContent) { mService = service; mDisplayContent = displayContent; - DisplayInfo info = displayContent.getDisplayInfo(); - mMotionSlop = (int)(info.logicalDensityDpi * TAP_MOTION_SLOP_INCHES); } // initialize the object, note this must be done outside WindowManagerService @@ -74,31 +66,19 @@ public class TaskTapPointerEventListener implements PointerEventListener { final int action = motionEvent.getAction(); switch (action & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: { - mPointerId = motionEvent.getPointerId(0); - mDownX = motionEvent.getX(); - mDownY = motionEvent.getY(); + final int x = (int) motionEvent.getX(); + final int y = (int) motionEvent.getY(); - final int x = (int) mDownX; - final int y = (int) mDownY; synchronized (this) { if (!mTouchExcludeRegion.contains(x, y)) { - mService.mH.obtainMessage(H.TAP_DOWN_OUTSIDE_TASK, x, y, - mDisplayContent).sendToTarget(); + mService.mH.obtainMessage(H.TAP_OUTSIDE_TASK, + x, y, mDisplayContent).sendToTarget(); } } break; } case MotionEvent.ACTION_MOVE: { - if (mPointerId >= 0) { - int index = motionEvent.findPointerIndex(mPointerId); - if ((motionEvent.getEventTime() - motionEvent.getDownTime()) > TAP_TIMEOUT_MSEC - || index < 0 - || Math.abs(motionEvent.getX(index) - mDownX) > mMotionSlop - || Math.abs(motionEvent.getY(index) - mDownY) > mMotionSlop) { - mPointerId = -1; - } - } if (motionEvent.getPointerCount() != 2) { stopTwoFingerScroll(); } @@ -149,24 +129,6 @@ public class TaskTapPointerEventListener implements PointerEventListener { case MotionEvent.ACTION_UP: case MotionEvent.ACTION_POINTER_UP: { - int index = (action & MotionEvent.ACTION_POINTER_INDEX_MASK) - >> MotionEvent.ACTION_POINTER_INDEX_SHIFT; - // Extract the index of the pointer that left the touch sensor - if (mPointerId == motionEvent.getPointerId(index)) { - final int x = (int)motionEvent.getX(index); - final int y = (int)motionEvent.getY(index); - synchronized(this) { - if ((motionEvent.getEventTime() - motionEvent.getDownTime()) - < TAP_TIMEOUT_MSEC - && Math.abs(x - mDownX) < mMotionSlop - && Math.abs(y - mDownY) < mMotionSlop - && !mTouchExcludeRegion.contains(x, y)) { - mService.mH.obtainMessage(H.TAP_OUTSIDE_TASK, x, y, - mDisplayContent).sendToTarget(); - } - } - mPointerId = -1; - } stopTwoFingerScroll(); break; } diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 2477acd15cd9..f858abe9b031 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -7163,18 +7163,25 @@ public class WindowManagerService extends IWindowManager.Stub } catch(RemoteException e) {} } - private void startResizingTask(DisplayContent displayContent, int startX, int startY) { - Task task = null; + private void handleTapOutsideTask(DisplayContent displayContent, int x, int y) { + int taskId = -1; synchronized (mWindowMap) { - task = displayContent.findTaskForControlPoint(startX, startY); - if (task == null || !startPositioningLocked( - task.getTopVisibleAppMainWindow(), true /*resize*/, startX, startY)) { - return; + final Task task = displayContent.findTaskForControlPoint(x, y); + if (task != null) { + if (!startPositioningLocked( + task.getTopVisibleAppMainWindow(), true /*resize*/, x, y)) { + return; + } + taskId = task.mTaskId; + } else { + taskId = displayContent.taskIdFromPoint(x, y); } } - try { - mActivityManager.setFocusedTask(task.mTaskId); - } catch(RemoteException e) {} + if (taskId >= 0) { + try { + mActivityManager.setFocusedTask(taskId); + } catch(RemoteException e) {} + } } private boolean startPositioningLocked( @@ -7489,18 +7496,17 @@ public class WindowManagerService extends IWindowManager.Stub public static final int RESET_ANR_MESSAGE = 38; public static final int WALLPAPER_DRAW_PENDING_TIMEOUT = 39; - public static final int TAP_DOWN_OUTSIDE_TASK = 40; - public static final int FINISH_TASK_POSITIONING = 41; + public static final int FINISH_TASK_POSITIONING = 40; - public static final int UPDATE_DOCKED_STACK_DIVIDER = 42; + public static final int UPDATE_DOCKED_STACK_DIVIDER = 41; - public static final int RESIZE_STACK = 43; - public static final int RESIZE_TASK = 44; + public static final int RESIZE_STACK = 42; + public static final int RESIZE_TASK = 43; - public static final int TWO_FINGER_SCROLL_START = 45; - public static final int SHOW_NON_RESIZEABLE_DOCK_TOAST = 46; + public static final int TWO_FINGER_SCROLL_START = 44; + public static final int SHOW_NON_RESIZEABLE_DOCK_TOAST = 45; - public static final int WINDOW_REPLACEMENT_TIMEOUT = 47; + public static final int WINDOW_REPLACEMENT_TIMEOUT = 46; /** * Used to denote that an integer field in a message will not be used. @@ -7954,27 +7960,13 @@ public class WindowManagerService extends IWindowManager.Stub } break; - case TAP_OUTSIDE_TASK: { - int taskId; - synchronized (mWindowMap) { - taskId = ((DisplayContent)msg.obj).taskIdFromPoint(msg.arg1, msg.arg2); - } - if (taskId >= 0) { - try { - mActivityManager.setFocusedTask(taskId); - } catch (RemoteException e) { - } - } - } - break; - case TWO_FINGER_SCROLL_START: { startScrollingTask((DisplayContent)msg.obj, msg.arg1, msg.arg2); } break; - case TAP_DOWN_OUTSIDE_TASK: { - startResizingTask((DisplayContent)msg.obj, msg.arg1, msg.arg2); + case TAP_OUTSIDE_TASK: { + handleTapOutsideTask((DisplayContent)msg.obj, msg.arg1, msg.arg2); } break; |