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

Commit 95b38a90 authored by Arthur Hung's avatar Arthur Hung
Browse files

Fix WM input limitations on secondary displays (1/N)

- One DisplayContent include one InputMonitor.
- For customized inputconsumers, they can be handled by DisplayContent.
- Extract InputManagerCallback to communicated InputManagerService.
- All windows need pass displayId to InputWindowHandle.

Bug: 111363643
Test: atest WindowManagerSmokeTest
Test: atest DisplayContentTests
Change-Id: Iaaca7d135a11c55a78bcf1f81918599b3d160106
parent cbb72aab
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -4669,7 +4669,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            } else if (mInputConsumer == null && mStatusBar != null && canHideNavigationBar()) {
                mInputConsumer = mWindowManagerFuncs.createInputConsumer(mHandler.getLooper(),
                        INPUT_CONSUMER_NAVIGATION,
                        (channel, looper) -> new HideNavInputEventReceiver(channel, looper));
                        (channel, looper) -> new HideNavInputEventReceiver(channel, looper),
                        displayFrames.mDisplayId);
                // As long as mInputConsumer is active, hover events are not dispatched to the app
                // and the pointer icon is likely to become stale. Hide it to avoid confusion.
                InputManager.getInstance().setPointerIconType(PointerIcon.TYPE_NULL);
+1 −1
Original line number Diff line number Diff line
@@ -525,7 +525,7 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
         * Add a input consumer which will consume all input events going to any window below it.
         */
        public InputConsumer createInputConsumer(Looper looper, String name,
                InputEventReceiver.Factory inputEventReceiverFactory);
                InputEventReceiver.Factory inputEventReceiverFactory, int displayId);

        /**
         * Returns a code that describes the current state of the lid switch.
+2 −2
Original line number Diff line number Diff line
@@ -648,7 +648,7 @@ public class AppWindowContainerController
    public void pauseKeyDispatching() {
        synchronized (mWindowMap) {
            if (mContainer != null) {
                mService.mInputMonitor.pauseDispatchingLw(mContainer);
                mContainer.getDisplayContent().getInputMonitor().pauseDispatchingLw(mContainer);
            }
        }
    }
@@ -656,7 +656,7 @@ public class AppWindowContainerController
    public void resumeKeyDispatching() {
        synchronized (mWindowMap) {
            if (mContainer != null) {
                mService.mInputMonitor.resumeDispatchingLw(mContainer);
                mContainer.getDisplayContent().getInputMonitor().resumeDispatchingLw(mContainer);
            }
        }
    }
+3 −3
Original line number Diff line number Diff line
@@ -449,13 +449,13 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
                    + ": hidden=" + isHidden() + " hiddenRequested=" + hiddenRequested);

            if (changed) {
                mService.mInputMonitor.setUpdateInputWindowsNeededLw();
                getDisplayContent().getInputMonitor().setUpdateInputWindowsNeededLw();
                if (performLayout) {
                    mService.updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES,
                            false /*updateInputWindows*/);
                    mService.mWindowPlacerLocked.performSurfacePlacement();
                }
                mService.mInputMonitor.updateInputWindowsLw(false /*force*/);
                getDisplayContent().getInputMonitor().updateInputWindowsLw(false /*force*/);
            }
        }

@@ -677,7 +677,7 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
            if (DEBUG_FOCUS_LIGHT) Slog.v(TAG_WM, "Removing focused app token:" + this);
            mService.mFocusedApp = null;
            mService.updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL, true /*updateInputWindows*/);
            mService.mInputMonitor.setFocusedAppLw(null);
            getDisplayContent().getInputMonitor().setFocusedAppLw(null);
        }

        if (!delayed) {
+15 −5
Original line number Diff line number Diff line
@@ -401,6 +401,8 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo

    private MagnificationSpec mMagnificationSpec;

    private InputMonitor mInputMonitor;

    private final Consumer<WindowState> mUpdateWindowsForAnimator = w -> {
        WindowStateAnimator winAnimator = w.mWinAnimator;
        final AppWindowToken atoken = w.mAppToken;
@@ -798,6 +800,8 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        // TODO(b/62541591): evaluate whether this is the best spot to declare the
        // {@link DisplayContent} ready for use.
        mDisplayReady = true;

        mInputMonitor = new InputMonitor(service, mDisplayId);
    }

    boolean isReady() {
@@ -2362,6 +2366,8 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo

        pw.println();
        mDisplayFrames.dump(prefix, pw);
        pw.println();
        mInputMonitor.dump(pw, "  ");
    }

    @Override
@@ -2472,9 +2478,9 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
            assignWindowLayers(false /* setLayoutNeeded */);
        }

        mService.mInputMonitor.setUpdateInputWindowsNeededLw();
        mInputMonitor.setUpdateInputWindowsNeededLw();
        mService.mWindowPlacerLocked.performSurfacePlacement();
        mService.mInputMonitor.updateInputWindowsLw(false /*force*/);
        mInputMonitor.updateInputWindowsLw(false /*force*/);
    }

    /** Returns true if a leaked surface was destroyed */
@@ -3057,10 +3063,10 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        forAllWindows(mPerformLayoutAttached, true /* traverseTopToBottom */);

        // Window frames may have changed. Tell the input dispatcher about it.
        mService.mInputMonitor.layoutInputConsumers(dw, dh);
        mService.mInputMonitor.setUpdateInputWindowsNeededLw();
        mInputMonitor.layoutInputConsumers(dw, dh);
        mInputMonitor.setUpdateInputWindowsNeededLw();
        if (updateInputWindows) {
            mService.mInputMonitor.updateInputWindowsLw(false /*force*/);
            mInputMonitor.updateInputWindowsLw(false /*force*/);
        }

        mService.mH.sendEmptyMessage(UPDATE_DOCKED_STACK_DIVIDER);
@@ -4107,4 +4113,8 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
    private boolean canUpdateImeTarget() {
        return mDeferUpdateImeTargetCount == 0;
    }

    InputMonitor getInputMonitor() {
        return mInputMonitor;
    }
}
Loading