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

Commit 5ed77076 authored by Arpit Singh's avatar Arpit Singh Committed by Automerger Merge Worker
Browse files

Merge changes from topic "typing-tapping-cursor" into udc-qpr-dev am: 027baa7a

parents 4f58e446 027baa7a
Loading
Loading
Loading
Loading
+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
+13 −7
Original line number Diff line number Diff line
@@ -242,7 +242,7 @@ std::list<NotifyArgs> KeyboardInputMapper::processKey(nsecs_t when, nsecs_t read
            keyDown.downTime = when;
            mKeyDowns.push_back(keyDown);
        }
        tryHideCursorOnKeyDown();
        onKeyDownProcessed();
    } else {
        // Remove key down.
        if (keyDownIndex) {
@@ -420,12 +420,18 @@ std::list<NotifyArgs> KeyboardInputMapper::cancelAllDownKeys(nsecs_t when) {
    return out;
}

void KeyboardInputMapper::tryHideCursorOnKeyDown() {
    // Hide the cursor while user is inputting text, ignoring meta keys or multiple simultaneous
    // down keys as they are likely to be shortcuts
    const bool shouldHideCursor = mKeyDowns.size() == 1 && !isMetaKey(mKeyDowns[0].keyCode);
    if (shouldHideCursor && getContext()->getPolicy()->isInputMethodConnectionActive()) {
        getContext()->fadePointer();
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);
    }
}

+1 −1
Original line number Diff line number Diff line
@@ -104,7 +104,7 @@ private:
    void updateLedStateForModifier(LedState& ledState, int32_t led, int32_t modifier, bool reset);
    std::optional<DisplayViewport> findViewport(const InputReaderConfiguration& readerConfig);
    [[nodiscard]] std::list<NotifyArgs> cancelAllDownKeys(nsecs_t when);
    void tryHideCursorOnKeyDown();
    void onKeyDownProcessed();
};

} // namespace android
Loading