diff options
| author | 2021-06-01 17:34:59 -0700 | |
|---|---|---|
| committer | 2021-06-21 14:18:05 -0700 | |
| commit | 4b19bd0d193d0fa06212d2e96f3971daed01b6e3 (patch) | |
| tree | bb8959ae2763987f74e1aeb3daca6df201b7828a /libs/input/Input.cpp | |
| parent | c652358755a933991bc8bf99b48d9c5f3df03907 (diff) | |
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
Diffstat (limited to 'libs/input/Input.cpp')
| -rw-r--r-- | libs/input/Input.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/libs/input/Input.cpp b/libs/input/Input.cpp index f1ccce1b9f..266d7a3c87 100644 --- a/libs/input/Input.cpp +++ b/libs/input/Input.cpp @@ -630,6 +630,13 @@ void MotionEvent::applyTransform(const std::array<float, 9>& matrix) { // 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__ |