mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-19 06:55:18 +00:00
Android: Pass touch events through as mouse events
This is probably not the best way of handling touch events, but at least it allows the user to actually interact with the page!
This commit is contained in:
committed by
Andrew Kaster
parent
feb7c0d950
commit
e6432041b2
@@ -93,3 +93,29 @@ Java_org_serenityos_ladybird_WebViewImplementation_nativeSetDevicePixelRatio(JNI
|
||||
auto* impl = reinterpret_cast<WebViewImplementationNative*>(instance);
|
||||
impl->set_device_pixel_ratio(ratio);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_org_serenityos_ladybird_WebViewImplementation_nativeMouseEvent(JNIEnv*, jobject /* thiz */, jlong instance, jint event_type, jfloat x, jfloat y, jfloat raw_x, jfloat raw_y)
|
||||
{
|
||||
auto* impl = reinterpret_cast<WebViewImplementationNative*>(instance);
|
||||
|
||||
Web::MouseEvent::Type web_event_type;
|
||||
|
||||
// These integers are defined in Android's MotionEvent.
|
||||
// See https://developer.android.com/reference/android/view/MotionEvent#constants_1
|
||||
if (event_type == 0) {
|
||||
// MotionEvent.ACTION_DOWN
|
||||
web_event_type = Web::MouseEvent::Type::MouseDown;
|
||||
} else if (event_type == 1) {
|
||||
// MotionEvent.ACTION_UP
|
||||
web_event_type = Web::MouseEvent::Type::MouseUp;
|
||||
} else if (event_type == 2) {
|
||||
// MotionEvent.ACTION_MOVE
|
||||
web_event_type = Web::MouseEvent::Type::MouseMove;
|
||||
} else {
|
||||
// Unknown event type, default to MouseUp
|
||||
web_event_type = Web::MouseEvent::Type::MouseUp;
|
||||
}
|
||||
|
||||
impl->mouse_event(web_event_type, x, y, raw_x, raw_y);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user