WindowServer+LibGUI: Make menubar allocation asynchronous

Same as with menu allocation, move menubar ID management to the client
side, removing more IPC stalls during application startup.
This commit is contained in:
Andreas Kling 2021-05-17 13:31:14 +02:00
parent baab0a5bef
commit 7e799529b9
Notes: sideshowbarker 2024-07-18 17:57:42 +09:00
4 changed files with 9 additions and 7 deletions

View file

@ -5,6 +5,7 @@
*/
#include <AK/Badge.h>
#include <AK/IDAllocator.h>
#include <LibGUI/Menu.h>
#include <LibGUI/MenuItem.h>
#include <LibGUI/Menubar.h>
@ -12,6 +13,8 @@
namespace GUI {
static IDAllocator s_menubar_id_allocator;
Menubar::Menubar()
{
}
@ -30,7 +33,9 @@ Menu& Menubar::add_menu(String name)
int Menubar::realize_menubar()
{
return WindowServerConnection::the().create_menubar();
auto menubar_id = s_menubar_id_allocator.allocate();
WindowServerConnection::the().async_create_menubar(menubar_id);
return menubar_id;
}
void Menubar::unrealize_menubar()

View file

@ -81,12 +81,10 @@ void ClientConnection::notify_about_new_screen_rect(Gfx::IntRect const& rect)
async_screen_rect_changed(rect);
}
Messages::WindowServer::CreateMenubarResponse ClientConnection::create_menubar()
void ClientConnection::create_menubar(i32 menubar_id)
{
int menubar_id = m_next_menubar_id++;
auto menubar = Menubar::create(*this, menubar_id);
m_menubars.set(menubar_id, move(menubar));
return menubar_id;
}
void ClientConnection::destroy_menubar(i32 menubar_id)

View file

@ -89,7 +89,7 @@ private:
void destroy_window(Window&, Vector<i32>& destroyed_window_ids);
virtual Messages::WindowServer::GreetResponse greet() override;
virtual Messages::WindowServer::CreateMenubarResponse create_menubar() override;
virtual void create_menubar(i32) override;
virtual void destroy_menubar(i32) override;
virtual void create_menu(i32, String const&) override;
virtual void destroy_menu(i32) override;
@ -160,7 +160,6 @@ private:
RefPtr<Core::Timer> m_ping_timer;
int m_next_menubar_id { 10000 };
int m_next_window_id { 1982 };
bool m_has_display_link { false };

View file

@ -2,7 +2,7 @@ endpoint WindowServer
{
greet() => (Gfx::IntRect screen_rect, Core::AnonymousBuffer theme_buffer)
create_menubar() => (i32 menubar_id)
create_menubar(i32 menubar_id) =|
destroy_menubar(i32 menubar_id) =|
create_menu(i32 menu_id, [UTF8] String menu_title) =|