Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 34761434 authored by Craig Mautner's avatar Craig Mautner Committed by Android (Google) Code Review
Browse files

Merge "Exclude regions from the tap detector."

parents 8929bae7 6601b7bd
Loading
Loading
Loading
Loading
+26 −3
Original line number Diff line number Diff line
@@ -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++) {
+4 −8
Original line number Diff line number Diff line
@@ -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);
        }
    }
}
+3 −1
Original line number Diff line number Diff line
@@ -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);
                }
            }
        }