mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 01:20:25 +00:00
Ladybird: Use pixelDelta() on supported platforms for better scrolling
This commit is contained in:
parent
0facfd3257
commit
abf0c8f1a6
Notes:
sideshowbarker
2024-07-17 20:33:50 +09:00
Author: https://github.com/bplaat Commit: https://github.com/SerenityOS/serenity/commit/abf0c8f1a6 Pull-request: https://github.com/SerenityOS/serenity/pull/20460 Reviewed-by: https://github.com/MacDue Reviewed-by: https://github.com/kalenikaliaksandr
1 changed files with 13 additions and 7 deletions
|
@ -282,13 +282,19 @@ 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();
|
||||
float delta_x = -num_degrees.x() / 120;
|
||||
float delta_y = num_degrees.y() / 120;
|
||||
auto step_x = delta_x * QApplication::wheelScrollLines() * devicePixelRatio();
|
||||
auto step_y = delta_y * QApplication::wheelScrollLines() * devicePixelRatio();
|
||||
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);
|
||||
|
||||
auto num_pixels = -event->pixelDelta();
|
||||
if (!num_pixels.isNull()) {
|
||||
client().async_mouse_wheel(to_content_position(position), button, buttons, modifiers, num_pixels.x(), num_pixels.y());
|
||||
} else {
|
||||
auto num_degrees = -event->angleDelta();
|
||||
float delta_x = -num_degrees.x() / 120;
|
||||
float delta_y = num_degrees.y() / 120;
|
||||
auto step_x = delta_x * QApplication::wheelScrollLines() * devicePixelRatio();
|
||||
auto step_y = delta_y * QApplication::wheelScrollLines() * devicePixelRatio();
|
||||
int scroll_step_size = verticalScrollBar()->singleStep();
|
||||
client().async_mouse_wheel(to_content_position(position), button, buttons, modifiers, step_x * scroll_step_size, step_y * scroll_step_size);
|
||||
}
|
||||
event->accept();
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue