Loading services/inputflinger/PointerChoreographer.cpp +9 −2 Original line number Diff line number Diff line Loading @@ -677,7 +677,13 @@ ui::LogicalDisplayId PointerChoreographer::getTargetMouseDisplayLocked( mTopology.graph.find(associatedDisplayId) == mTopology.graph.end()) { return associatedDisplayId; } return mCurrentMouseDisplayId.isValid() ? mCurrentMouseDisplayId : mTopology.primaryDisplayId; if (mCurrentMouseDisplayId.isValid()) { return mCurrentMouseDisplayId; } if (mTopology.primaryDisplayId.isValid()) { return mTopology.primaryDisplayId; } return ui::LogicalDisplayId::DEFAULT; } std::pair<ui::LogicalDisplayId, PointerControllerInterface&> Loading Loading @@ -786,7 +792,8 @@ PointerChoreographer::PointerDisplayChange PointerChoreographer::calculatePointerDisplayChangeToNotify() { ui::LogicalDisplayId displayIdToNotify = ui::LogicalDisplayId::INVALID; vec2 cursorPosition = {0, 0}; if (const auto it = mMousePointersByDisplay.find(mCurrentMouseDisplayId); if (const auto it = mMousePointersByDisplay.find(getTargetMouseDisplayLocked(mCurrentMouseDisplayId)); it != mMousePointersByDisplay.end()) { const auto& pointerController = it->second; // Use the displayId from the pointerController, because it accurately reflects whether Loading services/inputflinger/tests/PointerChoreographer_test.cpp +11 −0 Original line number Diff line number Diff line Loading @@ -361,6 +361,17 @@ TEST_F(PointerChoreographerTest, CallsNotifyPointerDisplayIdChanged) { assertPointerDisplayIdNotified(DISPLAY_ID); } TEST_F(PointerChoreographerTest, NoDefaultMouseSetFallbackToDefaultDisplayId) { mChoreographer.setDisplayViewports(createViewports({ui::LogicalDisplayId::DEFAULT})); mChoreographer.notifyInputDevicesChanged( {/*id=*/0, {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::LogicalDisplayId::INVALID)}}); assertPointerControllerCreated(ControllerType::MOUSE); assertPointerDisplayIdNotified(ui::LogicalDisplayId::DEFAULT); } TEST_F(PointerChoreographerTest, WhenViewportIsSetLaterCallsNotifyPointerDisplayIdChanged) { setDefaultMouseDisplayId(DISPLAY_ID); mChoreographer.notifyInputDevicesChanged( Loading Loading
services/inputflinger/PointerChoreographer.cpp +9 −2 Original line number Diff line number Diff line Loading @@ -677,7 +677,13 @@ ui::LogicalDisplayId PointerChoreographer::getTargetMouseDisplayLocked( mTopology.graph.find(associatedDisplayId) == mTopology.graph.end()) { return associatedDisplayId; } return mCurrentMouseDisplayId.isValid() ? mCurrentMouseDisplayId : mTopology.primaryDisplayId; if (mCurrentMouseDisplayId.isValid()) { return mCurrentMouseDisplayId; } if (mTopology.primaryDisplayId.isValid()) { return mTopology.primaryDisplayId; } return ui::LogicalDisplayId::DEFAULT; } std::pair<ui::LogicalDisplayId, PointerControllerInterface&> Loading Loading @@ -786,7 +792,8 @@ PointerChoreographer::PointerDisplayChange PointerChoreographer::calculatePointerDisplayChangeToNotify() { ui::LogicalDisplayId displayIdToNotify = ui::LogicalDisplayId::INVALID; vec2 cursorPosition = {0, 0}; if (const auto it = mMousePointersByDisplay.find(mCurrentMouseDisplayId); if (const auto it = mMousePointersByDisplay.find(getTargetMouseDisplayLocked(mCurrentMouseDisplayId)); it != mMousePointersByDisplay.end()) { const auto& pointerController = it->second; // Use the displayId from the pointerController, because it accurately reflects whether Loading
services/inputflinger/tests/PointerChoreographer_test.cpp +11 −0 Original line number Diff line number Diff line Loading @@ -361,6 +361,17 @@ TEST_F(PointerChoreographerTest, CallsNotifyPointerDisplayIdChanged) { assertPointerDisplayIdNotified(DISPLAY_ID); } TEST_F(PointerChoreographerTest, NoDefaultMouseSetFallbackToDefaultDisplayId) { mChoreographer.setDisplayViewports(createViewports({ui::LogicalDisplayId::DEFAULT})); mChoreographer.notifyInputDevicesChanged( {/*id=*/0, {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::LogicalDisplayId::INVALID)}}); assertPointerControllerCreated(ControllerType::MOUSE); assertPointerDisplayIdNotified(ui::LogicalDisplayId::DEFAULT); } TEST_F(PointerChoreographerTest, WhenViewportIsSetLaterCallsNotifyPointerDisplayIdChanged) { setDefaultMouseDisplayId(DISPLAY_ID); mChoreographer.notifyInputDevicesChanged( Loading