summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthankyouverycool <66646555+thankyouverycool@users.noreply.github.com>2022-09-07 07:43:34 -0400
committerLinus Groh <mail@linusgroh.de>2022-09-08 23:21:54 +0100
commit6c35aac617b60f76a2daf5dcb2ad558a162c175a (patch)
treea272868c45abd7d221541ba7f947d7ab82dffef3
parent7c9ad6cc2f296a22202586eb8b4f7e1f0747f55e (diff)
downloadserenity-6c35aac617b60f76a2daf5dcb2ad558a162c175a.zip
WindowServer: Add unadjusted position members to Menu
Used to determine Menu relationships by proxy
-rw-r--r--Userland/Services/WindowServer/Menu.cpp2
-rw-r--r--Userland/Services/WindowServer/Menu.h4
-rw-r--r--Userland/Services/WindowServer/WindowFrame.cpp1
3 files changed, 6 insertions, 1 deletions
diff --git a/Userland/Services/WindowServer/Menu.cpp b/Userland/Services/WindowServer/Menu.cpp
index bb5582d333..fc413598f9 100644
--- a/Userland/Services/WindowServer/Menu.cpp
+++ b/Userland/Services/WindowServer/Menu.cpp
@@ -635,7 +635,7 @@ void Menu::do_popup(Gfx::IntPoint const& position, bool make_input, bool as_subm
redraw_if_theme_changed();
constexpr auto margin = 10;
- Gfx::IntPoint adjusted_pos = position;
+ Gfx::IntPoint adjusted_pos = m_unadjusted_position = position;
if (adjusted_pos.x() + window.width() > screen.rect().right() - margin) {
// Vertically translate the window by its full width, i.e. flip it at its vertical axis.
diff --git a/Userland/Services/WindowServer/Menu.h b/Userland/Services/WindowServer/Menu.h
index f5ecbf3e05..2da0cc6e32 100644
--- a/Userland/Services/WindowServer/Menu.h
+++ b/Userland/Services/WindowServer/Menu.h
@@ -74,6 +74,9 @@ public:
Gfx::IntRect rect_in_window_menubar() const { return m_rect_in_window_menubar; }
void set_rect_in_window_menubar(Gfx::IntRect const& rect) { m_rect_in_window_menubar = rect; }
+ Gfx::IntPoint unadjusted_position() const { return m_unadjusted_position; }
+ void set_unadjusted_position(Gfx::IntPoint const& position) { m_unadjusted_position = position; }
+
Window* menu_window() { return m_menu_window.ptr(); }
Window& ensure_menu_window(Gfx::IntPoint const&);
@@ -150,6 +153,7 @@ private:
String m_name;
u32 m_alt_shortcut_character { 0 };
Gfx::IntRect m_rect_in_window_menubar;
+ Gfx::IntPoint m_unadjusted_position;
NonnullOwnPtrVector<MenuItem> m_items;
RefPtr<Window> m_menu_window;
diff --git a/Userland/Services/WindowServer/WindowFrame.cpp b/Userland/Services/WindowServer/WindowFrame.cpp
index f39a6fc461..9c3953f406 100644
--- a/Userland/Services/WindowServer/WindowFrame.cpp
+++ b/Userland/Services/WindowServer/WindowFrame.cpp
@@ -892,6 +892,7 @@ void WindowFrame::open_menubar_menu(Menu& menu)
auto menubar_rect = this->menubar_rect();
MenuManager::the().close_everyone();
auto position = menu.rect_in_window_menubar().bottom_left().translated(rect().location()).translated(menubar_rect.location());
+ menu.set_unadjusted_position(position);
auto& window = menu.ensure_menu_window(position);
auto window_rect = window.rect();
auto& screen = Screen::closest_to_rect(window_rect);