diff --git a/Userland/Services/WindowServer/Menu.cpp b/Userland/Services/WindowServer/Menu.cpp index 2369e7db80..d903db27eb 100644 --- a/Userland/Services/WindowServer/Menu.cpp +++ b/Userland/Services/WindowServer/Menu.cpp @@ -658,4 +658,9 @@ void Menu::set_hovered_index(int index, bool make_input) } } +bool Menu::is_open() const +{ + return MenuManager::the().is_open(*this); +} + } diff --git a/Userland/Services/WindowServer/Menu.h b/Userland/Services/WindowServer/Menu.h index 90b0bd962c..219a55fd50 100644 --- a/Userland/Services/WindowServer/Menu.h +++ b/Userland/Services/WindowServer/Menu.h @@ -34,6 +34,8 @@ public: const ClientConnection* client() const { return m_client; } int menu_id() const { return m_menu_id; } + bool is_open() const; + u32 alt_shortcut_character() const { return m_alt_shortcut_character; } bool is_empty() const { return m_items.is_empty(); } diff --git a/Userland/Services/WindowServer/MenuManager.cpp b/Userland/Services/WindowServer/MenuManager.cpp index a094c789e2..2dc82f3c4e 100644 --- a/Userland/Services/WindowServer/MenuManager.cpp +++ b/Userland/Services/WindowServer/MenuManager.cpp @@ -291,7 +291,7 @@ void MenuManager::set_hovered_menu(Menu* menu) void MenuManager::open_menu(Menu& menu, bool as_current_menu) { - if (is_open(menu)) { + if (menu.is_open()) { if (as_current_menu || current_menu() != &menu) { // This menu is already open. If requested, or if the current // window doesn't match this one, then set it to this diff --git a/Userland/Services/WindowServer/WindowFrame.cpp b/Userland/Services/WindowServer/WindowFrame.cpp index c4c089d7e2..9d4d4fa8c3 100644 --- a/Userland/Services/WindowServer/WindowFrame.cpp +++ b/Userland/Services/WindowServer/WindowFrame.cpp @@ -293,9 +293,10 @@ void WindowFrame::paint_menubar(Gfx::Painter& painter) m_window.menubar()->for_each_menu([&](Menu& menu) { auto text_rect = menu.rect_in_window_menubar(); Color text_color = palette.window_text(); - if (MenuManager::the().is_open(menu)) + auto is_open = menu.is_open(); + if (is_open) text_rect.translate_by(1, 1); - bool paint_as_pressed = MenuManager::the().is_open(menu); + bool paint_as_pressed = is_open; bool paint_as_hovered = !paint_as_pressed && &menu == MenuManager::the().hovered_menu(); if (paint_as_pressed || paint_as_hovered) { Gfx::StylePainter::paint_button(painter, menu.rect_in_window_menubar(), palette, Gfx::ButtonStyle::Coolbar, paint_as_pressed, paint_as_hovered);