Let InputReader set mouse cursor's display.
InputReader was already responsible to bind device/event and display. It
makes sense to further extend it to control the display where mouse
cursor is shown.
Bug: 146385350
Test: Mouse cursor shows up at expected display.
Test: atest inputflinger_tests
Change-Id: Ie7a9546550b70c8834462b06de929472196fe713
diff --git a/services/inputflinger/tests/InputReader_test.cpp b/services/inputflinger/tests/InputReader_test.cpp
index a9d7793..8ca7e4a 100644
--- a/services/inputflinger/tests/InputReader_test.cpp
+++ b/services/inputflinger/tests/InputReader_test.cpp
@@ -90,10 +90,6 @@
mMaxY = maxY;
}
- void setDisplayId(int32_t displayId) {
- mDisplayId = displayId;
- }
-
virtual void setPosition(float x, float y) {
mX = x;
mY = y;
@@ -116,6 +112,10 @@
return mDisplayId;
}
+ virtual void setDisplayViewport(const DisplayViewport& viewport) {
+ mDisplayId = viewport.displayId;
+ }
+
const std::map<int32_t, std::vector<int32_t>>& getSpots() {
return mSpotsByDisplay;
}
@@ -280,6 +280,10 @@
mConfig.showTouches = enabled;
}
+ void setDefaultPointerDisplayId(int32_t pointerDisplayId) {
+ mConfig.defaultPointerDisplayId = pointerDisplayId;
+ }
+
private:
DisplayViewport createDisplayViewport(int32_t displayId, int32_t width, int32_t height,
int32_t orientation, const std::string& uniqueId, std::optional<uint8_t> physicalPort,
@@ -3432,12 +3436,18 @@
CursorInputMapper* mapper = new CursorInputMapper(mDevice);
addMapperAndConfigure(mapper);
- // Setup PointerController for second display.
+ // Setup for second display.
constexpr int32_t SECOND_DISPLAY_ID = 1;
+ const std::string SECOND_DISPLAY_UNIQUE_ID = "local:1";
+ mFakePolicy->addDisplayViewport(SECOND_DISPLAY_ID, 800, 480, DISPLAY_ORIENTATION_0,
+ SECOND_DISPLAY_UNIQUE_ID, NO_PORT,
+ ViewportType::VIEWPORT_EXTERNAL);
+ mFakePolicy->setDefaultPointerDisplayId(SECOND_DISPLAY_ID);
+ configureDevice(InputReaderConfiguration::CHANGE_DISPLAY_INFO);
+
mFakePointerController->setBounds(0, 0, 800 - 1, 480 - 1);
mFakePointerController->setPosition(100, 200);
mFakePointerController->setButtonState(0);
- mFakePointerController->setDisplayId(SECOND_DISPLAY_ID);
NotifyMotionArgs args;
process(mapper, ARBITRARY_TIME, EV_REL, REL_X, 10);
@@ -6539,14 +6549,16 @@
}
TEST_F(MultiTouchInputMapperTest, Process_Pointer_ShouldHandleDisplayId) {
- // Setup PointerController for second display.
+ // Setup for second display.
sp<FakePointerController> fakePointerController = new FakePointerController();
- fakePointerController->setBounds(0, 0, 800 - 1, 480 - 1);
+ fakePointerController->setBounds(0, 0, DISPLAY_WIDTH - 1, DISPLAY_HEIGHT - 1);
fakePointerController->setPosition(100, 200);
fakePointerController->setButtonState(0);
- fakePointerController->setDisplayId(SECONDARY_DISPLAY_ID);
mFakePolicy->setPointerController(mDevice->getId(), fakePointerController);
+ mFakePolicy->setDefaultPointerDisplayId(SECONDARY_DISPLAY_ID);
+ prepareSecondaryDisplay(ViewportType::VIEWPORT_EXTERNAL);
+
MultiTouchInputMapper* mapper = new MultiTouchInputMapper(mDevice);
prepareDisplay(DISPLAY_ORIENTATION_0);
prepareAxes(POSITION);