From 6c35aac617b60f76a2daf5dcb2ad558a162c175a Mon Sep 17 00:00:00 2001 From: thankyouverycool <66646555+thankyouverycool@users.noreply.github.com> Date: Wed, 7 Sep 2022 07:43:34 -0400 Subject: [PATCH] WindowServer: Add unadjusted position members to Menu Used to determine Menu relationships by proxy --- Userland/Services/WindowServer/Menu.cpp | 2 +- Userland/Services/WindowServer/Menu.h | 4 ++++ Userland/Services/WindowServer/WindowFrame.cpp | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Userland/Services/WindowServer/Menu.cpp b/Userland/Services/WindowServer/Menu.cpp index bb5582d333c..fc413598f97 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 f5ecbf3e05f..2da0cc6e32f 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 m_items; RefPtr m_menu_window; diff --git a/Userland/Services/WindowServer/WindowFrame.cpp b/Userland/Services/WindowServer/WindowFrame.cpp index f39a6fc4612..9c3953f406e 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);