OnTouchListener: attach event controllers to WrapperWidget

otherwise, the touch event positions would depend on the scroll offset.
This fixes the glitchy vertical scrolling in ViewPager
This commit is contained in:
Julian Winkler
2024-03-25 19:50:29 +01:00
parent 2879e03120
commit e477b56dec
2 changed files with 2 additions and 3 deletions

View File

@@ -171,7 +171,7 @@ void _setOnTouchListener(JNIEnv *env, jobject this, GtkWidget *widget, jobject o
JNIEXPORT void JNICALL Java_android_view_View_setOnTouchListener(JNIEnv *env, jobject this, jobject on_touch_listener)
{
GtkWidget *widget = GTK_WIDGET(_PTR(_GET_LONG_FIELD(this, "widget")));
GtkWidget *widget = gtk_widget_get_parent(GTK_WIDGET(_PTR(_GET_LONG_FIELD(this, "widget"))));
_setOnTouchListener(env, this, widget, on_touch_listener);
}

View File

@@ -170,8 +170,7 @@ void wrapper_widget_set_jobject(WrapperWidget *wrapper, JNIEnv *env, jobject job
jmethodID ontouchevent_method = _METHOD(_CLASS(jobj), "onTouchEvent", "(Landroid/view/MotionEvent;)Z");
if (ontouchevent_method != handle_cache.view.onTouchEvent) {
/* use wrapper->child since the jobject may not have the "widget" variable set yet */
_setOnTouchListener(env, jobj, wrapper->child, NULL);
_setOnTouchListener(env, jobj, GTK_WIDGET(wrapper), NULL);
}
jmethodID computeScroll_method = _METHOD(_CLASS(jobj), "computeScroll", "()V");