1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-28 17:12:12 +00:00

WindowServer+LibGUI: Make menu allocation asynchronous

This was only synchronous since WindowServer managed the ID allocation.
Doing this on the client side instead allows us to make create_menu()
an asynchronous IPC call, removing a bunch of IPC stalls during
application startup.
This commit is contained in:
Andreas Kling 2021-05-17 13:26:40 +02:00
parent 52054eb922
commit baab0a5bef
4 changed files with 9 additions and 7 deletions

View file

@ -6,6 +6,7 @@
#include <AK/Debug.h>
#include <AK/HashMap.h>
#include <AK/IDAllocator.h>
#include <LibGUI/Action.h>
#include <LibGUI/ActionGroup.h>
#include <LibGUI/Menu.h>
@ -15,6 +16,8 @@
namespace GUI {
static IDAllocator s_menu_id_allocator;
static HashMap<int, Menu*>& all_menus()
{
static HashMap<int, Menu*>* map;
@ -85,7 +88,9 @@ void Menu::dismiss()
int Menu::realize_menu(RefPtr<Action> default_action)
{
unrealize_menu();
m_menu_id = WindowServerConnection::the().create_menu(m_name);
m_menu_id = s_menu_id_allocator.allocate();
WindowServerConnection::the().async_create_menu(m_menu_id, m_name);
dbgln_if(MENU_DEBUG, "GUI::Menu::realize_menu(): New menu ID: {}", m_menu_id);
VERIFY(m_menu_id > 0);