LibWeb: Make handle_mousewheel wheel delta use pixels
This commit is contained in:
parent
7d588db6c8
commit
0facfd3257
Notes:
sideshowbarker
2024-07-17 08:43:11 +09:00
Author: https://github.com/bplaat Commit: https://github.com/SerenityOS/serenity/commit/0facfd3257 Pull-request: https://github.com/SerenityOS/serenity/pull/20460 Reviewed-by: https://github.com/MacDue Reviewed-by: https://github.com/kalenikaliaksandr
3 changed files with 9 additions and 8 deletions
Ladybird/Qt
Userland/Libraries
|
@ -285,10 +285,10 @@ void WebContentView::wheelEvent(QWheelEvent* event)
|
|||
auto num_degrees = -event->angleDelta();
|
||||
float delta_x = -num_degrees.x() / 120;
|
||||
float delta_y = num_degrees.y() / 120;
|
||||
// Note: This does not use the QScrollBar's step size as LibWeb multiples this by a step size internally.
|
||||
auto step_x = delta_x * QApplication::wheelScrollLines() * devicePixelRatio();
|
||||
auto step_y = delta_y * QApplication::wheelScrollLines() * devicePixelRatio();
|
||||
client().async_mouse_wheel(to_content_position(position), button, buttons, modifiers, step_x, step_y);
|
||||
constexpr int scroll_step_size = 24;
|
||||
client().async_mouse_wheel(to_content_position(position), button, buttons, modifiers, step_x * scroll_step_size, step_y * scroll_step_size);
|
||||
event->accept();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -146,8 +146,6 @@ Painting::PaintableBox const* EventHandler::paint_root() const
|
|||
|
||||
bool EventHandler::handle_mousewheel(CSSPixelPoint position, unsigned button, unsigned buttons, unsigned int modifiers, int wheel_delta_x, int wheel_delta_y)
|
||||
{
|
||||
constexpr int scroll_step_size = 24;
|
||||
|
||||
if (m_browsing_context->active_document())
|
||||
m_browsing_context->active_document()->update_layout();
|
||||
|
||||
|
@ -167,7 +165,7 @@ bool EventHandler::handle_mousewheel(CSSPixelPoint position, unsigned button, un
|
|||
auto* containing_block = paintable->containing_block();
|
||||
while (containing_block) {
|
||||
if (containing_block->is_user_scrollable()) {
|
||||
const_cast<Painting::PaintableBox*>(containing_block->paintable_box())->handle_mousewheel({}, position, buttons, modifiers, wheel_delta_x * scroll_step_size, wheel_delta_y * scroll_step_size);
|
||||
const_cast<Painting::PaintableBox*>(containing_block->paintable_box())->handle_mousewheel({}, position, buttons, modifiers, wheel_delta_x, wheel_delta_y);
|
||||
break;
|
||||
}
|
||||
containing_block = containing_block->containing_block();
|
||||
|
@ -192,7 +190,7 @@ bool EventHandler::handle_mousewheel(CSSPixelPoint position, unsigned button, un
|
|||
if (node->dispatch_event(UIEvents::WheelEvent::create_from_platform_event(node->realm(), UIEvents::EventNames::wheel, offset.x(), offset.y(), position.x(), position.y(), wheel_delta_x, wheel_delta_y, buttons, button).release_value_but_fixme_should_propagate_errors())) {
|
||||
if (auto* page = m_browsing_context->page()) {
|
||||
if (m_browsing_context == &page->top_level_browsing_context())
|
||||
page->client().page_did_request_scroll(wheel_delta_x * scroll_step_size, wheel_delta_y * scroll_step_size);
|
||||
page->client().page_did_request_scroll(wheel_delta_x, wheel_delta_y);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -423,9 +423,12 @@ void OutOfProcessWebView::process_next_input_event()
|
|||
case GUI::Event::Type::MouseMove:
|
||||
client().async_mouse_move(to_content_position(event.position()), event.button(), event.buttons(), event.modifiers());
|
||||
break;
|
||||
case GUI::Event::Type::MouseWheel:
|
||||
client().async_mouse_wheel(to_content_position(event.position()), event.button(), event.buttons(), event.modifiers(), event.wheel_delta_x(), event.wheel_delta_y());
|
||||
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()), 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()), event.button(), event.buttons(), event.modifiers());
|
||||
break;
|
||||
|
|
Loading…
Add table
Reference in a new issue