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

Commit baa0d179 authored by Lior Barenboim's avatar Lior Barenboim Committed by Gerrit - the friendly Code Review server
Browse files

Ultrasound: Fix touchable region for windows on off-screen display

The ultrasound digital pen uses an external logical display, dedicated
to digital pen off-screen input. Apps using this feature use the
Android Presentation class to put Views on this display.
When calculating the touchable region for windows on this logical
display, Android uses the stack bounds of the activity, which is
placed on the main display. This yields an incorrect touchable
region for Views in the off-screen display, since the main display
and the off-screen display have different resolutions.
This fix sets the touchable region to be the entire window frame
for windows which reside in the digital pen off-screen display.

Change-Id: Ife87fc42b39a4bf75c8cfb194ae876c65e7ff4f9
parent 4ac219a2
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.server.wm;
import com.android.server.input.InputManagerService;
import com.android.server.input.InputApplicationHandle;
import com.android.server.input.InputWindowHandle;
import com.android.server.display.DigitalPenOffScreenDisplayAdapter;

import android.app.ActivityManagerNative;
import android.graphics.Rect;
@@ -177,7 +178,21 @@ 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;

            DisplayContent offScreenDisplayContent =
                mService.getDigitalPenOffScreenDisplayContentLocked();

            if ((!DigitalPenOffScreenDisplayAdapter.isDigitalPenDisabled())
                && (null != offScreenDisplayContent)
                && (child.getDisplayId() == offScreenDisplayContent.getDisplayId())) {
                // If the window is located on the digital pen extended off-screen
                // display, make the touchable region the entire frame. Using
                // getStackBounds() will yield the bounds of the activity which
                // is on the main display - not what we want.
                mTmpRect = child.getFrameLw();
            } else {
                child.getStackBounds(mTmpRect);
            }
            inputWindowHandle.touchableRegion.set(mTmpRect);
        } else {
            // Not modal or full screen modal
+1 −1
Original line number Diff line number Diff line
@@ -7088,7 +7088,7 @@ public class WindowManagerService extends IWindowManager.Stub
        return sw;
    }

    private DisplayContent getDigitalPenOffScreenDisplayContentLocked() {
    public DisplayContent getDigitalPenOffScreenDisplayContentLocked() {
        Display[] displays = mDisplayManager.getDisplays();
        int displayId = -1;
        for (Display display : displays) {