diff --git a/src/api-impl-jni/util.c b/src/api-impl-jni/util.c index a12a2d19..8161f43d 100644 --- a/src/api-impl-jni/util.c +++ b/src/api-impl-jni/util.c @@ -83,7 +83,7 @@ void set_up_handle_cache(JNIEnv *env) handle_cache.paint.getColor = _METHOD(handle_cache.paint.class, "getColor", "()I"); handle_cache.motion_event.class = _REF((*env)->FindClass(env, "android/view/MotionEvent")); - handle_cache.motion_event.constructor = _METHOD(handle_cache.motion_event.class, "", "(IIFFJ)V"); + handle_cache.motion_event.constructor = _METHOD(handle_cache.motion_event.class, "", "(IIFFJFF)V"); handle_cache.canvas.class = _REF((*env)->FindClass(env, "android/graphics/Canvas")); handle_cache.canvas.constructor = _METHOD(handle_cache.canvas.class, "", "(JJ)V"); diff --git a/src/api-impl-jni/views/android_view_View.c b/src/api-impl-jni/views/android_view_View.c index c392c38d..6d1bba3e 100644 --- a/src/api-impl-jni/views/android_view_View.c +++ b/src/api-impl-jni/views/android_view_View.c @@ -19,10 +19,13 @@ static struct touch_callback_data *cancel_triggerer = NULL; static bool call_ontouch_callback(int action, double x, double y, struct touch_callback_data *d, GtkPropagationPhase phase, guint32 timestamp, GdkEvent *event) { bool ret; + double raw_x; + double raw_y; JNIEnv *env; (*d->jvm)->GetEnv(d->jvm, (void**)&env, JNI_VERSION_1_6); - jobject motion_event = (*env)->NewObject(env, handle_cache.motion_event.class, handle_cache.motion_event.constructor, SOURCE_TOUCHSCREEN, action, (float)x, (float)y, (long)timestamp); + gdk_event_get_position(event, &raw_x, &raw_y); + jobject motion_event = (*env)->NewObject(env, handle_cache.motion_event.class, handle_cache.motion_event.constructor, SOURCE_TOUCHSCREEN, action, (float)x, (float)y, (long)timestamp, (float)raw_x, (float)raw_y); if (phase == GTK_PHASE_CAPTURE && !d->intercepted) { d->intercepted = (*env)->CallBooleanMethod(env, d->this, handle_cache.view.onInterceptTouchEvent, motion_event); @@ -120,7 +123,7 @@ static gboolean scroll_cb(GtkEventControllerScroll* self, gdouble dx, gdouble dy dx /= MAGIC_SCROLL_FACTOR; dy /= MAGIC_SCROLL_FACTOR; } - jobject motion_event = (*env)->NewObject(env, handle_cache.motion_event.class, handle_cache.motion_event.constructor, SOURCE_CLASS_POINTER, MOTION_EVENT_ACTION_SCROLL, dx, -dy, (long)0); + jobject motion_event = (*env)->NewObject(env, handle_cache.motion_event.class, handle_cache.motion_event.constructor, SOURCE_CLASS_POINTER, MOTION_EVENT_ACTION_SCROLL, dx, -dy, (long)0, 0.f, 0.f); gboolean ret = (*env)->CallBooleanMethod(env, this, handle_cache.view.onGenericMotionEvent, motion_event); if((*env)->ExceptionCheck(env)) diff --git a/src/api-impl/android/view/MotionEvent.java b/src/api-impl/android/view/MotionEvent.java index ed7d08fc..f69444af 100644 --- a/src/api-impl/android/view/MotionEvent.java +++ b/src/api-impl/android/view/MotionEvent.java @@ -1370,16 +1370,20 @@ public final class MotionEvent extends InputEvent { float coord_x; float coord_y; long eventTime; + float raw_x; + float raw_y; private MotionEvent() { } - public MotionEvent(int source, int action, float coord_x, float coord_y, long eventTime) { + public MotionEvent(int source, int action, float coord_x, float coord_y, long eventTime, float raw_x, float raw_y) { this.source = source; this.action = action; this.coord_x = coord_x; this.coord_y = coord_y; this.eventTime = eventTime; + this.raw_x = raw_x; + this.raw_y = raw_y; } @Override @@ -2233,7 +2237,7 @@ public final class MotionEvent extends InputEvent { * @see #AXIS_X */ public final float getRawX() { - return coord_x; + return raw_x; } /** @@ -2246,7 +2250,7 @@ public final class MotionEvent extends InputEvent { * @see #AXIS_Y */ public final float getRawY() { - return coord_y; + return raw_y; } /**