From 4534a43aae3cf37b675fbf903122e467333cfd34 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Sat, 16 Dec 2023 11:49:16 +0100 Subject: [PATCH] Ladybird/Qt: Apply to_content_position after scaling event coordinates Fixes regression introduced in b73ae80d8b1577d583235005831bc623ac00fad7 --- Ladybird/Qt/WebContentView.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Ladybird/Qt/WebContentView.cpp b/Ladybird/Qt/WebContentView.cpp index 0bb8a31ad62..61b465632a9 100644 --- a/Ladybird/Qt/WebContentView.cpp +++ b/Ladybird/Qt/WebContentView.cpp @@ -323,17 +323,17 @@ KeyCode get_keycode_from_qt_keyboard_event(QKeyEvent const& event) void WebContentView::mouseMoveEvent(QMouseEvent* event) { - Web::DevicePixelPoint position(to_content_position(Gfx::IntPoint { event->position().x(), event->position().y() }) * m_device_pixel_ratio); - Web::DevicePixelPoint screen_position(event->globalPosition().x() * m_device_pixel_ratio, event->globalPosition().y() * m_device_pixel_ratio); + Gfx::IntPoint position(event->position().x() * m_device_pixel_ratio, event->position().y() * m_device_pixel_ratio); + Gfx::IntPoint screen_position(event->globalPosition().x() * m_device_pixel_ratio, event->globalPosition().y() * m_device_pixel_ratio); auto buttons = get_buttons_from_qt_event(*event); auto modifiers = get_modifiers_from_qt_mouse_event(*event); - client().async_mouse_move(position, screen_position, 0, buttons, modifiers); + client().async_mouse_move(Web::DevicePixelPoint { to_content_position(position) }, Web::DevicePixelPoint { screen_position }, 0, buttons, modifiers); } void WebContentView::mousePressEvent(QMouseEvent* event) { - Web::DevicePixelPoint position(to_content_position(Gfx::IntPoint { event->position().x(), event->position().y() }) * m_device_pixel_ratio); - Web::DevicePixelPoint screen_position(event->globalPosition().x() * m_device_pixel_ratio, event->globalPosition().y() * m_device_pixel_ratio); + Gfx::IntPoint position(event->position().x() * m_device_pixel_ratio, event->position().y() * m_device_pixel_ratio); + Gfx::IntPoint screen_position(event->globalPosition().x() * m_device_pixel_ratio, event->globalPosition().y() * m_device_pixel_ratio); auto button = get_button_from_qt_event(*event); if (button == 0) { // We could not convert Qt buttons to something that Lagom can @@ -343,13 +343,13 @@ void WebContentView::mousePressEvent(QMouseEvent* event) } auto modifiers = get_modifiers_from_qt_mouse_event(*event); auto buttons = get_buttons_from_qt_event(*event); - client().async_mouse_down(position, screen_position, button, buttons, modifiers); + client().async_mouse_down(Web::DevicePixelPoint { to_content_position(position) }, Web::DevicePixelPoint { screen_position }, button, buttons, modifiers); } void WebContentView::mouseReleaseEvent(QMouseEvent* event) { - Web::DevicePixelPoint position(to_content_position(Gfx::IntPoint { event->position().x(), event->position().y() }) * m_device_pixel_ratio); - Web::DevicePixelPoint screen_position(event->globalPosition().x() * m_device_pixel_ratio, event->globalPosition().y() * m_device_pixel_ratio); + Gfx::IntPoint position(event->position().x() * m_device_pixel_ratio, event->position().y() * m_device_pixel_ratio); + Gfx::IntPoint screen_position(event->globalPosition().x() * m_device_pixel_ratio, event->globalPosition().y() * m_device_pixel_ratio); auto button = get_button_from_qt_event(*event); if (event->button() & Qt::MouseButton::BackButton) { @@ -368,21 +368,21 @@ void WebContentView::mouseReleaseEvent(QMouseEvent* event) } auto modifiers = get_modifiers_from_qt_mouse_event(*event); auto buttons = get_buttons_from_qt_event(*event); - client().async_mouse_up(position, screen_position, button, buttons, modifiers); + client().async_mouse_up(Web::DevicePixelPoint { to_content_position(position) }, Web::DevicePixelPoint { screen_position }, button, buttons, modifiers); } void WebContentView::wheelEvent(QWheelEvent* event) { if (!event->modifiers().testFlag(Qt::ControlModifier)) { - Web::DevicePixelPoint position(to_content_position(Gfx::IntPoint { event->position().x(), event->position().y() }) * m_device_pixel_ratio); - Web::DevicePixelPoint screen_position(event->globalPosition().x() * m_device_pixel_ratio, event->globalPosition().y() * m_device_pixel_ratio); + Gfx::IntPoint position(event->position().x() * m_device_pixel_ratio, event->position().y() * m_device_pixel_ratio); + Gfx::IntPoint screen_position(event->globalPosition().x() * m_device_pixel_ratio, event->globalPosition().y() * m_device_pixel_ratio); 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_pixels = -event->pixelDelta(); if (!num_pixels.isNull()) { - client().async_mouse_wheel(position, screen_position, button, buttons, modifiers, num_pixels.x(), num_pixels.y()); + client().async_mouse_wheel(Web::DevicePixelPoint { to_content_position(position) }, Web::DevicePixelPoint(screen_position), button, buttons, modifiers, num_pixels.x(), num_pixels.y()); } else { auto num_degrees = -event->angleDelta(); float delta_x = -num_degrees.x() / 120; @@ -390,7 +390,7 @@ void WebContentView::wheelEvent(QWheelEvent* event) auto step_x = delta_x * QApplication::wheelScrollLines() * m_device_pixel_ratio; auto step_y = delta_y * QApplication::wheelScrollLines() * m_device_pixel_ratio; int scroll_step_size = verticalScrollBar()->singleStep(); - client().async_mouse_wheel(position, screen_position, button, buttons, modifiers, step_x * scroll_step_size, step_y * scroll_step_size); + client().async_mouse_wheel(Web::DevicePixelPoint { to_content_position(position) }, Web::DevicePixelPoint(screen_position), button, buttons, modifiers, step_x * scroll_step_size, step_y * scroll_step_size); } event->accept(); return; @@ -400,8 +400,8 @@ void WebContentView::wheelEvent(QWheelEvent* event) void WebContentView::mouseDoubleClickEvent(QMouseEvent* event) { - Web::DevicePixelPoint position(to_content_position(Gfx::IntPoint { event->position().x(), event->position().y() }) * m_device_pixel_ratio); - Web::DevicePixelPoint screen_position(event->globalPosition().x() * m_device_pixel_ratio, event->globalPosition().y() * m_device_pixel_ratio); + Gfx::IntPoint position(event->position().x() * m_device_pixel_ratio, event->position().y() * m_device_pixel_ratio); + Gfx::IntPoint screen_position(event->globalPosition().x() * m_device_pixel_ratio, event->globalPosition().y() * m_device_pixel_ratio); auto button = get_button_from_qt_event(*event); if (button == 0) { // We could not convert Qt buttons to something that Lagom can @@ -411,7 +411,7 @@ void WebContentView::mouseDoubleClickEvent(QMouseEvent* event) } auto modifiers = get_modifiers_from_qt_mouse_event(*event); auto buttons = get_buttons_from_qt_event(*event); - client().async_doubleclick(position, screen_position, button, buttons, modifiers); + client().async_doubleclick(Web::DevicePixelPoint { to_content_position(position) }, Web::DevicePixelPoint { screen_position }, button, buttons, modifiers); } void WebContentView::dragEnterEvent(QDragEnterEvent* event)