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

Commit f3bc1aa7 authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

Receive touch mode state from WindowManager

Input needs to keep a copy of the touch mode state in order to tell apps
about it. The state will be sent to apps at the same time as the focus
change event.

The code currently does nothing, but the state will be needed in a
future CL.

Bug: 70668286
Test: presubmit
Change-Id: Ifab76977a0380370a753294d5a7504e3cec88af1
parent 240f8313
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -252,6 +252,10 @@ InputDispatcher::InputDispatcher(const sp<InputDispatcherPolicyInterface>& polic
        mDispatchEnabled(false),
        mDispatchFrozen(false),
        mInputFilterEnabled(false),
        // mInTouchMode will be initialized by the WindowManager to the default device config.
        // To avoid leaking stack in case that call never comes, and for tests,
        // initialize it here anyways.
        mInTouchMode(true),
        mFocusedDisplayId(ADISPLAY_ID_DEFAULT),
        mInputTargetWaitCause(INPUT_TARGET_WAIT_CAUSE_NONE) {
    mLooper = new Looper(false);
@@ -3538,6 +3542,11 @@ void InputDispatcher::setInputFilterEnabled(bool enabled) {
    mLooper->wake();
}

void InputDispatcher::setInTouchMode(bool inTouchMode) {
    std::scoped_lock lock(mLock);
    mInTouchMode = inTouchMode;
}

bool InputDispatcher::transferTouchFocus(const sp<IBinder>& fromToken, const sp<IBinder>& toToken) {
    if (fromToken == toToken) {
        if (DEBUG_FOCUS) {
+2 −0
Original line number Diff line number Diff line
@@ -102,6 +102,7 @@ public:
    virtual void setFocusedDisplay(int32_t displayId) override;
    virtual void setInputDispatchMode(bool enabled, bool frozen) override;
    virtual void setInputFilterEnabled(bool enabled) override;
    virtual void setInTouchMode(bool inTouchMode) override;

    virtual bool transferTouchFocus(const sp<IBinder>& fromToken,
                                    const sp<IBinder>& toToken) override;
@@ -247,6 +248,7 @@ private:
    bool mDispatchEnabled GUARDED_BY(mLock);
    bool mDispatchFrozen GUARDED_BY(mLock);
    bool mInputFilterEnabled GUARDED_BY(mLock);
    bool mInTouchMode GUARDED_BY(mLock);

    std::unordered_map<int32_t, std::vector<sp<InputWindowHandle>>> mWindowHandlesByDisplay
            GUARDED_BY(mLock);
+8 −0
Original line number Diff line number Diff line
@@ -116,6 +116,14 @@ public:
     */
    virtual void setInputFilterEnabled(bool enabled) = 0;

    /**
     * Set the touch mode state.
     * Touch mode is a global state that apps may enter / exit based on specific
     * user interactions with input devices.
     * If true, the device is in touch mode.
     */
    virtual void setInTouchMode(bool inTouchMode) = 0;

    /* Transfers touch focus from one window to another window.
     *
     * Returns true on success.  False if the window did not actually have touch focus.