From a62a8dd15e3deb4622e3ee8fd844999cf4fafc41 Mon Sep 17 00:00:00 2001 From: Siarhei Vishniakou Date: Fri, 8 Jun 2018 21:17:33 +0100 Subject: 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 --- libs/input/Input.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'libs/input/Input.cpp') diff --git a/libs/input/Input.cpp b/libs/input/Input.cpp index db27e11e24..8a15e2f40f 100644 --- a/libs/input/Input.cpp +++ b/libs/input/Input.cpp @@ -31,14 +31,16 @@ namespace android { // --- InputEvent --- -void InputEvent::initialize(int32_t deviceId, int32_t source) { +void InputEvent::initialize(int32_t deviceId, int32_t source, int32_t displayId) { mDeviceId = deviceId; mSource = source; + mDisplayId = displayId; } void InputEvent::initialize(const InputEvent& from) { mDeviceId = from.mDeviceId; mSource = from.mSource; + mDisplayId = from.mDisplayId; } // --- KeyEvent --- @@ -54,6 +56,7 @@ int32_t KeyEvent::getKeyCodeFromLabel(const char* label) { void KeyEvent::initialize( int32_t deviceId, int32_t source, + int32_t displayId, int32_t action, int32_t flags, int32_t keyCode, @@ -62,7 +65,7 @@ void KeyEvent::initialize( int32_t repeatCount, nsecs_t downTime, nsecs_t eventTime) { - InputEvent::initialize(deviceId, source); + InputEvent::initialize(deviceId, source, displayId); mAction = action; mFlags = flags; mKeyCode = keyCode; @@ -231,8 +234,7 @@ void MotionEvent::initialize( size_t pointerCount, const PointerProperties* pointerProperties, const PointerCoords* pointerCoords) { - InputEvent::initialize(deviceId, source); - mDisplayId = displayId; + InputEvent::initialize(deviceId, source, displayId); mAction = action; mActionButton = actionButton; mFlags = flags; @@ -252,8 +254,7 @@ void MotionEvent::initialize( } void MotionEvent::copyFrom(const MotionEvent* other, bool keepHistory) { - InputEvent::initialize(other->mDeviceId, other->mSource); - mDisplayId = other->mDisplayId; + InputEvent::initialize(other->mDeviceId, other->mSource, other->mDisplayId); mAction = other->mAction; mActionButton = other->mActionButton; mFlags = other->mFlags; -- cgit v1.2.3-59-g8ed1b