MotionEvent: Transform mouse cursor position
When calling MotionEvent::applyTransform, the x/y coordinates for all
PointerCoords are transformed accordingly. When this happens, we also
need to transform the mouse cursor position.
Bug: 179274888
Test: atest InputShellCommandTest (when the display is rotated to
different orientations)
Change-Id: I10db8238150b1bd20f3f53c3a7514a111e362adb
diff --git a/libs/input/Input.cpp b/libs/input/Input.cpp
index f1ccce1..266d7a3 100644
--- a/libs/input/Input.cpp
+++ b/libs/input/Input.cpp
@@ -630,6 +630,13 @@
// Apply the transformation to all samples.
std::for_each(mSamplePointerCoords.begin(), mSamplePointerCoords.end(),
[&transform](PointerCoords& c) { c.transform(transform); });
+
+ if (mRawXCursorPosition != AMOTION_EVENT_INVALID_CURSOR_POSITION &&
+ mRawYCursorPosition != AMOTION_EVENT_INVALID_CURSOR_POSITION) {
+ const vec2 cursor = transform.transform(mRawXCursorPosition, mRawYCursorPosition);
+ mRawXCursorPosition = cursor.x;
+ mRawYCursorPosition = cursor.y;
+ }
}
#ifdef __linux__