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

Commit 027baa7a authored by Arpit Singh's avatar Arpit Singh Committed by Android (Google) Code Review
Browse files

Merge changes from topic "typing-tapping-cursor" into udc-qpr-dev

* changes:
  Disable Tap to click while typing on a PK
  Hide pointer while typing on a physical keyboard
parents 28bb2a11 a5ea7c17
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -447,6 +447,9 @@ public:
            const std::string& inputDeviceDescriptor, ui::Rotation surfaceRotation) = 0;
    /* Notifies the input reader policy that a stylus gesture has started. */
    virtual void notifyStylusGestureStarted(int32_t deviceId, nsecs_t eventTime) = 0;

    /* Returns true if any InputConnection is currently active. */
    virtual bool isInputMethodConnectionActive() = 0;
};

} // namespace android
+10 −0
Original line number Diff line number Diff line
@@ -1040,6 +1040,16 @@ int32_t InputReader::ContextImpl::getLedMetaState() {
    return mReader->getLedMetaStateLocked();
}

void InputReader::ContextImpl::setPreventingTouchpadTaps(bool prevent) {
    // lock is already held by the input loop
    mReader->mPreventingTouchpadTaps = prevent;
}

bool InputReader::ContextImpl::isPreventingTouchpadTaps() {
    // lock is already held by the input loop
    return mReader->mPreventingTouchpadTaps;
}

void InputReader::ContextImpl::disableVirtualKeysUntil(nsecs_t time) {
    // lock is already held by the input loop
    mReader->disableVirtualKeysUntilLocked(time);
+6 −0
Original line number Diff line number Diff line
@@ -155,6 +155,9 @@ protected:
        int32_t getNextId() NO_THREAD_SAFETY_ANALYSIS override;
        void updateLedMetaState(int32_t metaState) REQUIRES(mReader->mLock) override;
        int32_t getLedMetaState() REQUIRES(mReader->mLock) REQUIRES(mLock) override;
        void setPreventingTouchpadTaps(bool prevent) REQUIRES(mReader->mLock)
                REQUIRES(mLock) override;
        bool isPreventingTouchpadTaps() REQUIRES(mReader->mLock) REQUIRES(mLock) override;
    } mContext;

    friend class ContextImpl;
@@ -185,6 +188,9 @@ private:
    std::unordered_map<std::shared_ptr<InputDevice>, std::vector<int32_t> /*eventHubId*/>
            mDeviceToEventHubIdsMap GUARDED_BY(mLock);

    // true if tap-to-click on touchpad currently disabled
    bool mPreventingTouchpadTaps GUARDED_BY(mLock){false};

    // low-level input event decoding and device management
    [[nodiscard]] std::list<NotifyArgs> processEventsLocked(const RawEvent* rawEvents, size_t count)
            REQUIRES(mLock);
+3 −0
Original line number Diff line number Diff line
@@ -62,6 +62,9 @@ public:

    virtual void updateLedMetaState(int32_t metaState) = 0;
    virtual int32_t getLedMetaState() = 0;

    virtual void setPreventingTouchpadTaps(bool prevent) = 0;
    virtual bool isPreventingTouchpadTaps() = 0;
};

} // namespace android
+16 −0
Original line number Diff line number Diff line
@@ -242,6 +242,7 @@ std::list<NotifyArgs> KeyboardInputMapper::processKey(nsecs_t when, nsecs_t read
            keyDown.downTime = when;
            mKeyDowns.push_back(keyDown);
        }
        onKeyDownProcessed();
    } else {
        // Remove key down.
        if (keyDownIndex) {
@@ -419,4 +420,19 @@ std::list<NotifyArgs> KeyboardInputMapper::cancelAllDownKeys(nsecs_t when) {
    return out;
}

void KeyboardInputMapper::onKeyDownProcessed() {
    InputReaderContext& context = *getContext();
    if (context.isPreventingTouchpadTaps()) {
        // avoid pinging java service unnecessarily
        return;
    }
    // Ignore meta keys or multiple simultaneous down keys as they are likely to be keyboard
    // shortcuts
    bool shouldHideCursor = mKeyDowns.size() == 1 && !isMetaKey(mKeyDowns[0].keyCode);
    if (shouldHideCursor && context.getPolicy()->isInputMethodConnectionActive()) {
        context.fadePointer();
        context.setPreventingTouchpadTaps(true);
    }
}

} // namespace android
Loading