mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
Ladybird/WebView: Apply viewport scroll offset to mouse event coordinate
This commit is contained in:
parent
96170a4f24
commit
874e73e0c9
Notes:
sideshowbarker
2024-07-18 02:13:10 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/874e73e0c9 Pull-request: https://github.com/SerenityOS/serenity/pull/16583 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/linusg
2 changed files with 11 additions and 3 deletions
|
@ -337,7 +337,7 @@ void WebView::mouseMoveEvent(QMouseEvent* event)
|
|||
Gfx::IntPoint position(event->x(), event->y());
|
||||
auto buttons = get_buttons_from_qt_event(*event);
|
||||
auto modifiers = get_modifiers_from_qt_event(*event);
|
||||
m_page_client->page().handle_mousemove(position, buttons, modifiers);
|
||||
m_page_client->page().handle_mousemove(to_content(position), buttons, modifiers);
|
||||
}
|
||||
|
||||
void WebView::mousePressEvent(QMouseEvent* event)
|
||||
|
@ -345,7 +345,7 @@ void WebView::mousePressEvent(QMouseEvent* event)
|
|||
Gfx::IntPoint position(event->x(), event->y());
|
||||
auto button = get_button_from_qt_event(*event);
|
||||
auto modifiers = get_modifiers_from_qt_event(*event);
|
||||
m_page_client->page().handle_mousedown(position, button, modifiers);
|
||||
m_page_client->page().handle_mousedown(to_content(position), button, modifiers);
|
||||
}
|
||||
|
||||
void WebView::mouseReleaseEvent(QMouseEvent* event)
|
||||
|
@ -353,7 +353,12 @@ void WebView::mouseReleaseEvent(QMouseEvent* event)
|
|||
Gfx::IntPoint position(event->x(), event->y());
|
||||
auto button = get_button_from_qt_event(*event);
|
||||
auto modifiers = get_modifiers_from_qt_event(*event);
|
||||
m_page_client->page().handle_mouseup(position, button, modifiers);
|
||||
m_page_client->page().handle_mouseup(to_content(position), button, modifiers);
|
||||
}
|
||||
|
||||
Gfx::IntPoint WebView::to_content(Gfx::IntPoint viewport_position) const
|
||||
{
|
||||
return viewport_position.translated(horizontalScrollBar()->value(), verticalScrollBar()->value());
|
||||
}
|
||||
|
||||
void WebView::paintEvent(QPaintEvent* event)
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibGfx/Forward.h>
|
||||
#include <QAbstractScrollArea>
|
||||
|
||||
class HeadlessBrowserPageClient;
|
||||
|
@ -35,5 +36,7 @@ signals:
|
|||
void title_changed(QString);
|
||||
|
||||
private:
|
||||
Gfx::IntPoint to_content(Gfx::IntPoint) const;
|
||||
|
||||
OwnPtr<HeadlessBrowserPageClient> m_page_client;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue