diff --git a/src/api-impl-jni/util.c b/src/api-impl-jni/util.c index e49fb1ba..9d97a3e7 100644 --- a/src/api-impl-jni/util.c +++ b/src/api-impl-jni/util.c @@ -119,6 +119,7 @@ void set_up_handle_cache(JNIEnv *env) handle_cache.view.computeScroll = _METHOD(handle_cache.view.class, "computeScroll", "()V"); handle_cache.view.getScrollX = _METHOD(handle_cache.view.class, "getScrollX", "()I"); handle_cache.view.getScrollY = _METHOD(handle_cache.view.class, "getScrollY", "()I"); + handle_cache.view.performClick = _METHOD(handle_cache.view.class, "performClick", "()Z"); handle_cache.asset_manager.class = _REF((*env)->FindClass(env, "android/content/res/AssetManager")); handle_cache.asset_manager.extractFromAPK = _STATIC_METHOD(handle_cache.asset_manager.class, "extractFromAPK", "(Ljava/lang/String;Ljava/lang/String;)V"); diff --git a/src/api-impl-jni/util.h b/src/api-impl-jni/util.h index 6cfc3db0..06041ee0 100644 --- a/src/api-impl-jni/util.h +++ b/src/api-impl-jni/util.h @@ -80,6 +80,7 @@ struct handle_cache { jmethodID computeScroll; jmethodID getScrollX; jmethodID getScrollY; + jmethodID performClick; } view; struct { jclass class; diff --git a/src/api-impl-jni/widgets/android_widget_LinearLayout.c b/src/api-impl-jni/widgets/android_widget_LinearLayout.c index 9b3ecbf8..657b26df 100644 --- a/src/api-impl-jni/widgets/android_widget_LinearLayout.c +++ b/src/api-impl-jni/widgets/android_widget_LinearLayout.c @@ -10,6 +10,15 @@ #include "../generated_headers/android_widget_LinearLayout.h" #include "../generated_headers/android_view_ViewGroup.h" +static void on_click(GtkGestureClick *gesture, int n_press, double x, double y, jobject this) +{ + JNIEnv *env = get_jni_env(); + + (*env)->CallBooleanMethod(env, this, handle_cache.view.performClick); + if((*env)->ExceptionCheck(env)) + (*env)->ExceptionDescribe(env); +} + JNIEXPORT jlong JNICALL Java_android_widget_LinearLayout_native_1constructor(JNIEnv *env, jobject this, jobject context, jobject attrs) { int orientation = attribute_set_get_int(env, attrs, "orientation", NULL, 1); @@ -22,6 +31,12 @@ JNIEXPORT jlong JNICALL Java_android_widget_LinearLayout_native_1constructor(JNI gtk_widget_set_hexpand_set(box, true); // FIXME: to counteract expand on drawing areas gtk_widget_set_vexpand_set(box, true); // XXX } + if (_METHOD(_CLASS(this), "performClick", "()Z") != handle_cache.view.performClick) { + GtkEventController *controller = GTK_EVENT_CONTROLLER(gtk_gesture_click_new()); + + g_signal_connect(controller, "released", G_CALLBACK(on_click), _REF(this)); + gtk_widget_add_controller(box, controller); + } return _INTPTR(box); // struct ninepatch_t *ninepatch = ninepatch_new("/home/Mis012/Github_and_other_sources/org.happysanta.gd_29_src.tar.gz/res/drawable-mdpi/btn_br_down.9.png");