Move displayid into InputEvent
There are certain use cases where key events should be associated with a
particular display. Refactor KeyEvent and MotionEvent to have an
associated display id.
Remove "hasAssociatedDisplay" variable from KeyboardInputMapper,
it just used to mirror "isOrientationAware".
If the keyboard is orientation aware (= it is physically attached to a
display, and therefore rotates together with that display), then
associate that keyboard with the internal viewport. Otherwise, the key
events are not associated with any particular display.
Remaining to do:
- make mInternalDisplay, mExternalDisplay, mVirtualDisplays into a
single vector with type (internal, external, virtual)
- have getDisplayViewport return std::optional (will require deep
changes)
Bug: 64258305
Test: atest inputflinger_tests libinput_tests
Change-Id: I4fe145e74cb59310efaa55bfc9dc3c2b3bd997e3
diff --git a/services/inputflinger/tests/InputDispatcher_test.cpp b/services/inputflinger/tests/InputDispatcher_test.cpp
index 9c72c77..0e26d4a 100644
--- a/services/inputflinger/tests/InputDispatcher_test.cpp
+++ b/services/inputflinger/tests/InputDispatcher_test.cpp
@@ -120,7 +120,7 @@
KeyEvent event;
// Rejects undefined key actions.
- event.initialize(DEVICE_ID, AINPUT_SOURCE_KEYBOARD,
+ event.initialize(DEVICE_ID, AINPUT_SOURCE_KEYBOARD, ADISPLAY_ID_NONE,
/*action*/ -1, 0,
AKEYCODE_A, KEY_A, AMETA_NONE, 0, ARBITRARY_TIME, ARBITRARY_TIME);
ASSERT_EQ(INPUT_EVENT_INJECTION_FAILED, mDispatcher->injectInputEvent(
@@ -129,7 +129,7 @@
<< "Should reject key events with undefined action.";
// Rejects ACTION_MULTIPLE since it is not supported despite being defined in the API.
- event.initialize(DEVICE_ID, AINPUT_SOURCE_KEYBOARD,
+ event.initialize(DEVICE_ID, AINPUT_SOURCE_KEYBOARD, ADISPLAY_ID_NONE,
AKEY_EVENT_ACTION_MULTIPLE, 0,
AKEYCODE_A, KEY_A, AMETA_NONE, 0, ARBITRARY_TIME, ARBITRARY_TIME);
ASSERT_EQ(INPUT_EVENT_INJECTION_FAILED, mDispatcher->injectInputEvent(