diff options
author | Baitinq <manuelpalenzuelamerino@gmail.com> | 2022-11-08 02:00:24 +0100 |
---|---|---|
committer | Andrew Kaster <andrewdkaster@gmail.com> | 2022-12-25 07:58:58 -0700 |
commit | 982174706b754e7cd26625beeb0242da85066cd3 (patch) | |
tree | 9abc83e6a8c35f19a22b680e5a1793f8b0ff0595 /Ladybird | |
parent | ef553a4b768cb6b5a5acd0305098a2111febede6 (diff) | |
download | serenity-982174706b754e7cd26625beeb0242da85066cd3.zip |
Ladybird: Handle forward and backward mouse buttons
We now emit a new signal for backward mouse button's mouseup and forward
mouse button's mouseup which is handled by going back and forward in the
history respectively:))
Diffstat (limited to 'Ladybird')
-rw-r--r-- | Ladybird/Tab.cpp | 8 | ||||
-rw-r--r-- | Ladybird/WebContentView.cpp | 7 | ||||
-rw-r--r-- | Ladybird/WebContentView.h | 2 |
3 files changed, 17 insertions, 0 deletions
diff --git a/Ladybird/Tab.cpp b/Ladybird/Tab.cpp index b68c166bc9..d1430c0bbd 100644 --- a/Ladybird/Tab.cpp +++ b/Ladybird/Tab.cpp @@ -73,6 +73,14 @@ Tab::Tab(BrowserWindow* window) m_hover_label->hide(); }); + QObject::connect(m_view, &WebContentView::back_mouse_button, [this] { + back(); + }); + + QObject::connect(m_view, &WebContentView::forward_mouse_button, [this] { + forward(); + }); + QObject::connect(m_view, &WebContentView::load_started, [this](const URL& url) { m_location_edit->setText(url.to_string().characters()); m_history.push(url, m_title.toUtf8().data()); diff --git a/Ladybird/WebContentView.cpp b/Ladybird/WebContentView.cpp index bd13b71b05..9048950309 100644 --- a/Ladybird/WebContentView.cpp +++ b/Ladybird/WebContentView.cpp @@ -308,6 +308,13 @@ void WebContentView::mouseReleaseEvent(QMouseEvent* event) { Gfx::IntPoint position(event->position().x() / m_inverse_pixel_scaling_ratio, event->position().y() / m_inverse_pixel_scaling_ratio); auto button = get_button_from_qt_event(*event); + + if (event->button() & Qt::MouseButton::BackButton) { + emit back_mouse_button(); + } else if (event->button() & Qt::MouseButton::ForwardButton) { + emit forward_mouse_button(); + } + if (button == 0) { // We could not convert Qt buttons to something that Lagom can // recognize - don't even bother propagating this to the web engine diff --git a/Ladybird/WebContentView.h b/Ladybird/WebContentView.h index b11277af6f..b4d881f9db 100644 --- a/Ladybird/WebContentView.h +++ b/Ladybird/WebContentView.h @@ -143,6 +143,8 @@ public: signals: void link_hovered(QString, int timeout = 0); void link_unhovered(); + void back_mouse_button(); + void forward_mouse_button(); void load_started(const URL&); void title_changed(QString); void favicon_changed(QIcon); |