From 1aa56f0129fa6ec0c3520081a5bdac815d51a0da Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 3 May 2021 21:36:36 +0200 Subject: [PATCH] WindowServer+LibGUI: Make much of window construction asynchronous Most of the IPC that happens between clients and WindowServer when creating and configuring windows can be asynchronous. This further reduces the amount of ping-ponging played during application startup. --- Userland/Libraries/LibGUI/Window.cpp | 22 +++++++++---------- .../Services/WindowServer/WindowServer.ipc | 20 ++++++++--------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Userland/Libraries/LibGUI/Window.cpp b/Userland/Libraries/LibGUI/Window.cpp index cf99a6a9b8..6b27eb2ad8 100644 --- a/Userland/Libraries/LibGUI/Window.cpp +++ b/Userland/Libraries/LibGUI/Window.cpp @@ -204,7 +204,7 @@ void Window::set_title(String title) m_title_when_windowless = move(title); if (!is_visible()) return; - WindowServerConnection::the().set_window_title(m_window_id, m_title_when_windowless); + WindowServerConnection::the().async_set_window_title(m_window_id, m_title_when_windowless); } String Window::title() const @@ -262,7 +262,7 @@ void Window::set_minimum_size(const Gfx::IntSize& size) m_minimum_size_when_windowless = size; if (is_visible()) - WindowServerConnection::the().set_window_minimum_size(m_window_id, size); + WindowServerConnection::the().async_set_window_minimum_size(m_window_id, size); } void Window::center_on_screen() @@ -695,7 +695,7 @@ void Window::set_has_alpha_channel(bool value) m_back_store = nullptr; m_front_store = nullptr; - WindowServerConnection::the().set_window_has_alpha_channel(m_window_id, value); + WindowServerConnection::the().async_set_window_has_alpha_channel(m_window_id, value); update(); } @@ -710,7 +710,7 @@ void Window::set_opacity(float opacity) m_opacity_when_windowless = opacity; if (!is_visible()) return; - WindowServerConnection::the().set_window_opacity(m_window_id, opacity); + WindowServerConnection::the().async_set_window_opacity(m_window_id, opacity); } void Window::set_alpha_hit_threshold(float threshold) @@ -724,7 +724,7 @@ void Window::set_alpha_hit_threshold(float threshold) m_alpha_hit_threshold = threshold; if (!is_visible()) return; - WindowServerConnection::the().set_window_alpha_hit_threshold(m_window_id, threshold); + WindowServerConnection::the().async_set_window_alpha_hit_threshold(m_window_id, threshold); } void Window::set_hovered_widget(Widget* widget) @@ -829,7 +829,7 @@ void Window::apply_icon() if (!is_visible()) return; - WindowServerConnection::the().set_window_icon_bitmap(m_window_id, m_icon->to_shareable_bitmap()); + WindowServerConnection::the().async_set_window_icon_bitmap(m_window_id, m_icon->to_shareable_bitmap()); } void Window::start_interactive_resize() @@ -978,7 +978,7 @@ void Window::set_base_size(const Gfx::IntSize& base_size) return; m_base_size = base_size; if (is_visible()) - WindowServerConnection::the().set_window_base_size_and_size_increment(m_window_id, m_base_size, m_size_increment); + WindowServerConnection::the().async_set_window_base_size_and_size_increment(m_window_id, m_base_size, m_size_increment); } void Window::set_size_increment(const Gfx::IntSize& size_increment) @@ -987,7 +987,7 @@ void Window::set_size_increment(const Gfx::IntSize& size_increment) return; m_size_increment = size_increment; if (is_visible()) - WindowServerConnection::the().set_window_base_size_and_size_increment(m_window_id, m_base_size, m_size_increment); + WindowServerConnection::the().async_set_window_base_size_and_size_increment(m_window_id, m_base_size, m_size_increment); } void Window::set_resize_aspect_ratio(const Optional& ratio) @@ -997,7 +997,7 @@ void Window::set_resize_aspect_ratio(const Optional& ratio) m_resize_aspect_ratio = ratio; if (is_visible()) - WindowServerConnection::the().set_window_resize_aspect_ratio(m_window_id, m_resize_aspect_ratio); + WindowServerConnection::the().async_set_window_resize_aspect_ratio(m_window_id, m_resize_aspect_ratio); } void Window::did_add_widget(Badge, Widget&) @@ -1038,9 +1038,9 @@ void Window::update_cursor() m_effective_cursor = new_cursor; if (m_custom_cursor) - WindowServerConnection::the().set_window_custom_cursor(m_window_id, m_custom_cursor->to_shareable_bitmap()); + WindowServerConnection::the().async_set_window_custom_cursor(m_window_id, m_custom_cursor->to_shareable_bitmap()); else - WindowServerConnection::the().set_window_cursor(m_window_id, (u32)m_effective_cursor); + WindowServerConnection::the().async_set_window_cursor(m_window_id, (u32)m_effective_cursor); } void Window::focus_a_widget_if_possible(FocusSource source) diff --git a/Userland/Services/WindowServer/WindowServer.ipc b/Userland/Services/WindowServer/WindowServer.ipc index 4a68ed6c71..aa7da699fc 100644 --- a/Userland/Services/WindowServer/WindowServer.ipc +++ b/Userland/Services/WindowServer/WindowServer.ipc @@ -51,7 +51,7 @@ endpoint WindowServer set_window_menubar(i32 window_id, i32 menubar_id) =| - set_window_title(i32 window_id, [UTF8] String title) => () + set_window_title(i32 window_id, [UTF8] String title) =| get_window_title(i32 window_id) => ([UTF8] String title) set_window_progress(i32 window_id, Optional progress) =| @@ -62,7 +62,7 @@ endpoint WindowServer set_window_rect(i32 window_id, Gfx::IntRect rect) => (Gfx::IntRect rect) get_window_rect(i32 window_id) => (Gfx::IntRect rect) - set_window_minimum_size(i32 window_id, Gfx::IntSize size) => () + set_window_minimum_size(i32 window_id, Gfx::IntSize size) =| get_window_minimum_size(i32 window_id) => (Gfx::IntSize size) get_applet_rect_on_screen(i32 window_id) => (Gfx::IntRect rect) @@ -75,13 +75,13 @@ endpoint WindowServer did_finish_painting(i32 window_id, Vector rects) =| set_global_cursor_tracking(i32 window_id, bool enabled) => () - set_window_opacity(i32 window_id, float opacity) => () + set_window_opacity(i32 window_id, float opacity) =| - set_window_alpha_hit_threshold(i32 window_id, float threshold) => () + set_window_alpha_hit_threshold(i32 window_id, float threshold) =| set_window_backing_store(i32 window_id, i32 bpp, i32 pitch, IPC::File anon_file, i32 serial, bool has_alpha_channel, Gfx::IntSize size, bool flush_immediately) => () - set_window_has_alpha_channel(i32 window_id, bool has_alpha_channel) => () + set_window_has_alpha_channel(i32 window_id, bool has_alpha_channel) =| move_window_to_front(i32 window_id) => () set_fullscreen(i32 window_id, bool fullscreen) => () set_frameless(i32 window_id, bool frameless) => () @@ -94,11 +94,11 @@ endpoint WindowServer set_wallpaper_mode(String mode) => () set_resolution(Gfx::IntSize resolution, int scale_factor) => (bool success, Gfx::IntSize resolution, int scale_factor) - set_window_icon_bitmap(i32 window_id, Gfx::ShareableBitmap icon) => () + set_window_icon_bitmap(i32 window_id, Gfx::ShareableBitmap icon) =| get_wallpaper() => (String path) - set_window_cursor(i32 window_id, i32 cursor_type) => () - set_window_custom_cursor(i32 window_id, Gfx::ShareableBitmap cursor) => () + set_window_cursor(i32 window_id, i32 cursor_type) =| + set_window_custom_cursor(i32 window_id, Gfx::ShareableBitmap cursor) =| start_drag([UTF8] String text, HashMap mime_data, Gfx::ShareableBitmap drag_bitmap) => (bool started) @@ -106,8 +106,8 @@ endpoint WindowServer get_system_theme() => ([UTF8] String theme_name) refresh_system_theme() =| - set_window_base_size_and_size_increment(i32 window_id, Gfx::IntSize base_size, Gfx::IntSize size_increment) => () - set_window_resize_aspect_ratio(i32 window_id, Optional resize_aspect_ratio) => () + set_window_base_size_and_size_increment(i32 window_id, Gfx::IntSize base_size, Gfx::IntSize size_increment) =| + set_window_resize_aspect_ratio(i32 window_id, Optional resize_aspect_ratio) =| enable_display_link() =| disable_display_link() =|