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

Commit 2210dab5 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "WM: Add a crop to touchable region if needed"

parents f71f015f 93d68c27
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -251,7 +251,7 @@ final class InputMonitor {
            final boolean hasFocus, final boolean hasWallpaper) {
        // Add a window to our list of input windows.
        inputWindowHandle.name = child.toString();
        flags = child.getSurfaceTouchableRegion(inputWindowHandle.touchableRegion, flags);
        flags = child.getSurfaceTouchableRegion(inputWindowHandle, flags);
        inputWindowHandle.layoutParamsFlags = flags;
        inputWindowHandle.layoutParamsType = type;
        inputWindowHandle.dispatchingTimeoutNanos = child.getInputDispatchingTimeoutNanos();
+20 −2
Original line number Diff line number Diff line
@@ -214,7 +214,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
    static final String TAG = TAG_WITH_CLASS_NAME ? "WindowState" : TAG_WM;

    // The minimal size of a window within the usable area of the freeform stack.
    // TODO(multi-window): fix the min sizes when we have mininum width/height support,
    // TODO(multi-window): fix the min sizes when we have minimum width/height support,
    //                     use hard-coded min sizes for now.
    static final int MINIMUM_VISIBLE_WIDTH_IN_DP = 48;
    static final int MINIMUM_VISIBLE_HEIGHT_IN_DP = 32;
@@ -2196,8 +2196,11 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        }
    }

    int getSurfaceTouchableRegion(Region region, int flags) {
    int getSurfaceTouchableRegion(InputWindowHandle inputWindowHandle, int flags) {
        final boolean modal = (flags & (FLAG_NOT_TOUCH_MODAL | FLAG_NOT_FOCUSABLE)) == 0;
        final Region region = inputWindowHandle.touchableRegion;
        setTouchableRegionCropIfNeeded(inputWindowHandle);

        if (mAppToken != null && !mAppToken.getResolvedOverrideBounds().isEmpty()) {
            // There may have touchable letterboxes around the activity, so in order to let the
            // letterboxes are able to receive touch event and slip to activity, the activity with
@@ -2265,6 +2268,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
                region.set(-dw, -dh, dw + dw, dh + dh);
                // Subtract the area that cannot be touched.
                region.op(touchExcludeRegion, Region.Op.DIFFERENCE);
                inputWindowHandle.setTouchableRegionCrop(null);
            }
            touchExcludeRegion.recycle();
        } else {
@@ -2939,6 +2943,20 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        subtractTouchExcludeRegionIfNeeded(outRegion);
    }

    private void setTouchableRegionCropIfNeeded(InputWindowHandle handle) {
        final Task task = getTask();
        if (task == null || !task.cropWindowsToStackBounds()) {
            return;
        }

        final TaskStack stack = task.mStack;
        if (stack == null) {
            return;
        }

        handle.setTouchableRegionCrop(stack.getSurfaceControl());
    }

    private void cropRegionToStackBoundsIfNeeded(Region region) {
        final Task task = getTask();
        if (task == null || !task.cropWindowsToStackBounds()) {