diff options
| -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); |