diff options
| author | 2024-03-05 00:31:36 +0000 | |
|---|---|---|
| committer | 2024-03-06 19:39:29 +0000 | |
| commit | 990d8713a9913136dba9eb57f3b351edaa00be26 (patch) | |
| tree | c84d1fed252448fb0f50ef438d031b779161d772 | |
| parent | eaa9fde906b02a87155f54963eb659b6a70830ae (diff) | |
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
| -rw-r--r-- | services/inputflinger/PointerChoreographer.cpp | 18 | ||||
| -rw-r--r-- | services/inputflinger/PointerChoreographer.h | 2 |
2 files changed, 8 insertions, 12 deletions
diff --git a/services/inputflinger/PointerChoreographer.cpp b/services/inputflinger/PointerChoreographer.cpp index 3ac4285304..3e7c1c71ef 100644 --- a/services/inputflinger/PointerChoreographer.cpp +++ b/services/inputflinger/PointerChoreographer.cpp @@ -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}; } diff --git a/services/inputflinger/PointerChoreographer.h b/services/inputflinger/PointerChoreographer.h index 6aab3aade0..f46038ef73 100644 --- a/services/inputflinger/PointerChoreographer.h +++ b/services/inputflinger/PointerChoreographer.h @@ -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); |