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

Commit de54d1a1 authored by Prabir Pradhan's avatar Prabir Pradhan
Browse files

MotionEvent: Get offsets in raw coordinate space

Use the offsets in raw coordinates instead of the previously used
offsets in untransformed coordinates, which does not have any meaning in
Java.

Bug: 249340921
Test: atest libinput_tests
Test: atest inputflinger_tests
Change-Id: Ia21d63be5a2c45a2339227061de89ab772a8e7f7
parent 20e88667
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -1775,9 +1775,9 @@ public final class MotionEvent extends InputEvent implements Parcelable {
    @CriticalNative
    private static native void nativeOffsetLocation(long nativePtr, float deltaX, float deltaY);
    @CriticalNative
    private static native float nativeGetXOffset(long nativePtr);
    private static native float nativeGetRawXOffset(long nativePtr);
    @CriticalNative
    private static native float nativeGetYOffset(long nativePtr);
    private static native float nativeGetRawYOffset(long nativePtr);
    @CriticalNative
    private static native float nativeGetXPrecision(long nativePtr);
    @CriticalNative
@@ -3745,7 +3745,7 @@ public final class MotionEvent extends InputEvent implements Parcelable {
                    nativeGetAction(mNativePtr), nativeGetFlags(mNativePtr),
                    nativeGetEdgeFlags(mNativePtr), nativeGetMetaState(mNativePtr),
                    nativeGetButtonState(mNativePtr), nativeGetClassification(mNativePtr),
                    nativeGetXOffset(mNativePtr), nativeGetYOffset(mNativePtr),
                    nativeGetRawXOffset(mNativePtr), nativeGetRawYOffset(mNativePtr),
                    nativeGetXPrecision(mNativePtr), nativeGetYPrecision(mNativePtr),
                    nativeGetDownTimeNanos(mNativePtr),
                    nativeGetEventTimeNanos(mNativePtr, HISTORY_CURRENT),
+8 −8
Original line number Diff line number Diff line
@@ -411,8 +411,8 @@ static void android_view_MotionEvent_nativeAddBatch(JNIEnv* env, jclass clazz,
            jniThrowNullPointerException(env, "pointerCoords");
            return;
        }
        pointerCoordsToNative(env, pointerCoordsObj,
                event->getXOffset(), event->getYOffset(), &rawPointerCoords[i]);
        pointerCoordsToNative(env, pointerCoordsObj, event->getRawXOffset(), event->getRawYOffset(),
                              &rawPointerCoords[i]);
        env->DeleteLocalRef(pointerCoordsObj);
    }

@@ -735,14 +735,14 @@ static void android_view_MotionEvent_nativeOffsetLocation(jlong nativePtr, jfloa
    return event->offsetLocation(deltaX, deltaY);
}

static jfloat android_view_MotionEvent_nativeGetXOffset(jlong nativePtr) {
static jfloat android_view_MotionEvent_nativeGetRawXOffset(jlong nativePtr) {
    MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
    return event->getXOffset();
    return event->getRawXOffset();
}

static jfloat android_view_MotionEvent_nativeGetYOffset(jlong nativePtr) {
static jfloat android_view_MotionEvent_nativeGetRawYOffset(jlong nativePtr) {
    MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
    return event->getYOffset();
    return event->getRawYOffset();
}

static jfloat android_view_MotionEvent_nativeGetXPrecision(jlong nativePtr) {
@@ -871,8 +871,8 @@ static const JNINativeMethod gMotionEventMethods[] = {
        {"nativeGetClassification", "(J)I",
         (void*)android_view_MotionEvent_nativeGetClassification},
        {"nativeOffsetLocation", "(JFF)V", (void*)android_view_MotionEvent_nativeOffsetLocation},
        {"nativeGetXOffset", "(J)F", (void*)android_view_MotionEvent_nativeGetXOffset},
        {"nativeGetYOffset", "(J)F", (void*)android_view_MotionEvent_nativeGetYOffset},
        {"nativeGetRawXOffset", "(J)F", (void*)android_view_MotionEvent_nativeGetRawXOffset},
        {"nativeGetRawYOffset", "(J)F", (void*)android_view_MotionEvent_nativeGetRawYOffset},
        {"nativeGetXPrecision", "(J)F", (void*)android_view_MotionEvent_nativeGetXPrecision},
        {"nativeGetYPrecision", "(J)F", (void*)android_view_MotionEvent_nativeGetYPrecision},
        {"nativeGetXCursorPosition", "(J)F",
+2 −2
Original line number Diff line number Diff line
@@ -124,11 +124,11 @@ int64_t AMotionEvent_getEventTime(const AInputEvent* motion_event) {
}

float AMotionEvent_getXOffset(const AInputEvent* motion_event) {
    return static_cast<const MotionEvent*>(motion_event)->getXOffset();
    return static_cast<const MotionEvent*>(motion_event)->getRawXOffset();
}

float AMotionEvent_getYOffset(const AInputEvent* motion_event) {
    return static_cast<const MotionEvent*>(motion_event)->getYOffset();
    return static_cast<const MotionEvent*>(motion_event)->getRawYOffset();
}

float AMotionEvent_getXPrecision(const AInputEvent* motion_event) {