mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:27:43 +00:00
Ladybird: Use pixelDelta() on supported platforms for better scrolling
This commit is contained in:
parent
0facfd3257
commit
abf0c8f1a6
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 button = get_button_from_qt_event(*event);
|
||||||
auto buttons = get_buttons_from_qt_event(*event);
|
auto buttons = get_buttons_from_qt_event(*event);
|
||||||
auto modifiers = get_modifiers_from_qt_mouse_event(*event);
|
auto modifiers = get_modifiers_from_qt_mouse_event(*event);
|
||||||
auto num_degrees = -event->angleDelta();
|
|
||||||
float delta_x = -num_degrees.x() / 120;
|
auto num_pixels = -event->pixelDelta();
|
||||||
float delta_y = num_degrees.y() / 120;
|
if (!num_pixels.isNull()) {
|
||||||
auto step_x = delta_x * QApplication::wheelScrollLines() * devicePixelRatio();
|
client().async_mouse_wheel(to_content_position(position), button, buttons, modifiers, num_pixels.x(), num_pixels.y());
|
||||||
auto step_y = delta_y * QApplication::wheelScrollLines() * devicePixelRatio();
|
} else {
|
||||||
constexpr int scroll_step_size = 24;
|
auto num_degrees = -event->angleDelta();
|
||||||
client().async_mouse_wheel(to_content_position(position), button, buttons, modifiers, step_x * scroll_step_size, step_y * scroll_step_size);
|
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();
|
event->accept();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue