Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4b19bd0d authored by Prabir Pradhan's avatar Prabir Pradhan
Browse files

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
parent c6523587
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -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__