View: add basic implemntation of dispatchTouchEvent

Some Views block all events going to their descendants, and
then synthesize new events themselves. Gtk doesn't allow event
synthesization, which makes this quite annoying to deal with.
This initial implementation definiely has some problems,
for example it seems to cause infinite loops in some cases,
however it surprisingly works well enough.
This commit is contained in:
Mis012
2025-03-26 20:06:09 +01:00
parent b19f2c35d2
commit 4d12ad5c90
9 changed files with 518 additions and 24 deletions

View File

@@ -132,6 +132,7 @@ void set_up_handle_cache(JNIEnv *env)
handle_cache.view.getScrollY = _METHOD(handle_cache.view.class, "getScrollY", "()I");
handle_cache.view.performClick = _METHOD(handle_cache.view.class, "performClick", "()Z");
handle_cache.view.onTouchEvent = _METHOD(handle_cache.view.class, "onTouchEvent", "(Landroid/view/MotionEvent;)Z");
handle_cache.view.onTouchEventInternal = _METHOD(handle_cache.view.class, "onTouchEventInternal", "(Landroid/view/MotionEvent;)Z");
handle_cache.view.dispatchTouchEvent = _METHOD(handle_cache.view.class, "dispatchTouchEvent", "(Landroid/view/MotionEvent;)Z");
handle_cache.view.onInterceptTouchEvent = _METHOD(handle_cache.view.class, "onInterceptTouchEvent", "(Landroid/view/MotionEvent;)Z");
handle_cache.view.layoutInternal = _METHOD(handle_cache.view.class, "layoutInternal", "(II)V");
@@ -143,6 +144,9 @@ void set_up_handle_cache(JNIEnv *env)
handle_cache.view.dispatchKeyEvent = _METHOD(handle_cache.view.class, "dispatchKeyEvent", "(Landroid/view/KeyEvent;)Z");
handle_cache.view.onKeyDown = _METHOD(handle_cache.view.class, "onKeyDown", "(ILandroid/view/KeyEvent;)Z");
handle_cache.view_group.class = _REF((*env)->FindClass(env, "android/view/ViewGroup"));
handle_cache.view_group.dispatchTouchEvent = _METHOD(handle_cache.view_group.class, "dispatchTouchEvent", "(Landroid/view/MotionEvent;)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");