mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
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:
parent
baab0a5bef
commit
7e799529b9
Notes:
sideshowbarker
2024-07-18 17:57:42 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/7e799529b9b
4 changed files with 9 additions and 7 deletions
|
@ -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()
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 };
|
||||
|
|
|
@ -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) =|
|
||||
|
|
Loading…
Reference in a new issue