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

Commit 4f58e446 authored by Arpit Singh's avatar Arpit Singh Committed by Automerger Merge Worker
Browse files

Hide pointer while typing on a physical keyboard am: b3b3f73f

parents 87bd09d1 b3b3f73f
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
@@ -242,6 +242,7 @@ std::list<NotifyArgs> KeyboardInputMapper::processKey(nsecs_t when, nsecs_t read
            keyDown.downTime = when;
            mKeyDowns.push_back(keyDown);
        }
        tryHideCursorOnKeyDown();
    } else {
        // Remove key down.
        if (keyDownIndex) {
@@ -419,4 +420,13 @@ 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();
    }
}

} // namespace android
+1 −0
Original line number Diff line number Diff line
@@ -104,6 +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();
};

} // namespace android
+1 −0
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ cc_test {
        "SyncQueue_test.cpp",
        "TestInputListener.cpp",
        "TouchpadInputMapper_test.cpp",
        "KeyboardInputMapper_test.cpp",
        "UinputDevice.cpp",
        "UnwantedInteractionBlocker_test.cpp",
    ],
+8 −0
Original line number Diff line number Diff line
@@ -209,6 +209,14 @@ void FakeInputReaderPolicy::setStylusPointerIconEnabled(bool enabled) {
    mConfig.stylusPointerIconEnabled = enabled;
}

void FakeInputReaderPolicy::setIsInputMethodConnectionActive(bool active) {
    mIsInputMethodConnectionActive = active;
}

bool FakeInputReaderPolicy::isInputMethodConnectionActive() {
    return mIsInputMethodConnectionActive;
}

void FakeInputReaderPolicy::getReaderConfiguration(InputReaderConfiguration* outConfig) {
    *outConfig = mConfig;
}
Loading