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

Commit f8a2a632 authored by Filip Gruszczynski's avatar Filip Gruszczynski
Browse files

Fix touching outside of popup not dismissing it.

We only included the exact popup window area for intercepting touches
that would dismiss the popup. We need to intercept the parent area, so
we use the task or stack associated with the window to determine which
touch events to intercept and use as dismiss. This doesn't affect which
touch events will be delivered to the window.

Bug: 25329650

Change-Id: Ie248ec67bb5328fd67b470f556cf206ce888514c
parent e978607a
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -99,6 +99,17 @@ public final class InputWindowHandle {
        this.displayId = displayId;
    }

    @Override
    public String toString() {
        return new StringBuilder(name)
                .append(", layer=").append(layer)
                .append(", frame=[").append(frameLeft).append(",").append(frameTop).append(",")
                        .append(frameRight).append(",").append(frameBottom).append("]")
                .append(", touchableRegion=").append(touchableRegion)
                .toString();

    }

    @Override
    protected void finalize() throws Throwable {
        try {
+22 −8
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
package com.android.server.wm;

import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER;
import static com.android.server.wm.WindowManagerService.DEBUG_FOCUS_LIGHT;
import static com.android.server.wm.WindowManagerService.DEBUG_INPUT;
import static com.android.server.wm.WindowState.BOUNDS_FOR_TOUCH;
import android.app.ActivityManagerNative;
import android.graphics.Rect;
@@ -179,7 +181,17 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks {
        if (modal && child.mAppToken != null) {
            // Limit the outer touch to the activity stack region.
            flags |= WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
            // If this is a modal window we need to dismiss it if it's not full screen and the touch
            // happens outside of the frame that displays the content. This means we need to
            // intercept touches outside of that window. The dim layer user associated with the
            // window (task or stack) will give us the good bounds, as they would be used to display
            // the dim layer.
            final DimLayer.DimLayerUser dimLayerUser = child.getDimLayerUser();
            if (dimLayerUser != null) {
                dimLayerUser.getBounds(mTmpRect);
            } else {
                child.getVisibleBounds(mTmpRect, BOUNDS_FOR_TOUCH);
            }
            inputWindowHandle.touchableRegion.set(mTmpRect);
        } else {
            // Not modal or full screen modal
@@ -227,7 +239,9 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks {
            inputWindowHandle.scaleFactor = 1;
        }


        if (DEBUG_INPUT) {
            Slog.d(WindowManagerService.TAG, "addInputWindowHandle: " + inputWindowHandle);
        }
        addInputWindowHandleLw(inputWindowHandle);
    }

@@ -428,7 +442,7 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks {
     * Layer assignment is assumed to be complete by the time this is called.
     */
    public void setInputFocusLw(WindowState newWindow, boolean updateInputWindows) {
        if (WindowManagerService.DEBUG_FOCUS_LIGHT || WindowManagerService.DEBUG_INPUT) {
        if (DEBUG_FOCUS_LIGHT || DEBUG_INPUT) {
            Slog.d(WindowManagerService.TAG, "Input focus has changed to " + newWindow);
        }

@@ -464,7 +478,7 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks {

    public void pauseDispatchingLw(WindowToken window) {
        if (! window.paused) {
            if (WindowManagerService.DEBUG_INPUT) {
            if (DEBUG_INPUT) {
                Slog.v(WindowManagerService.TAG, "Pausing WindowToken " + window);
            }

@@ -475,7 +489,7 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks {

    public void resumeDispatchingLw(WindowToken window) {
        if (window.paused) {
            if (WindowManagerService.DEBUG_INPUT) {
            if (DEBUG_INPUT) {
                Slog.v(WindowManagerService.TAG, "Resuming WindowToken " + window);
            }

@@ -486,7 +500,7 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks {

    public void freezeInputDispatchingLw() {
        if (! mInputDispatchFrozen) {
            if (WindowManagerService.DEBUG_INPUT) {
            if (DEBUG_INPUT) {
                Slog.v(WindowManagerService.TAG, "Freezing input dispatching");
            }

@@ -497,7 +511,7 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks {

    public void thawInputDispatchingLw() {
        if (mInputDispatchFrozen) {
            if (WindowManagerService.DEBUG_INPUT) {
            if (DEBUG_INPUT) {
                Slog.v(WindowManagerService.TAG, "Thawing input dispatching");
            }

@@ -508,7 +522,7 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks {

    public void setEventDispatchingLw(boolean enabled) {
        if (mInputDispatchEnabled != enabled) {
            if (WindowManagerService.DEBUG_INPUT) {
            if (DEBUG_INPUT) {
                Slog.v(WindowManagerService.TAG, "Setting event dispatching to " + enabled);
            }