Loading services/inputflinger/PointerChoreographer.cpp +18 −4 Original line number Diff line number Diff line Loading @@ -327,14 +327,23 @@ void PointerChoreographer::updatePointerControllersLocked() { std::set<DeviceId> touchDevicesToKeep; std::set<DeviceId> stylusDevicesToKeep; // Mark the displayIds or deviceIds of PointerControllers currently needed. // Mark the displayIds or deviceIds of PointerControllers currently needed, and create // new PointerControllers if necessary. for (const auto& info : mInputDeviceInfos) { const uint32_t sources = info.getSources(); if (isFromSource(sources, AINPUT_SOURCE_MOUSE) || isFromSource(sources, AINPUT_SOURCE_MOUSE_RELATIVE)) { const int32_t resolvedDisplayId = getTargetMouseDisplayLocked(info.getAssociatedDisplayId()); mouseDisplaysToKeep.insert(resolvedDisplayId); const int32_t displayId = getTargetMouseDisplayLocked(info.getAssociatedDisplayId()); mouseDisplaysToKeep.insert(displayId); // For mice, show the cursor immediately when the device is first connected or // when it moves to a new display. auto [mousePointerIt, isNewMousePointer] = mMousePointersByDisplay.try_emplace(displayId, getMouseControllerConstructor(displayId)); auto [_, isNewMouseDevice] = mMouseDevices.emplace(info.getId()); if (isNewMouseDevice || isNewMousePointer) { mousePointerIt->second->unfade(PointerControllerInterface::Transition::IMMEDIATE); } } if (isFromSource(sources, AINPUT_SOURCE_TOUCHSCREEN) && mShowTouchesEnabled && info.getAssociatedDisplayId() != ADISPLAY_ID_NONE) { Loading @@ -356,6 +365,11 @@ void PointerChoreographer::updatePointerControllersLocked() { std::erase_if(mStylusPointersByDevice, [&stylusDevicesToKeep](const auto& pair) { return stylusDevicesToKeep.find(pair.first) == stylusDevicesToKeep.end(); }); std::erase_if(mMouseDevices, [&](DeviceId id) REQUIRES(mLock) { return std::find_if(mInputDeviceInfos.begin(), mInputDeviceInfos.end(), [id](const auto& info) { return info.getId() == id; }) == mInputDeviceInfos.end(); }); // Notify the policy if there's a change on the pointer display ID. notifyPointerDisplayIdChangedLocked(); Loading services/inputflinger/PointerChoreographer.h +1 −0 Original line number Diff line number Diff line Loading @@ -139,6 +139,7 @@ private: int32_t mDefaultMouseDisplayId GUARDED_BY(mLock); int32_t mNotifiedPointerDisplayId GUARDED_BY(mLock); std::vector<InputDeviceInfo> mInputDeviceInfos GUARDED_BY(mLock); std::set<DeviceId> mMouseDevices GUARDED_BY(mLock); std::vector<DisplayViewport> mViewports GUARDED_BY(mLock); bool mShowTouchesEnabled GUARDED_BY(mLock); bool mStylusPointerIconEnabled GUARDED_BY(mLock); Loading services/inputflinger/tests/FakePointerController.h +1 −1 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ public: void setDisplayViewport(const DisplayViewport& viewport) override; void updatePointerIcon(PointerIconStyle iconId) override; void setCustomPointerIcon(const SpriteIcon& icon) override; void fade(Transition) override; void assertViewportSet(int32_t displayId); void assertViewportNotSet(); Loading @@ -56,7 +57,6 @@ private: std::string dump() override { return ""; } std::optional<FloatRect> getBounds() const override; void move(float deltaX, float deltaY) override; void fade(Transition) override; void unfade(Transition) override; void setPresentation(Presentation) override {} void setSpots(const PointerCoords*, const uint32_t*, BitSet32 spotIdBits, Loading services/inputflinger/tests/PointerChoreographer_test.cpp +91 −333 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
services/inputflinger/PointerChoreographer.cpp +18 −4 Original line number Diff line number Diff line Loading @@ -327,14 +327,23 @@ void PointerChoreographer::updatePointerControllersLocked() { std::set<DeviceId> touchDevicesToKeep; std::set<DeviceId> stylusDevicesToKeep; // Mark the displayIds or deviceIds of PointerControllers currently needed. // Mark the displayIds or deviceIds of PointerControllers currently needed, and create // new PointerControllers if necessary. for (const auto& info : mInputDeviceInfos) { const uint32_t sources = info.getSources(); if (isFromSource(sources, AINPUT_SOURCE_MOUSE) || isFromSource(sources, AINPUT_SOURCE_MOUSE_RELATIVE)) { const int32_t resolvedDisplayId = getTargetMouseDisplayLocked(info.getAssociatedDisplayId()); mouseDisplaysToKeep.insert(resolvedDisplayId); const int32_t displayId = getTargetMouseDisplayLocked(info.getAssociatedDisplayId()); mouseDisplaysToKeep.insert(displayId); // For mice, show the cursor immediately when the device is first connected or // when it moves to a new display. auto [mousePointerIt, isNewMousePointer] = mMousePointersByDisplay.try_emplace(displayId, getMouseControllerConstructor(displayId)); auto [_, isNewMouseDevice] = mMouseDevices.emplace(info.getId()); if (isNewMouseDevice || isNewMousePointer) { mousePointerIt->second->unfade(PointerControllerInterface::Transition::IMMEDIATE); } } if (isFromSource(sources, AINPUT_SOURCE_TOUCHSCREEN) && mShowTouchesEnabled && info.getAssociatedDisplayId() != ADISPLAY_ID_NONE) { Loading @@ -356,6 +365,11 @@ void PointerChoreographer::updatePointerControllersLocked() { std::erase_if(mStylusPointersByDevice, [&stylusDevicesToKeep](const auto& pair) { return stylusDevicesToKeep.find(pair.first) == stylusDevicesToKeep.end(); }); std::erase_if(mMouseDevices, [&](DeviceId id) REQUIRES(mLock) { return std::find_if(mInputDeviceInfos.begin(), mInputDeviceInfos.end(), [id](const auto& info) { return info.getId() == id; }) == mInputDeviceInfos.end(); }); // Notify the policy if there's a change on the pointer display ID. notifyPointerDisplayIdChangedLocked(); Loading
services/inputflinger/PointerChoreographer.h +1 −0 Original line number Diff line number Diff line Loading @@ -139,6 +139,7 @@ private: int32_t mDefaultMouseDisplayId GUARDED_BY(mLock); int32_t mNotifiedPointerDisplayId GUARDED_BY(mLock); std::vector<InputDeviceInfo> mInputDeviceInfos GUARDED_BY(mLock); std::set<DeviceId> mMouseDevices GUARDED_BY(mLock); std::vector<DisplayViewport> mViewports GUARDED_BY(mLock); bool mShowTouchesEnabled GUARDED_BY(mLock); bool mStylusPointerIconEnabled GUARDED_BY(mLock); Loading
services/inputflinger/tests/FakePointerController.h +1 −1 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ public: void setDisplayViewport(const DisplayViewport& viewport) override; void updatePointerIcon(PointerIconStyle iconId) override; void setCustomPointerIcon(const SpriteIcon& icon) override; void fade(Transition) override; void assertViewportSet(int32_t displayId); void assertViewportNotSet(); Loading @@ -56,7 +57,6 @@ private: std::string dump() override { return ""; } std::optional<FloatRect> getBounds() const override; void move(float deltaX, float deltaY) override; void fade(Transition) override; void unfade(Transition) override; void setPresentation(Presentation) override {} void setSpots(const PointerCoords*, const uint32_t*, BitSet32 spotIdBits, Loading
services/inputflinger/tests/PointerChoreographer_test.cpp +91 −333 File changed.Preview size limit exceeded, changes collapsed. Show changes