mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 01:58:12 +00:00
LibWeb: Make handle_mousewheel wheel delta use pixels
This commit is contained in:
parent
7d588db6c8
commit
0facfd3257
3 changed files with 9 additions and 8 deletions
|
@ -285,10 +285,10 @@ void WebContentView::wheelEvent(QWheelEvent* event)
|
||||||
auto num_degrees = -event->angleDelta();
|
auto num_degrees = -event->angleDelta();
|
||||||
float delta_x = -num_degrees.x() / 120;
|
float delta_x = -num_degrees.x() / 120;
|
||||||
float delta_y = num_degrees.y() / 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_x = delta_x * QApplication::wheelScrollLines() * devicePixelRatio();
|
||||||
auto step_y = delta_y * 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();
|
event->accept();
|
||||||
return;
|
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)
|
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())
|
if (m_browsing_context->active_document())
|
||||||
m_browsing_context->active_document()->update_layout();
|
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();
|
auto* containing_block = paintable->containing_block();
|
||||||
while (containing_block) {
|
while (containing_block) {
|
||||||
if (containing_block->is_user_scrollable()) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
containing_block = containing_block->containing_block();
|
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 (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 (auto* page = m_browsing_context->page()) {
|
||||||
if (m_browsing_context == &page->top_level_browsing_context())
|
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:
|
case GUI::Event::Type::MouseMove:
|
||||||
client().async_mouse_move(to_content_position(event.position()), event.button(), event.buttons(), event.modifiers());
|
client().async_mouse_move(to_content_position(event.position()), event.button(), event.buttons(), event.modifiers());
|
||||||
break;
|
break;
|
||||||
case GUI::Event::Type::MouseWheel:
|
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());
|
// 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;
|
break;
|
||||||
|
}
|
||||||
case GUI::Event::Type::MouseDoubleClick:
|
case GUI::Event::Type::MouseDoubleClick:
|
||||||
client().async_doubleclick(to_content_position(event.position()), event.button(), event.buttons(), event.modifiers());
|
client().async_doubleclick(to_content_position(event.position()), event.button(), event.buttons(), event.modifiers());
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue