diff options
author | Craig Mautner <cmautner@google.com> | 2013-04-29 17:31:48 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-04-29 17:31:48 +0000 |
commit | 34761434a0957dde28d6156afb48372934581c16 (patch) | |
tree | 5e9206dff13ce4dc80af2497142c93ad90183b12 /services | |
parent | 8929bae78135bacbff36e0f25bb33ba274b2dcc5 (diff) | |
parent | 6601b7bdeb46756fd83ad4c1966ef966c52b46e4 (diff) | |
download | frameworks_base-34761434a0957dde28d6156afb48372934581c16.zip frameworks_base-34761434a0957dde28d6156afb48372934581c16.tar.gz frameworks_base-34761434a0957dde28d6156afb48372934581c16.tar.bz2 |
Merge "Exclude regions from the tap detector."
Diffstat (limited to 'services')
3 files changed, 33 insertions, 12 deletions
diff --git a/services/java/com/android/server/wm/DisplayContent.java b/services/java/com/android/server/wm/DisplayContent.java index 45f018d..dd675db 100644 --- a/services/java/com/android/server/wm/DisplayContent.java +++ b/services/java/com/android/server/wm/DisplayContent.java @@ -22,6 +22,7 @@ import static com.android.server.wm.WindowManagerService.DEBUG_VISIBILITY; import static com.android.server.wm.WindowManagerService.TAG; import android.graphics.Rect; +import android.graphics.Region; import android.util.Slog; import android.util.SparseArray; import android.view.Display; @@ -70,6 +71,8 @@ class DisplayContent { private final DisplayInfo mDisplayInfo = new DisplayInfo(); private final Display mDisplay; + Rect mBaseDisplayRect = new Rect(); + // Accessed directly by all users. boolean layoutNeeded; int pendingLayoutChanges; @@ -94,9 +97,6 @@ class DisplayContent { /** True when the home StackBox is at the top of mStackBoxes, false otherwise. */ private TaskStack mHomeStack = null; - /** Save allocating when retrieving tasks */ - ArrayList<Task> mTmpTasks = new ArrayList<Task>(); - /** Sorted most recent at top, oldest at [0]. */ ArrayList<TaskStack> mStackHistory = new ArrayList<TaskStack>(); @@ -106,8 +106,17 @@ class DisplayContent { /** Detect user tapping outside of current focused stack bounds .*/ StackTapDetector mTapDetector; + /** Detect user tapping outside of current focused stack bounds .*/ + Region mTouchExcludeRegion = new Region(); + SparseArray<UserStacks> mUserStacks = new SparseArray<UserStacks>(); + /** Save allocating when retrieving tasks */ + ArrayList<Task> mTmpTasks = new ArrayList<Task>(); + + /** Save allocating when calculating rects */ + Rect mTmpRect = new Rect(); + /** * @param display May not be null. */ @@ -328,6 +337,20 @@ class DisplayContent { return topBox.stackIdFromPoint(x, y); } + void setTouchExcludeRegion(TaskStack focusedStack) { + mTouchExcludeRegion.set(mBaseDisplayRect); + WindowList windows = getWindowList(); + for (int i = windows.size() - 1; i >= 0; --i) { + final WindowState win = windows.get(i); + final TaskStack stack = win.getStack(); + if (win.isVisibleLw() && stack != null && stack != focusedStack) { + mTmpRect.set(win.mVisibleFrame); + mTmpRect.intersect(win.mVisibleInsets); + mTouchExcludeRegion.op(mTmpRect, Region.Op.DIFFERENCE); + } + } + } + void switchUserStacks(int oldUserId, int newUserId) { final WindowList windows = getWindowList(); for (int i = 0; i < windows.size(); i++) { diff --git a/services/java/com/android/server/wm/StackTapDetector.java b/services/java/com/android/server/wm/StackTapDetector.java index a6e8ece8..a71b075 100644 --- a/services/java/com/android/server/wm/StackTapDetector.java +++ b/services/java/com/android/server/wm/StackTapDetector.java @@ -17,6 +17,7 @@ package com.android.server.wm; import android.graphics.Rect; +import android.graphics.Region; import android.os.Looper; import android.view.DisplayInfo; import android.view.InputChannel; @@ -35,7 +36,7 @@ public class StackTapDetector extends InputEventReceiver { private float mDownX; private float mDownY; private int mPointerId; - private Rect mStackBounds = new Rect(); + final private Region mTouchExcludeRegion; private final WindowManagerService mService; private final DisplayContent mDisplayContent; @@ -44,6 +45,7 @@ public class StackTapDetector extends InputEventReceiver { super(inputChannel, looper); mService = service; mDisplayContent = displayContent; + mTouchExcludeRegion = displayContent.mTouchExcludeRegion; DisplayInfo info = displayContent.getDisplayInfo(); mMotionSlop = (int)(info.logicalDensityDpi * TAP_MOTION_SLOP_INCHES); } @@ -84,7 +86,7 @@ public class StackTapDetector extends InputEventReceiver { if ((motionEvent.getEventTime() - motionEvent.getDownTime()) < TAP_TIMEOUT_MSEC && (x - mDownX) < mMotionSlop && (y - mDownY) < mMotionSlop - && !mStackBounds.contains(x, y)) { + && !mTouchExcludeRegion.contains(x, y)) { mService.mH.obtainMessage(H.TAP_OUTSIDE_STACK, x, y, mDisplayContent) .sendToTarget(); } @@ -95,10 +97,4 @@ public class StackTapDetector extends InputEventReceiver { } } } - - void setStackBounds(Rect bounds) { - synchronized (this) { - mStackBounds.set(bounds); - } - } } diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java index 6878ede..6a2d3e2 100644 --- a/services/java/com/android/server/wm/WindowManagerService.java +++ b/services/java/com/android/server/wm/WindowManagerService.java @@ -3715,7 +3715,7 @@ public class WindowManagerService extends IWindowManager.Stub if (mFocusedApp != null) { Task task = mTaskIdToTask.get(mFocusedApp.groupId); stack = task.mStack; - task.getDisplayContent().mTapDetector.setStackBounds(stack.mStackBox.mBounds); + task.getDisplayContent().setTouchExcludeRegion(stack); } else { stack = null; } @@ -6895,6 +6895,8 @@ public class WindowManagerService extends IWindowManager.Stub displayContent.mBaseDisplayWidth = displayContent.mInitialDisplayWidth; displayContent.mBaseDisplayHeight = displayContent.mInitialDisplayHeight; displayContent.mBaseDisplayDensity = displayContent.mInitialDisplayDensity; + displayContent.mBaseDisplayRect.set(0, 0, + displayContent.mBaseDisplayWidth, displayContent.mBaseDisplayHeight); } } } |