diff options
author | Andreas Kling <kling@serenityos.org> | 2021-05-20 21:42:31 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-20 22:12:42 +0200 |
commit | ec8363aec373bc38a642360659901b1b4f671df2 (patch) | |
tree | d7ea84f1840fdd795e29ea8f6633c6b5e8e0d114 /Userland | |
parent | 1150e9fe7987d2824ac4a63c8b7bc5d7d33c65ca (diff) | |
download | serenity-ec8363aec373bc38a642360659901b1b4f671df2.zip |
WindowServer+LibGUI: Make client/server greeting faster
Instead of doing a full IPC round-trip for the client and server to
greet each other upon connecting, the server now automatically sends
a "fast_greet" message when a client connects.
The client simply waits for that message to arrive before proceeding.
(Waiting is necessary since LibGUI relies on the palette information
included in the greeting.)
Diffstat (limited to 'Userland')
6 files changed, 15 insertions, 11 deletions
diff --git a/Userland/Libraries/LibGUI/WindowServerConnection.cpp b/Userland/Libraries/LibGUI/WindowServerConnection.cpp index 492ea7c421..d51d57d1e3 100644 --- a/Userland/Libraries/LibGUI/WindowServerConnection.cpp +++ b/Userland/Libraries/LibGUI/WindowServerConnection.cpp @@ -42,9 +42,16 @@ static void set_system_theme_from_anonymous_buffer(Core::AnonymousBuffer buffer) void WindowServerConnection::handshake() { - auto response = greet(); - set_system_theme_from_anonymous_buffer(response.theme_buffer()); - Desktop::the().did_receive_screen_rect({}, response.screen_rect()); + // NOTE: WindowServer automatically sends a "fast_greet" message to us when we connect. + // All we have to do is wait for it to arrive. This avoids a round-trip during application startup. + auto message = wait_for_specific_message<Messages::WindowClient::FastGreet>(); + set_system_theme_from_anonymous_buffer(message->theme_buffer()); + Desktop::the().did_receive_screen_rect({}, message->screen_rect()); +} + +void WindowServerConnection::fast_greet(Gfx::IntRect const&, Core::AnonymousBuffer const&) +{ + // NOTE: This message is handled in handshake(). } void WindowServerConnection::update_system_theme(Core::AnonymousBuffer const& theme_buffer) diff --git a/Userland/Libraries/LibGUI/WindowServerConnection.h b/Userland/Libraries/LibGUI/WindowServerConnection.h index 472888ac2b..38b2a3db9f 100644 --- a/Userland/Libraries/LibGUI/WindowServerConnection.h +++ b/Userland/Libraries/LibGUI/WindowServerConnection.h @@ -27,6 +27,7 @@ public: static WindowServerConnection& the(); private: + virtual void fast_greet(Gfx::IntRect const&, Core::AnonymousBuffer const&) override; virtual void paint(i32, Gfx::IntSize const&, Vector<Gfx::IntRect> const&) override; virtual void mouse_move(i32, Gfx::IntPoint const&, u32, u32, u32, i32, bool, Vector<String> const&) override; virtual void mouse_down(i32, Gfx::IntPoint const&, u32, u32, u32, i32) override; diff --git a/Userland/Services/WindowServer/ClientConnection.cpp b/Userland/Services/WindowServer/ClientConnection.cpp index 923e5f4834..0132c3a872 100644 --- a/Userland/Services/WindowServer/ClientConnection.cpp +++ b/Userland/Services/WindowServer/ClientConnection.cpp @@ -53,6 +53,8 @@ ClientConnection::ClientConnection(NonnullRefPtr<Core::LocalSocket> client_socke if (!s_connections) s_connections = new HashMap<int, NonnullRefPtr<ClientConnection>>; s_connections->set(client_id, *this); + + async_fast_greet(Screen::the().rect(), Gfx::current_system_theme_buffer()); } ClientConnection::~ClientConnection() @@ -681,11 +683,6 @@ void ClientConnection::start_window_resize(i32 window_id) WindowManager::the().start_window_resize(window, Screen::the().cursor_location(), MouseButton::Left); } -Messages::WindowServer::GreetResponse ClientConnection::greet() -{ - return { Screen::the().rect(), Gfx::current_system_theme_buffer() }; -} - Messages::WindowServer::StartDragResponse ClientConnection::start_drag(String const& text, HashMap<String, ByteBuffer> const& mime_data, Gfx::ShareableBitmap const& drag_bitmap) { auto& wm = WindowManager::the(); diff --git a/Userland/Services/WindowServer/ClientConnection.h b/Userland/Services/WindowServer/ClientConnection.h index 9b2c75ec17..46e69bed5f 100644 --- a/Userland/Services/WindowServer/ClientConnection.h +++ b/Userland/Services/WindowServer/ClientConnection.h @@ -88,7 +88,6 @@ private: void set_unresponsive(bool); void destroy_window(Window&, Vector<i32>& destroyed_window_ids); - virtual Messages::WindowServer::GreetResponse greet() override; virtual void create_menubar(i32) override; virtual void destroy_menubar(i32) override; virtual void create_menu(i32, String const&) override; diff --git a/Userland/Services/WindowServer/WindowClient.ipc b/Userland/Services/WindowServer/WindowClient.ipc index bd63d70d9b..b4dfe9548c 100644 --- a/Userland/Services/WindowServer/WindowClient.ipc +++ b/Userland/Services/WindowServer/WindowClient.ipc @@ -1,5 +1,7 @@ endpoint WindowClient { + fast_greet(Gfx::IntRect screen_rect, Core::AnonymousBuffer theme_buffer) =| + paint(i32 window_id, Gfx::IntSize window_size, Vector<Gfx::IntRect> rects) =| mouse_move(i32 window_id, Gfx::IntPoint mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta, bool is_drag, Vector<String> mime_types) =| mouse_down(i32 window_id, Gfx::IntPoint mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta) =| diff --git a/Userland/Services/WindowServer/WindowServer.ipc b/Userland/Services/WindowServer/WindowServer.ipc index 704c3338b0..bb8b70dd90 100644 --- a/Userland/Services/WindowServer/WindowServer.ipc +++ b/Userland/Services/WindowServer/WindowServer.ipc @@ -1,7 +1,5 @@ endpoint WindowServer { - greet() => (Gfx::IntRect screen_rect, Core::AnonymousBuffer theme_buffer) - create_menubar(i32 menubar_id) =| destroy_menubar(i32 menubar_id) =| |