Skip to content

Commit

Permalink
WindowServer: Add MenuManager helper to find closest open ancestor
Browse files Browse the repository at this point in the history
  • Loading branch information
thankyouverycool authored and awesomekling committed Aug 16, 2022
1 parent db85254 commit 4489f9d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Userland/Services/WindowServer/MenuManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,14 @@ void MenuManager::close_everyone()
clear_current_menu();
}

Menu* MenuManager::closest_open_ancestor_of(Menu const& other) const
{
for (auto& menu : m_open_menu_stack.in_reverse())
if (menu->is_menu_ancestor_of(other))
return menu.ptr();
return nullptr;
}

void MenuManager::close_everyone_not_in_lineage(Menu& menu)
{
Vector<Menu&> menus_to_close;
Expand Down
1 change: 1 addition & 0 deletions Userland/Services/WindowServer/MenuManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class MenuManager final : public Core::Object {
bool has_open_menu() const { return !m_open_menu_stack.is_empty(); }

Menu* current_menu() { return m_current_menu.ptr(); }
Menu* closest_open_ancestor_of(Menu const&) const;
void set_current_menu(Menu*);
void clear_current_menu();
void open_menu(Menu&, bool as_current_menu = true);
Expand Down

0 comments on commit 4489f9d

Please sign in to comment.