summaryrefslogtreecommitdiff
path: root/Servers
diff options
context:
space:
mode:
authorShannon Booth <shannon.ml.booth@gmail.com>2020-01-18 12:13:15 +1300
committerAndreas Kling <awesomekling@gmail.com>2020-01-18 00:27:39 +0100
commitd86b20d8bd5a845acd2a2588e862a7c2778d7086 (patch)
treeed066eff4a4e422c1a580a865ae2aaa9cd969ac0 /Servers
parent22d1961c9a9f1265c123262c1f81aec0f7836256 (diff)
downloadserenity-d86b20d8bd5a845acd2a2588e862a7c2778d7086.zip
WindowServer: Add toggle_menu helper function
Diffstat (limited to 'Servers')
-rw-r--r--Servers/WindowServer/WSMenuManager.cpp9
-rw-r--r--Servers/WindowServer/WSMenuManager.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/Servers/WindowServer/WSMenuManager.cpp b/Servers/WindowServer/WSMenuManager.cpp
index ed55f4a579..0e02231066 100644
--- a/Servers/WindowServer/WSMenuManager.cpp
+++ b/Servers/WindowServer/WSMenuManager.cpp
@@ -382,6 +382,15 @@ void WSMenuManager::close_menu_and_descendants(WSMenu& menu)
close_menus(menus_to_close);
}
+void WSMenuManager::toggle_menu(WSMenu& menu)
+{
+ if (is_open(menu)) {
+ close_menu_and_descendants(menu);
+ return;
+ }
+ open_menu(menu);
+}
+
void WSMenuManager::open_menu(WSMenu& menu)
{
if (is_open(menu))
diff --git a/Servers/WindowServer/WSMenuManager.h b/Servers/WindowServer/WSMenuManager.h
index 4fd9e1d544..641eee428a 100644
--- a/Servers/WindowServer/WSMenuManager.h
+++ b/Servers/WindowServer/WSMenuManager.h
@@ -32,6 +32,7 @@ public:
WSMenu* current_menu() { return m_current_menu.ptr(); }
void set_current_menu(WSMenu*, bool is_submenu = false);
void open_menu(WSMenu&);
+ void toggle_menu(WSMenu&);
WSMenuBar* current_menubar() { return m_current_menubar.ptr(); }
void set_current_menubar(WSMenuBar*);