From 3b5766d0781eff85f28d5add16222b61827939b2 Mon Sep 17 00:00:00 2001 From: Karol Kosek Date: Fri, 5 Aug 2022 00:53:44 +0200 Subject: Browser: Show bookmark and history page lists under the their buttons Previously they were showing right under the cursor. --- Userland/Applications/Browser/BookmarksBarWidget.cpp | 8 +++----- Userland/Applications/Browser/Tab.cpp | 8 ++++---- 2 files changed, 7 insertions(+), 9 deletions(-) (limited to 'Userland') diff --git a/Userland/Applications/Browser/BookmarksBarWidget.cpp b/Userland/Applications/Browser/BookmarksBarWidget.cpp index 4bb0d7dfcd..958720a02f 100644 --- a/Userland/Applications/Browser/BookmarksBarWidget.cpp +++ b/Userland/Applications/Browser/BookmarksBarWidget.cpp @@ -111,17 +111,14 @@ BookmarksBarWidget::BookmarksBarWidget(String const& bookmarks_file, bool enable m_additional = GUI::Button::construct(); m_additional->set_tooltip("Show hidden bookmarks"); + m_additional->set_menu(m_additional_menu); + m_additional->set_menu_position(GUI::Button::MenuPosition::BottomLeft); auto bitmap_or_error = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/overflow-menu.png"sv); if (!bitmap_or_error.is_error()) m_additional->set_icon(bitmap_or_error.release_value()); m_additional->set_button_style(Gfx::ButtonStyle::Coolbar); m_additional->set_fixed_size(22, 20); m_additional->set_focus_policy(GUI::FocusPolicy::TabFocus); - m_additional->on_click = [this](auto) { - if (m_additional_menu) { - m_additional_menu->popup(m_additional->relative_position().translated(relative_position().translated(m_additional->window()->position()))); - } - }; m_separator = GUI::Widget::construct(); @@ -254,6 +251,7 @@ void BookmarksBarWidget::update_content_size() // hide all items > m_last_visible_index and create new bookmarks menu for them m_additional->set_visible(true); m_additional_menu = GUI::Menu::construct("Additional Bookmarks"); + m_additional->set_menu(m_additional_menu); for (size_t i = m_last_visible_index; i < m_bookmarks.size(); ++i) { auto& bookmark = m_bookmarks.at(i); bookmark.set_visible(false); diff --git a/Userland/Applications/Browser/Tab.cpp b/Userland/Applications/Browser/Tab.cpp index 12d5bc3bcc..6ef827ab73 100644 --- a/Userland/Applications/Browser/Tab.cpp +++ b/Userland/Applications/Browser/Tab.cpp @@ -127,7 +127,7 @@ Tab::Tab(BrowserWindow& window) m_web_content_view->set_proxy_mappings(g_proxies, g_proxy_mappings); auto& go_back_button = toolbar.add_action(window.go_back_action()); - go_back_button.on_context_menu_request = [this](auto& context_menu_event) { + go_back_button.on_context_menu_request = [&](auto&) { if (!m_history.can_go_back()) return; int i = 0; @@ -136,11 +136,11 @@ Tab::Tab(BrowserWindow& window) i++; m_go_back_context_menu->add_action(GUI::Action::create(url.to_string(), g_icon_bag.filetype_html, [this, i](auto&) { go_back(i); })); } - m_go_back_context_menu->popup(context_menu_event.screen_position()); + m_go_back_context_menu->popup(go_back_button.screen_relative_rect().bottom_left()); }; auto& go_forward_button = toolbar.add_action(window.go_forward_action()); - go_forward_button.on_context_menu_request = [this](auto& context_menu_event) { + go_forward_button.on_context_menu_request = [&](auto&) { if (!m_history.can_go_forward()) return; int i = 0; @@ -149,7 +149,7 @@ Tab::Tab(BrowserWindow& window) i++; m_go_forward_context_menu->add_action(GUI::Action::create(url.to_string(), g_icon_bag.filetype_html, [this, i](auto&) { go_forward(i); })); } - m_go_forward_context_menu->popup(context_menu_event.screen_position()); + m_go_forward_context_menu->popup(go_forward_button.screen_relative_rect().bottom_left()); }; auto& go_home_button = toolbar.add_action(window.go_home_action()); -- cgit v1.2.3