Ladybird: Fix scroll step size

The Qt docs are not that clear, but to get the number of steps the
wheel was scrolled you divide by 120 (which when multiplied by
wheelScrollLines() gives the scroll offset).
This commit is contained in:
MacDue 2023-08-05 17:25:19 +01:00 committed by Andreas Kling
parent 22d06a4ff0
commit 7b7ba38655
Notes: sideshowbarker 2024-07-17 07:43:44 +09:00

View File

@ -282,9 +282,13 @@ void WebContentView::wheelEvent(QWheelEvent* event)
auto button = get_button_from_qt_event(*event);
auto buttons = get_buttons_from_qt_event(*event);
auto modifiers = get_modifiers_from_qt_mouse_event(*event);
auto num_degrees = -event->angleDelta() / 8;
client().async_mouse_wheel(to_content_position(position), button, buttons, modifiers, num_degrees.x(), num_degrees.y());
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);
event->accept();
return;
}