LinearLayout: handle overwritten performClick() method

This is needed to make TabLayout functional
This commit is contained in:
Julian Winkler
2023-09-01 12:19:45 +02:00
parent fb1a07967e
commit 295d9dfda3
3 changed files with 17 additions and 0 deletions

View File

@@ -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");

View File

@@ -80,6 +80,7 @@ struct handle_cache {
jmethodID computeScroll;
jmethodID getScrollX;
jmethodID getScrollY;
jmethodID performClick;
} view;
struct {
jclass class;

View File

@@ -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");