1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 05:17:34 +00:00

LibWeb: Refactor WebContentServer mouse input message to DevicePixel

This commit is contained in:
Bastiaan van der Plaat 2023-12-15 17:46:09 +01:00 committed by Alexander Kalenik
parent 1f171cb60b
commit b73ae80d8b
11 changed files with 90 additions and 93 deletions

View file

@ -138,11 +138,6 @@ DevicePixelRect Page::rounded_device_rect(CSSPixelRect rect) const
};
}
bool Page::handle_mousewheel(DevicePixelPoint position, DevicePixelPoint screen_position, unsigned button, unsigned buttons, unsigned modifiers, int wheel_delta_x, int wheel_delta_y)
{
return top_level_browsing_context().event_handler().handle_mousewheel(device_to_css_point(position), device_to_css_point(screen_position), button, buttons, modifiers, wheel_delta_x, wheel_delta_y);
}
bool Page::handle_mouseup(DevicePixelPoint position, DevicePixelPoint screen_position, unsigned button, unsigned buttons, unsigned modifiers)
{
return top_level_browsing_context().event_handler().handle_mouseup(device_to_css_point(position), device_to_css_point(screen_position), button, buttons, modifiers);
@ -158,6 +153,11 @@ bool Page::handle_mousemove(DevicePixelPoint position, DevicePixelPoint screen_p
return top_level_browsing_context().event_handler().handle_mousemove(device_to_css_point(position), device_to_css_point(screen_position), buttons, modifiers);
}
bool Page::handle_mousewheel(DevicePixelPoint position, DevicePixelPoint screen_position, unsigned button, unsigned buttons, unsigned modifiers, DevicePixels wheel_delta_x, DevicePixels wheel_delta_y)
{
return top_level_browsing_context().event_handler().handle_mousewheel(device_to_css_point(position), device_to_css_point(screen_position), button, buttons, modifiers, wheel_delta_x.value(), wheel_delta_y.value());
}
bool Page::handle_doubleclick(DevicePixelPoint position, DevicePixelPoint screen_position, unsigned button, unsigned buttons, unsigned modifiers)
{
return top_level_browsing_context().event_handler().handle_doubleclick(device_to_css_point(position), device_to_css_point(screen_position), button, buttons, modifiers);

View file

@ -77,7 +77,7 @@ public:
bool handle_mouseup(DevicePixelPoint, DevicePixelPoint screen_position, unsigned button, unsigned buttons, unsigned modifiers);
bool handle_mousedown(DevicePixelPoint, DevicePixelPoint screen_position, unsigned button, unsigned buttons, unsigned modifiers);
bool handle_mousemove(DevicePixelPoint, DevicePixelPoint screen_position, unsigned buttons, unsigned modifiers);
bool handle_mousewheel(DevicePixelPoint, DevicePixelPoint screen_position, unsigned button, unsigned buttons, unsigned modifiers, int wheel_delta_x, int wheel_delta_y);
bool handle_mousewheel(DevicePixelPoint, DevicePixelPoint screen_position, unsigned button, unsigned buttons, unsigned modifiers, DevicePixels wheel_delta_x, DevicePixels wheel_delta_y);
bool handle_doubleclick(DevicePixelPoint, DevicePixelPoint screen_position, unsigned button, unsigned buttons, unsigned modifiers);
bool handle_keydown(KeyCode, unsigned modifiers, u32 code_point);

View file

@ -337,25 +337,26 @@ void OutOfProcessWebView::process_next_input_event()
}
},
[this](GUI::MouseEvent const& event) {
auto screen_position = event.position() + (window()->position() + relative_position());
auto position = to_content_position(event.position()).to_type<Web::DevicePixels>();
auto screen_position = (event.position() + (window()->position() + relative_position())).to_type<Web::DevicePixels>();
switch (event.type()) {
case GUI::Event::Type::MouseDown:
client().async_mouse_down(to_content_position(event.position()), screen_position, event.button(), event.buttons(), event.modifiers());
client().async_mouse_down(position, screen_position, event.button(), event.buttons(), event.modifiers());
break;
case GUI::Event::Type::MouseUp:
client().async_mouse_up(to_content_position(event.position()), screen_position, event.button(), event.buttons(), event.modifiers());
client().async_mouse_up(position, screen_position, event.button(), event.buttons(), event.modifiers());
break;
case GUI::Event::Type::MouseMove:
client().async_mouse_move(to_content_position(event.position()), screen_position, event.button(), event.buttons(), event.modifiers());
client().async_mouse_move(position, screen_position, event.button(), event.buttons(), event.modifiers());
break;
case GUI::Event::Type::MouseWheel: {
// FIXME: This wheel delta step size multiplier is used to remain the old scroll behaviour, in future use system step size.
constexpr int scroll_step_size = 24;
client().async_mouse_wheel(to_content_position(event.position()), screen_position, event.button(), event.buttons(), event.modifiers(), event.wheel_delta_x() * scroll_step_size, event.wheel_delta_y() * scroll_step_size);
client().async_mouse_wheel(position, screen_position, event.button(), event.buttons(), event.modifiers(), event.wheel_delta_x() * scroll_step_size, event.wheel_delta_y() * scroll_step_size);
break;
}
case GUI::Event::Type::MouseDoubleClick:
client().async_doubleclick(to_content_position(event.position()), screen_position, event.button(), event.buttons(), event.modifiers());
client().async_doubleclick(position, screen_position, event.button(), event.buttons(), event.modifiers());
break;
default:
dbgln("Unrecognized mouse event type in OOPWV input event queue: {}", event.type());