summaryrefslogtreecommitdiff
path: root/include/input/InputEventBuilders.h
diff options
context:
space:
mode:
author Prabir Pradhan <prabirmsp@google.com> 2024-02-29 02:23:50 +0000
committer Prabir Pradhan <prabirmsp@google.com> 2024-03-05 04:23:01 +0000
commitbf9b0a854f2351e337fc7c7658cc03b75055276b (patch)
tree07937d57e660c54d0ccf2dd2960d418f8d6f6c5e /include/input/InputEventBuilders.h
parent9180f87bfaac7d0f063d1f59fa572e4751899af6 (diff)
Move MotionEvent#split implementation to native
There is already a native implementation of split in InputDispatcher. Prevent code duplication by moving the Java impl to native. The Java impl is not correct, because it cannot access all values like the transforms to initialize the split event with. Bug: 326171104 Test: atest libinput_tests Test: atest inputflinger_tests Change-Id: I6230b6aa0696dcfc275a5a14ab4af3d4b7bd0b45
Diffstat (limited to 'include/input/InputEventBuilders.h')
-rw-r--r--include/input/InputEventBuilders.h17
1 files changed, 14 insertions, 3 deletions
diff --git a/include/input/InputEventBuilders.h b/include/input/InputEventBuilders.h
index 2d23b97386..c0c5e2412d 100644
--- a/include/input/InputEventBuilders.h
+++ b/include/input/InputEventBuilders.h
@@ -118,6 +118,16 @@ public:
return *this;
}
+ MotionEventBuilder& transform(ui::Transform t) {
+ mTransform = t;
+ return *this;
+ }
+
+ MotionEventBuilder& rawTransform(ui::Transform t) {
+ mRawTransform = t;
+ return *this;
+ }
+
MotionEvent build() {
std::vector<PointerProperties> pointerProperties;
std::vector<PointerCoords> pointerCoords;
@@ -134,12 +144,11 @@ public:
}
MotionEvent event;
- static const ui::Transform kIdentityTransform;
event.initialize(InputEvent::nextId(), mDeviceId, mSource, mDisplayId, INVALID_HMAC,
mAction, mActionButton, mFlags, /*edgeFlags=*/0, AMETA_NONE, mButtonState,
- MotionClassification::NONE, kIdentityTransform,
+ MotionClassification::NONE, mTransform,
/*xPrecision=*/0, /*yPrecision=*/0, mRawXCursorPosition,
- mRawYCursorPosition, kIdentityTransform, mDownTime, mEventTime,
+ mRawYCursorPosition, mRawTransform, mDownTime, mEventTime,
mPointers.size(), pointerProperties.data(), pointerCoords.data());
return event;
}
@@ -156,6 +165,8 @@ private:
int32_t mFlags{0};
float mRawXCursorPosition{AMOTION_EVENT_INVALID_CURSOR_POSITION};
float mRawYCursorPosition{AMOTION_EVENT_INVALID_CURSOR_POSITION};
+ ui::Transform mTransform;
+ ui::Transform mRawTransform;
std::vector<PointerBuilder> mPointers;
};