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

Commit 990d8713 authored by Prabir Pradhan's avatar Prabir Pradhan
Browse files

PointerChoreographer: Remove ability to create mouse controllers OTF

In the following CL, we made a change that results in the mouse cursor
position being valid whenever there is a mouse or touchpad connected:
I55898a3de1beb0f83f5da199521f26a886fb596c

This means we are no longer depending on creating mouse controllers
on-the-fly based on the input events. Remove the logic that creates
mouse controllers on-the-fly.

Bug: 327717240
Test: atest inputflinger_tests
Change-Id: I0fa10ef48055d80136083a1c0ab23522f6683fdc
parent eaa9fde9
Loading
Loading
Loading
Loading
+7 −11
Original line number Diff line number Diff line
@@ -104,7 +104,7 @@ NotifyMotionArgs PointerChoreographer::processMouseEventLocked(const NotifyMotio
                   << args.dump();
    }

    auto [displayId, pc] = getDisplayIdAndMouseControllerLocked(args.displayId);
    auto [displayId, pc] = ensureMouseControllerLocked(args.displayId);

    const float deltaX = args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X);
    const float deltaY = args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y);
@@ -124,7 +124,7 @@ NotifyMotionArgs PointerChoreographer::processMouseEventLocked(const NotifyMotio
}

NotifyMotionArgs PointerChoreographer::processTouchpadEventLocked(const NotifyMotionArgs& args) {
    auto [displayId, pc] = getDisplayIdAndMouseControllerLocked(args.displayId);
    auto [displayId, pc] = ensureMouseControllerLocked(args.displayId);

    NotifyMotionArgs newArgs(args);
    newArgs.displayId = displayId;
@@ -308,17 +308,13 @@ int32_t PointerChoreographer::getTargetMouseDisplayLocked(int32_t associatedDisp
    return associatedDisplayId == ADISPLAY_ID_NONE ? mDefaultMouseDisplayId : associatedDisplayId;
}

std::pair<int32_t, PointerControllerInterface&>
PointerChoreographer::getDisplayIdAndMouseControllerLocked(int32_t associatedDisplayId) {
std::pair<int32_t, PointerControllerInterface&> PointerChoreographer::ensureMouseControllerLocked(
        int32_t associatedDisplayId) {
    const int32_t displayId = getTargetMouseDisplayLocked(associatedDisplayId);

    // Get the mouse pointer controller for the display, or create one if it doesn't exist.
    auto [it, emplaced] =
            mMousePointersByDisplay.try_emplace(displayId,
                                                getMouseControllerConstructor(displayId));
    if (emplaced) {
        notifyPointerDisplayIdChangedLocked();
    }
    auto it = mMousePointersByDisplay.find(displayId);
    LOG_ALWAYS_FATAL_IF(it == mMousePointersByDisplay.end(),
                        "There is no mouse controller created for display %d", displayId);

    return {displayId, *it->second};
}
+1 −1
Original line number Diff line number Diff line
@@ -113,7 +113,7 @@ private:
    void notifyPointerDisplayIdChangedLocked() REQUIRES(mLock);
    const DisplayViewport* findViewportByIdLocked(int32_t displayId) const REQUIRES(mLock);
    int32_t getTargetMouseDisplayLocked(int32_t associatedDisplayId) const REQUIRES(mLock);
    std::pair<int32_t, PointerControllerInterface&> getDisplayIdAndMouseControllerLocked(
    std::pair<int32_t /*displayId*/, PointerControllerInterface&> ensureMouseControllerLocked(
            int32_t associatedDisplayId) REQUIRES(mLock);
    InputDeviceInfo* findInputDeviceLocked(DeviceId deviceId) REQUIRES(mLock);
    bool canUnfadeOnDisplay(int32_t displayId) REQUIRES(mLock);