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:
Alex Studer
2024-07-07 01:26:04 -04:00
committed by Andrew Kaster
parent feb7c0d950
commit e6432041b2
5 changed files with 71 additions and 0 deletions

View File

@@ -103,6 +103,25 @@ void WebViewImplementationNative::set_device_pixel_ratio(float f)
client().async_set_device_pixels_per_css_pixel(0, m_device_pixel_ratio);
}
void WebViewImplementationNative::mouse_event(Web::MouseEvent::Type event_type, float x, float y, float raw_x, float raw_y)
{
Gfx::IntPoint position = { x, y };
Gfx::IntPoint screen_position = { raw_x, raw_y };
auto event = Web::MouseEvent {
event_type,
position.to_type<Web::DevicePixels>(),
screen_position.to_type<Web::DevicePixels>(),
Web::UIEvents::MouseButton::Primary,
Web::UIEvents::MouseButton::Primary,
Web::UIEvents::KeyModifier::Mod_None,
0,
0,
nullptr
};
enqueue_input_event(move(event));
}
NonnullRefPtr<WebView::WebContentClient> WebViewImplementationNative::bind_web_content_client()
{
JavaEnvironment env(global_vm);