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

Userland: Update IPC calls to use proxies

This updates all existing code to use the auto-generated client
methods instead of post_message/send_sync.
This commit is contained in:
Gunnar Beutner 2021-05-03 13:33:59 +02:00 committed by Andreas Kling
parent 78803ce384
commit 5bb79ea0a7
63 changed files with 303 additions and 316 deletions

View file

@ -16,14 +16,14 @@ ClientConnection::ClientConnection()
void ClientConnection::handshake()
{
send_sync<Messages::AudioServer::Greet>();
greet();
}
void ClientConnection::enqueue(const Buffer& buffer)
{
for (;;) {
auto response = send_sync<Messages::AudioServer::EnqueueBuffer>(buffer.anonymous_buffer(), buffer.id(), buffer.sample_count());
if (response->success())
auto response = enqueue_buffer(buffer.anonymous_buffer(), buffer.id(), buffer.sample_count());
if (response.success())
break;
sleep(1);
}
@ -31,53 +31,53 @@ void ClientConnection::enqueue(const Buffer& buffer)
bool ClientConnection::try_enqueue(const Buffer& buffer)
{
auto response = send_sync<Messages::AudioServer::EnqueueBuffer>(buffer.anonymous_buffer(), buffer.id(), buffer.sample_count());
return response->success();
auto response = enqueue_buffer(buffer.anonymous_buffer(), buffer.id(), buffer.sample_count());
return response.success();
}
bool ClientConnection::get_muted()
{
return send_sync<Messages::AudioServer::GetMuted>()->muted();
return IPCProxy::get_muted().muted();
}
void ClientConnection::set_muted(bool muted)
{
send_sync<Messages::AudioServer::SetMuted>(muted);
IPCProxy::set_muted(muted);
}
int ClientConnection::get_main_mix_volume()
{
return send_sync<Messages::AudioServer::GetMainMixVolume>()->volume();
return IPCProxy::get_main_mix_volume().volume();
}
void ClientConnection::set_main_mix_volume(int volume)
{
send_sync<Messages::AudioServer::SetMainMixVolume>(volume);
IPCProxy::set_main_mix_volume(volume);
}
int ClientConnection::get_remaining_samples()
{
return send_sync<Messages::AudioServer::GetRemainingSamples>()->remaining_samples();
return IPCProxy::get_remaining_samples().remaining_samples();
}
int ClientConnection::get_played_samples()
{
return send_sync<Messages::AudioServer::GetPlayedSamples>()->played_samples();
return IPCProxy::get_played_samples().played_samples();
}
void ClientConnection::set_paused(bool paused)
{
send_sync<Messages::AudioServer::SetPaused>(paused);
IPCProxy::set_paused(paused);
}
void ClientConnection::clear_buffer(bool paused)
{
send_sync<Messages::AudioServer::ClearBuffer>(paused);
IPCProxy::clear_buffer(paused);
}
int ClientConnection::get_playing_buffer()
{
return send_sync<Messages::AudioServer::GetPlayingBuffer>()->buffer_id();
return IPCProxy::get_playing_buffer().buffer_id();
}
void ClientConnection::finished_playing_buffer(i32 buffer_id)

View file

@ -40,7 +40,7 @@ class LaunchServerConnection : public IPC::ServerConnection<LaunchClientEndpoint
public:
virtual void handshake() override
{
send_sync<Messages::LaunchServer::Greet>();
greet();
}
private:
@ -99,7 +99,7 @@ bool Launcher::seal_allowlist()
bool Launcher::open(const URL& url, const String& handler_name)
{
return connection().send_sync<Messages::LaunchServer::OpenURL>(url, handler_name)->response();
return connection().open_url(url, handler_name).response();
}
bool Launcher::open(const URL& url, const Details& details)
@ -110,12 +110,12 @@ bool Launcher::open(const URL& url, const Details& details)
Vector<String> Launcher::get_handlers_for_url(const URL& url)
{
return connection().send_sync<Messages::LaunchServer::GetHandlersForURL>(url.to_string())->handlers();
return connection().get_handlers_for_url(url.to_string()).handlers();
}
auto Launcher::get_handlers_with_details_for_url(const URL& url) -> NonnullRefPtrVector<Details>
{
auto details = connection().send_sync<Messages::LaunchServer::GetHandlersWithDetailsForURL>(url.to_string())->handlers_details();
auto details = connection().get_handlers_with_details_for_url(url.to_string()).handlers_details();
NonnullRefPtrVector<Details> handlers_with_details;
for (auto& value : details) {
handlers_with_details.append(Details::from_details_str(value));

View file

@ -186,7 +186,7 @@ void Application::tooltip_show_timer_did_fire()
Gfx::IntRect desktop_rect = Desktop::the().rect();
const int margin = 30;
Gfx::IntPoint adjusted_pos = WindowServerConnection::the().send_sync<Messages::WindowServer::GetGlobalCursorPosition>()->position();
Gfx::IntPoint adjusted_pos = WindowServerConnection::the().get_global_cursor_position().position();
adjusted_pos.translate_by(0, 18);

View file

@ -19,7 +19,7 @@ class ClipboardServerConnection : public IPC::ServerConnection<ClipboardClientEn
public:
virtual void handshake() override
{
send_sync<Messages::ClipboardServer::Greet>();
greet();
}
private:
@ -56,12 +56,12 @@ Clipboard::Clipboard()
Clipboard::DataAndType Clipboard::data_and_type() const
{
auto response = connection().send_sync<Messages::ClipboardServer::GetClipboardData>();
if (!response->data().is_valid())
auto response = connection().get_clipboard_data();
if (!response.data().is_valid())
return {};
auto data = ByteBuffer::copy(response->data().data<void>(), response->data().size());
auto type = response->mime_type();
auto metadata = response->metadata().entries();
auto data = ByteBuffer::copy(response.data().data<void>(), response.data().size());
auto type = response.mime_type();
auto metadata = response.metadata().entries();
return { data, type, metadata };
}
@ -75,7 +75,7 @@ void Clipboard::set_data(ReadonlyBytes data, const String& type, const HashMap<S
if (!data.is_empty())
memcpy(buffer.data<void>(), data.data(), data.size());
connection().send_sync<Messages::ClipboardServer::SetClipboardData>(move(buffer), type, metadata);
connection().set_clipboard_data(move(buffer), type, metadata);
}
void ClipboardServerConnection::clipboard_data_changed(String const& mime_type)

View file

@ -34,18 +34,18 @@ void Desktop::did_receive_screen_rect(Badge<WindowServerConnection>, const Gfx::
void Desktop::set_background_color(const StringView& background_color)
{
WindowServerConnection::the().post_message(Messages::WindowServer::SetBackgroundColor(background_color));
WindowServerConnection::the().async_set_background_color(background_color);
}
void Desktop::set_wallpaper_mode(const StringView& mode)
{
WindowServerConnection::the().post_message(Messages::WindowServer::SetWallpaperMode(mode));
WindowServerConnection::the().async_set_wallpaper_mode(mode);
}
bool Desktop::set_wallpaper(const StringView& path, bool save_config)
{
WindowServerConnection::the().post_message(Messages::WindowServer::AsyncSetWallpaper(path));
auto ret_val = WindowServerConnection::the().wait_for_specific_message<Messages::WindowClient::AsyncSetWallpaperFinished>()->success();
WindowServerConnection::the().async_set_wallpaper(path);
auto ret_val = WindowServerConnection::the().wait_for_specific_message<Messages::WindowClient::SetWallpaperFinished>()->success();
if (ret_val && save_config) {
RefPtr<Core::ConfigFile> config = Core::ConfigFile::get_for_app("WindowManager");
@ -59,7 +59,7 @@ bool Desktop::set_wallpaper(const StringView& path, bool save_config)
String Desktop::wallpaper() const
{
return WindowServerConnection::the().send_sync<Messages::WindowServer::GetWallpaper>()->path();
return WindowServerConnection::the().get_wallpaper().path();
}
}

View file

@ -43,7 +43,7 @@ static i32 s_next_callback_id = 1;
i32 DisplayLink::register_callback(Function<void(i32)> callback)
{
if (callbacks().is_empty())
WindowServerConnection::the().post_message(Messages::WindowServer::EnableDisplayLink());
WindowServerConnection::the().async_enable_display_link();
i32 callback_id = s_next_callback_id++;
callbacks().set(callback_id, adopt_ref(*new DisplayLinkCallback(callback_id, move(callback))));
@ -57,7 +57,7 @@ bool DisplayLink::unregister_callback(i32 callback_id)
callbacks().remove(callback_id);
if (callbacks().is_empty())
WindowServerConnection::the().post_message(Messages::WindowServer::DisableDisplayLink());
WindowServerConnection::the().async_disable_display_link();
return true;
}

View file

@ -37,12 +37,12 @@ DragOperation::Outcome DragOperation::exec()
drag_bitmap = bitmap->to_shareable_bitmap();
}
auto response = WindowServerConnection::the().send_sync<Messages::WindowServer::StartDrag>(
auto response = WindowServerConnection::the().start_drag(
m_mime_data->text(),
m_mime_data->all_data(),
drag_bitmap);
if (!response->started()) {
if (!response.started()) {
m_outcome = Outcome::Cancelled;
return m_outcome;
}

View file

@ -72,20 +72,20 @@ void Menu::realize_if_needed(const RefPtr<Action>& default_action)
void Menu::popup(const Gfx::IntPoint& screen_position, const RefPtr<Action>& default_action)
{
realize_if_needed(default_action);
WindowServerConnection::the().post_message(Messages::WindowServer::PopupMenu(m_menu_id, screen_position));
WindowServerConnection::the().async_popup_menu(m_menu_id, screen_position);
}
void Menu::dismiss()
{
if (m_menu_id == -1)
return;
WindowServerConnection::the().post_message(Messages::WindowServer::DismissMenu(m_menu_id));
WindowServerConnection::the().async_dismiss_menu(m_menu_id);
}
int Menu::realize_menu(RefPtr<Action> default_action)
{
unrealize_menu();
m_menu_id = WindowServerConnection::the().send_sync<Messages::WindowServer::CreateMenu>(m_name)->menu_id();
m_menu_id = WindowServerConnection::the().create_menu(m_name).menu_id();
dbgln_if(MENU_DEBUG, "GUI::Menu::realize_menu(): New menu ID: {}", m_menu_id);
VERIFY(m_menu_id > 0);
@ -94,14 +94,14 @@ int Menu::realize_menu(RefPtr<Action> default_action)
item.set_menu_id({}, m_menu_id);
item.set_identifier({}, i);
if (item.type() == MenuItem::Type::Separator) {
WindowServerConnection::the().send_sync<Messages::WindowServer::AddMenuSeparator>(m_menu_id);
WindowServerConnection::the().add_menu_separator(m_menu_id);
continue;
}
if (item.type() == MenuItem::Type::Submenu) {
auto& submenu = *item.submenu();
submenu.realize_if_needed(default_action);
auto icon = submenu.icon() ? submenu.icon()->to_shareable_bitmap() : Gfx::ShareableBitmap();
WindowServerConnection::the().send_sync<Messages::WindowServer::AddMenuItem>(m_menu_id, i, submenu.menu_id(), submenu.name(), true, false, false, false, "", icon, false);
WindowServerConnection::the().add_menu_item(m_menu_id, i, submenu.menu_id(), submenu.name(), true, false, false, false, "", icon, false);
continue;
}
if (item.type() == MenuItem::Type::Action) {
@ -110,7 +110,7 @@ int Menu::realize_menu(RefPtr<Action> default_action)
bool exclusive = action.group() && action.group()->is_exclusive() && action.is_checkable();
bool is_default = (default_action.ptr() == &action);
auto icon = action.icon() ? action.icon()->to_shareable_bitmap() : Gfx::ShareableBitmap();
WindowServerConnection::the().send_sync<Messages::WindowServer::AddMenuItem>(m_menu_id, i, -1, action.text(), action.is_enabled(), action.is_checkable(), action.is_checkable() ? action.is_checked() : false, is_default, shortcut_text, icon, exclusive);
WindowServerConnection::the().add_menu_item(m_menu_id, i, -1, action.text(), action.is_enabled(), action.is_checkable(), action.is_checkable() ? action.is_checked() : false, is_default, shortcut_text, icon, exclusive);
}
}
all_menus().set(m_menu_id, this);
@ -123,7 +123,7 @@ void Menu::unrealize_menu()
if (m_menu_id == -1)
return;
all_menus().remove(m_menu_id);
WindowServerConnection::the().send_sync<Messages::WindowServer::DestroyMenu>(m_menu_id);
WindowServerConnection::the().destroy_menu(m_menu_id);
m_menu_id = -1;
}

View file

@ -74,7 +74,7 @@ void MenuItem::update_window_server()
return;
auto& action = *m_action;
auto shortcut_text = action.shortcut().is_valid() ? action.shortcut().to_string() : String();
WindowServerConnection::the().send_sync<Messages::WindowServer::UpdateMenuItem>(m_menu_id, m_identifier, -1, action.text(), action.is_enabled(), action.is_checkable(), action.is_checkable() ? action.is_checked() : false, m_default, shortcut_text);
WindowServerConnection::the().update_menu_item(m_menu_id, m_identifier, -1, action.text(), action.is_enabled(), action.is_checkable(), action.is_checkable() ? action.is_checked() : false, m_default, shortcut_text);
}
void MenuItem::set_menu_id(Badge<Menu>, unsigned int menu_id)

View file

@ -30,14 +30,14 @@ Menu& Menubar::add_menu(String name)
int Menubar::realize_menubar()
{
return WindowServerConnection::the().send_sync<Messages::WindowServer::CreateMenubar>()->menubar_id();
return WindowServerConnection::the().create_menubar().menubar_id();
}
void Menubar::unrealize_menubar()
{
if (m_menubar_id == -1)
return;
WindowServerConnection::the().send_sync<Messages::WindowServer::DestroyMenubar>(m_menubar_id);
WindowServerConnection::the().destroy_menubar(m_menubar_id);
m_menubar_id = -1;
}
@ -49,7 +49,7 @@ void Menubar::notify_added_to_window(Badge<Window>)
for (auto& menu : m_menus) {
int menu_id = menu.realize_menu();
VERIFY(menu_id != -1);
WindowServerConnection::the().send_sync<Messages::WindowServer::AddMenuToMenubar>(m_menubar_id, menu_id);
WindowServerConnection::the().add_menu_to_menubar(m_menubar_id, menu_id);
}
}

View file

@ -20,7 +20,7 @@ class NotificationServerConnection : public IPC::ServerConnection<NotificationCl
public:
virtual void handshake() override
{
send_sync<Messages::NotificationServer::Greet>();
greet();
}
virtual void die() override
@ -51,7 +51,7 @@ void Notification::show()
VERIFY(!m_shown && !m_destroyed);
auto icon = m_icon ? m_icon->to_shareable_bitmap() : Gfx::ShareableBitmap();
m_connection = NotificationServerConnection::construct(this);
m_connection->send_sync<Messages::NotificationServer::ShowNotification>(m_text, m_title, icon);
m_connection->show_notification(m_text, m_title, icon);
m_shown = true;
}
@ -59,7 +59,7 @@ void Notification::close()
{
VERIFY(m_shown);
if (!m_destroyed) {
m_connection->send_sync<Messages::NotificationServer::CloseNotification>();
m_connection->close_notification();
connection_closed();
return;
}
@ -73,13 +73,13 @@ bool Notification::update()
}
if (m_text_dirty || m_title_dirty) {
m_connection->send_sync<Messages::NotificationServer::UpdateNotificationText>(m_text, m_title);
m_connection->update_notification_text(m_text, m_title);
m_text_dirty = false;
m_title_dirty = false;
}
if (m_icon_dirty) {
m_connection->send_sync<Messages::NotificationServer::UpdateNotificationIcon>(m_icon ? m_icon->to_shareable_bitmap() : Gfx::ShareableBitmap());
m_connection->update_notification_icon(m_icon ? m_icon->to_shareable_bitmap() : Gfx::ShareableBitmap());
m_icon_dirty = false;
}

View file

@ -109,7 +109,7 @@ void Window::move_to_front()
if (!is_visible())
return;
WindowServerConnection::the().send_sync<Messages::WindowServer::MoveWindowToFront>(m_window_id);
WindowServerConnection::the().move_window_to_front(m_window_id);
}
void Window::show()
@ -119,7 +119,7 @@ void Window::show()
auto* parent_window = find_parent_window();
auto response = WindowServerConnection::the().send_sync<Messages::WindowServer::CreateWindow>(
auto response = WindowServerConnection::the().create_window(
m_rect_when_windowless,
!m_moved_by_client,
m_has_alpha_channel,
@ -138,7 +138,7 @@ void Window::show()
(i32)m_window_type,
m_title_when_windowless,
parent_window ? parent_window->window_id() : 0);
m_window_id = response->window_id();
m_window_id = response.window_id();
m_visible = true;
apply_icon();
@ -178,10 +178,10 @@ void Window::hide()
{
if (!is_visible())
return;
auto response = WindowServerConnection::the().send_sync<Messages::WindowServer::DestroyWindow>(m_window_id);
auto response = WindowServerConnection::the().destroy_window(m_window_id);
server_did_destroy();
for (auto child_window_id : response->destroyed_window_ids()) {
for (auto child_window_id : response.destroyed_window_ids()) {
if (auto* window = Window::from_window_id(child_window_id)) {
window->server_did_destroy();
}
@ -205,27 +205,27 @@ void Window::set_title(String title)
m_title_when_windowless = move(title);
if (!is_visible())
return;
WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowTitle>(m_window_id, m_title_when_windowless);
WindowServerConnection::the().set_window_title(m_window_id, m_title_when_windowless);
}
String Window::title() const
{
if (!is_visible())
return m_title_when_windowless;
return WindowServerConnection::the().send_sync<Messages::WindowServer::GetWindowTitle>(m_window_id)->title();
return WindowServerConnection::the().get_window_title(m_window_id).title();
}
Gfx::IntRect Window::applet_rect_on_screen() const
{
VERIFY(m_window_type == WindowType::Applet);
return WindowServerConnection::the().send_sync<Messages::WindowServer::GetAppletRectOnScreen>(m_window_id)->rect();
return WindowServerConnection::the().get_applet_rect_on_screen(m_window_id).rect();
}
Gfx::IntRect Window::rect() const
{
if (!is_visible())
return m_rect_when_windowless;
return WindowServerConnection::the().send_sync<Messages::WindowServer::GetWindowRect>(m_window_id)->rect();
return WindowServerConnection::the().get_window_rect(m_window_id).rect();
}
void Window::set_rect(const Gfx::IntRect& a_rect)
@ -240,7 +240,7 @@ void Window::set_rect(const Gfx::IntRect& a_rect)
m_main_widget->resize(m_rect_when_windowless.size());
return;
}
auto window_rect = WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowRect>(m_window_id, a_rect)->rect();
auto window_rect = WindowServerConnection::the().set_window_rect(m_window_id, a_rect).rect();
if (m_back_store && m_back_store->size() != window_rect.size())
m_back_store = nullptr;
if (m_front_store && m_front_store->size() != window_rect.size())
@ -254,7 +254,7 @@ Gfx::IntSize Window::minimum_size() const
if (!is_visible())
return m_minimum_size_when_windowless;
return WindowServerConnection::the().send_sync<Messages::WindowServer::GetWindowMinimumSize>(m_window_id)->size();
return WindowServerConnection::the().get_window_minimum_size(m_window_id).size();
}
void Window::set_minimum_size(const Gfx::IntSize& size)
@ -263,7 +263,7 @@ void Window::set_minimum_size(const Gfx::IntSize& size)
m_minimum_size_when_windowless = size;
if (is_visible())
WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowMinimumSize>(m_window_id, size);
WindowServerConnection::the().set_window_minimum_size(m_window_id, size);
}
void Window::center_on_screen()
@ -297,10 +297,8 @@ void Window::set_window_type(WindowType window_type)
void Window::make_window_manager(unsigned event_mask)
{
GUI::WindowManagerServerConnection::the()
.post_message(Messages::WindowManagerServer::SetEventMask(event_mask));
GUI::WindowManagerServerConnection::the()
.post_message(Messages::WindowManagerServer::SetManagerWindow(m_window_id));
GUI::WindowManagerServerConnection::the().async_set_event_mask(event_mask);
GUI::WindowManagerServerConnection::the().async_set_manager_window(m_window_id);
}
void Window::set_cursor(Gfx::StandardCursor cursor)
@ -418,7 +416,7 @@ void Window::handle_multi_paint_event(MultiPaintEvent& event)
set_current_backing_store(*m_back_store, true);
if (is_visible())
WindowServerConnection::the().post_message(Messages::WindowServer::DidFinishPainting(m_window_id, rects));
WindowServerConnection::the().async_did_finish_painting(m_window_id, rects);
}
void Window::handle_key_event(KeyEvent& event)
@ -599,7 +597,7 @@ void Window::force_update()
if (!is_visible())
return;
auto rect = this->rect();
WindowServerConnection::the().post_message(Messages::WindowServer::InvalidateRect(m_window_id, { { 0, 0, rect.width(), rect.height() } }, true));
WindowServerConnection::the().async_invalidate_rect(m_window_id, { { 0, 0, rect.width(), rect.height() } }, true);
}
void Window::update(const Gfx::IntRect& a_rect)
@ -619,7 +617,7 @@ void Window::update(const Gfx::IntRect& a_rect)
auto rects = move(m_pending_paint_event_rects);
if (rects.is_empty())
return;
WindowServerConnection::the().post_message(Messages::WindowServer::InvalidateRect(m_window_id, rects, false));
WindowServerConnection::the().async_invalidate_rect(m_window_id, rects, false);
});
}
m_pending_paint_event_rects.append(a_rect);
@ -698,7 +696,7 @@ void Window::set_has_alpha_channel(bool value)
m_back_store = nullptr;
m_front_store = nullptr;
WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowHasAlphaChannel>(m_window_id, value);
WindowServerConnection::the().set_window_has_alpha_channel(m_window_id, value);
update();
}
@ -713,7 +711,7 @@ void Window::set_opacity(float opacity)
m_opacity_when_windowless = opacity;
if (!is_visible())
return;
WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowOpacity>(m_window_id, opacity);
WindowServerConnection::the().set_window_opacity(m_window_id, opacity);
}
void Window::set_alpha_hit_threshold(float threshold)
@ -727,7 +725,7 @@ void Window::set_alpha_hit_threshold(float threshold)
m_alpha_hit_threshold = threshold;
if (!is_visible())
return;
WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowAlphaHitThreshold>(m_window_id, threshold);
WindowServerConnection::the().set_window_alpha_hit_threshold(m_window_id, threshold);
}
void Window::set_hovered_widget(Widget* widget)
@ -747,7 +745,7 @@ void Window::set_hovered_widget(Widget* widget)
void Window::set_current_backing_store(WindowBackingStore& backing_store, bool flush_immediately)
{
auto& bitmap = backing_store.bitmap();
WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowBackingStore>(m_window_id, 32, bitmap.pitch(), bitmap.anon_fd(), backing_store.serial(), bitmap.has_alpha_channel(), bitmap.size(), flush_immediately);
WindowServerConnection::the().set_window_backing_store(m_window_id, 32, bitmap.pitch(), bitmap.anon_fd(), backing_store.serial(), bitmap.has_alpha_channel(), bitmap.size(), flush_immediately);
}
void Window::flip(const Vector<Gfx::IntRect, 32>& dirty_rects)
@ -832,12 +830,12 @@ void Window::apply_icon()
if (!is_visible())
return;
WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowIconBitmap>(m_window_id, m_icon->to_shareable_bitmap());
WindowServerConnection::the().set_window_icon_bitmap(m_window_id, m_icon->to_shareable_bitmap());
}
void Window::start_interactive_resize()
{
WindowServerConnection::the().post_message(Messages::WindowServer::StartWindowResize(m_window_id));
WindowServerConnection::the().async_start_window_resize(m_window_id);
}
Vector<Widget*> Window::focusable_widgets(FocusSource source) const
@ -888,7 +886,7 @@ void Window::set_fullscreen(bool fullscreen)
m_fullscreen = fullscreen;
if (!is_visible())
return;
WindowServerConnection::the().send_sync<Messages::WindowServer::SetFullscreen>(m_window_id, fullscreen);
WindowServerConnection::the().set_fullscreen(m_window_id, fullscreen);
}
void Window::set_frameless(bool frameless)
@ -898,7 +896,7 @@ void Window::set_frameless(bool frameless)
m_frameless = frameless;
if (!is_visible())
return;
WindowServerConnection::the().send_sync<Messages::WindowServer::SetFrameless>(m_window_id, frameless);
WindowServerConnection::the().set_frameless(m_window_id, frameless);
}
bool Window::is_maximized() const
@ -906,7 +904,7 @@ bool Window::is_maximized() const
if (!is_visible())
return false;
return WindowServerConnection::the().send_sync<Messages::WindowServer::IsMaximized>(m_window_id)->maximized();
return WindowServerConnection::the().is_maximized(m_window_id).maximized();
}
void Window::schedule_relayout()
@ -924,7 +922,7 @@ void Window::schedule_relayout()
void Window::refresh_system_theme()
{
WindowServerConnection::the().post_message(Messages::WindowServer::RefreshSystemTheme());
WindowServerConnection::the().async_refresh_system_theme();
}
void Window::for_each_window(Badge<WindowServerConnection>, Function<void(Window&)> callback)
@ -981,7 +979,7 @@ void Window::set_base_size(const Gfx::IntSize& base_size)
return;
m_base_size = base_size;
if (is_visible())
WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowBaseSizeAndSizeIncrement>(m_window_id, m_base_size, m_size_increment);
WindowServerConnection::the().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)
@ -990,7 +988,7 @@ void Window::set_size_increment(const Gfx::IntSize& size_increment)
return;
m_size_increment = size_increment;
if (is_visible())
WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowBaseSizeAndSizeIncrement>(m_window_id, m_base_size, m_size_increment);
WindowServerConnection::the().set_window_base_size_and_size_increment(m_window_id, m_base_size, m_size_increment);
}
void Window::set_resize_aspect_ratio(const Optional<Gfx::IntSize>& ratio)
@ -1000,7 +998,7 @@ void Window::set_resize_aspect_ratio(const Optional<Gfx::IntSize>& ratio)
m_resize_aspect_ratio = ratio;
if (is_visible())
WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowResizeAspectRatio>(m_window_id, m_resize_aspect_ratio);
WindowServerConnection::the().set_window_resize_aspect_ratio(m_window_id, m_resize_aspect_ratio);
}
void Window::did_add_widget(Badge<Widget>, Widget&)
@ -1024,7 +1022,7 @@ void Window::did_remove_widget(Badge<Widget>, Widget& widget)
void Window::set_progress(Optional<int> progress)
{
VERIFY(m_window_id);
WindowServerConnection::the().post_message(Messages::WindowServer::SetWindowProgress(m_window_id, progress));
WindowServerConnection::the().async_set_window_progress(m_window_id, progress);
}
void Window::update_cursor()
@ -1041,9 +1039,9 @@ void Window::update_cursor()
m_effective_cursor = new_cursor;
if (m_custom_cursor)
WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowCustomCursor>(m_window_id, m_custom_cursor->to_shareable_bitmap());
WindowServerConnection::the().set_window_custom_cursor(m_window_id, m_custom_cursor->to_shareable_bitmap());
else
WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowCursor>(m_window_id, (u32)m_effective_cursor);
WindowServerConnection::the().set_window_cursor(m_window_id, (u32)m_effective_cursor);
}
void Window::focus_a_widget_if_possible(FocusSource source)
@ -1078,7 +1076,7 @@ void Window::set_menubar(RefPtr<Menubar> menubar)
m_menubar = move(menubar);
if (m_window_id && m_menubar) {
m_menubar->notify_added_to_window({});
WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowMenubar>(m_window_id, m_menubar->menubar_id());
WindowServerConnection::the().set_window_menubar(m_window_id, m_menubar->menubar_id());
}
}
@ -1086,14 +1084,14 @@ bool Window::is_modified() const
{
if (!m_window_id)
return false;
return WindowServerConnection::the().send_sync<Messages::WindowServer::IsWindowModified>(m_window_id)->modified();
return WindowServerConnection::the().is_window_modified(m_window_id).modified();
}
void Window::set_modified(bool modified)
{
if (!m_window_id)
return;
WindowServerConnection::the().post_message(Messages::WindowServer::SetWindowModified(m_window_id, modified));
WindowServerConnection::the().async_set_window_modified(m_window_id, modified);
}
}

View file

@ -42,9 +42,9 @@ static void set_system_theme_from_anonymous_buffer(Core::AnonymousBuffer buffer)
void WindowServerConnection::handshake()
{
auto response = send_sync<Messages::WindowServer::Greet>();
set_system_theme_from_anonymous_buffer(response->theme_buffer());
Desktop::the().did_receive_screen_rect({}, response->screen_rect());
auto response = greet();
set_system_theme_from_anonymous_buffer(response.theme_buffer());
Desktop::the().did_receive_screen_rect({}, response.screen_rect());
}
void WindowServerConnection::update_system_theme(Core::AnonymousBuffer const& theme_buffer)
@ -293,7 +293,7 @@ void WindowServerConnection::screen_rect_changed(Gfx::IntRect const& rect)
});
}
void WindowServerConnection::async_set_wallpaper_finished(bool)
void WindowServerConnection::set_wallpaper_finished(bool)
{
// This is handled manually by Desktop::set_wallpaper().
}
@ -337,7 +337,7 @@ void WindowServerConnection::display_link_notification()
void WindowServerConnection::ping()
{
post_message(Messages::WindowServer::Pong());
async_pong();
}
}

View file

@ -48,7 +48,7 @@ private:
virtual void menu_item_left(i32, u32) override;
virtual void menu_visibility_did_change(i32, bool) override;
virtual void screen_rect_changed(Gfx::IntRect const&) override;
virtual void async_set_wallpaper_finished(bool) override;
virtual void set_wallpaper_finished(bool) override;
virtual void drag_dropped(i32, Gfx::IntPoint const&, String const&, HashMap<String, ByteBuffer> const&) override;
virtual void drag_accepted() override;
virtual void drag_cancelled() override;

View file

@ -17,13 +17,16 @@ NonnullRefPtr<T> new_client_connection(Args&&... args)
}
template<typename ClientEndpoint, typename ServerEndpoint>
class ClientConnection : public Connection<ServerEndpoint, ClientEndpoint>, public ServerEndpoint::Stub {
class ClientConnection : public Connection<ServerEndpoint, ClientEndpoint>
, public ServerEndpoint::Stub
, public ClientEndpoint::template Proxy<ServerEndpoint> {
public:
using ClientProxy = typename ClientEndpoint::Proxy;
using ServerStub = typename ServerEndpoint::Stub;
using IPCProxy = ClientEndpoint::template Proxy<ServerEndpoint>;
ClientConnection(ServerStub& stub, NonnullRefPtr<Core::LocalSocket> socket, int client_id)
: IPC::Connection<ServerEndpoint, ClientEndpoint>(stub, move(socket))
, ClientEndpoint::template Proxy<ServerEndpoint>(*this, {})
, m_client_id(client_id)
{
VERIFY(this->socket().is_connected());

View file

@ -29,7 +29,6 @@ template<typename LocalEndpoint, typename PeerEndpoint>
class Connection : public Core::Object {
public:
using LocalStub = typename LocalEndpoint::Stub;
using PeerProxy = typename PeerEndpoint::Proxy;
Connection(LocalStub& local_stub, NonnullRefPtr<Core::LocalSocket> socket)
: m_local_stub(local_stub)

View file

@ -11,13 +11,16 @@
namespace IPC {
template<typename ClientEndpoint, typename ServerEndpoint>
class ServerConnection : public IPC::Connection<ClientEndpoint, ServerEndpoint>, public ClientEndpoint::Stub {
class ServerConnection : public IPC::Connection<ClientEndpoint, ServerEndpoint>
, public ClientEndpoint::Stub
, public ServerEndpoint::template Proxy<ClientEndpoint> {
public:
using ClientStub = typename ClientEndpoint::Stub;
using ServerProxy = typename ServerEndpoint::Proxy;
using IPCProxy = ServerEndpoint::template Proxy<ClientEndpoint>;
ServerConnection(ClientStub& local_endpoint, const StringView& address)
: Connection<ClientEndpoint, ServerEndpoint>(local_endpoint, Core::LocalSocket::construct())
, ServerEndpoint::template Proxy<ClientEndpoint>(*this, {})
{
// We want to rate-limit our clients
this->socket().set_blocking(true);

View file

@ -23,7 +23,7 @@ void Client::die()
void Client::handshake()
{
send_sync<Messages::ImageDecoderServer::Greet>();
greet();
}
void Client::dummy()

View file

@ -18,12 +18,12 @@ RequestClient::RequestClient()
void RequestClient::handshake()
{
send_sync<Messages::RequestServer::Greet>();
greet();
}
bool RequestClient::is_supported_protocol(const String& protocol)
{
return send_sync<Messages::RequestServer::IsSupportedProtocol>(protocol)->supported();
return IPCProxy::is_supported_protocol(protocol).supported();
}
template<typename RequestHashMapTraits>
@ -33,29 +33,30 @@ RefPtr<Request> RequestClient::start_request(const String& method, const String&
for (auto& it : request_headers)
header_dictionary.add(it.key, it.value);
auto response = send_sync<Messages::RequestServer::StartRequest>(method, url, header_dictionary, ByteBuffer::copy(request_body));
auto request_id = response->request_id();
if (request_id < 0 || !response->response_fd().has_value())
auto response = IPCProxy::start_request(method, url, header_dictionary, ByteBuffer::copy(request_body));
auto request_id = response.request_id();
if (request_id < 0 || !response.response_fd().has_value())
return nullptr;
auto response_fd = response->response_fd().value().take_fd();
auto response_fd = response.response_fd().value().take_fd();
auto request = Request::create_from_id({}, *this, request_id);
request->set_request_fd({}, response_fd);
m_requests.set(request_id, request);
return request;
return nullptr;
}
bool RequestClient::stop_request(Badge<Request>, Request& request)
{
if (!m_requests.contains(request.id()))
return false;
return send_sync<Messages::RequestServer::StopRequest>(request.id())->success();
return IPCProxy::stop_request(request.id()).success();
}
bool RequestClient::set_certificate(Badge<Request>, Request& request, String certificate, String key)
{
if (!m_requests.contains(request.id()))
return false;
return send_sync<Messages::RequestServer::SetCertificate>(request.id(), move(certificate), move(key))->success();
return IPCProxy::set_certificate(request.id(), move(certificate), move(key)).success();
}
void RequestClient::request_finished(i32 request_id, bool success, u32 total_size)

View file

@ -17,7 +17,7 @@ WebSocketClient::WebSocketClient()
void WebSocketClient::handshake()
{
send_sync<Messages::WebSocketServer::Greet>();
greet();
}
RefPtr<WebSocket> WebSocketClient::connect(const URL& url, const String& origin, const Vector<String>& protocols, const Vector<String>& extensions, const HashMap<String, String>& request_headers)
@ -25,8 +25,8 @@ RefPtr<WebSocket> WebSocketClient::connect(const URL& url, const String& origin,
IPC::Dictionary header_dictionary;
for (auto& it : request_headers)
header_dictionary.add(it.key, it.value);
auto response = send_sync<Messages::WebSocketServer::Connect>(url, origin, protocols, extensions, header_dictionary);
auto connection_id = response->connection_id();
auto response = IPCProxy::connect(url, origin, protocols, extensions, header_dictionary);
auto connection_id = response.connection_id();
if (connection_id < 0)
return nullptr;
auto connection = WebSocket::create_from_id({}, *this, connection_id);
@ -38,28 +38,28 @@ u32 WebSocketClient::ready_state(Badge<WebSocket>, WebSocket& connection)
{
if (!m_connections.contains(connection.id()))
return (u32)WebSocket::ReadyState::Closed;
return send_sync<Messages::WebSocketServer::ReadyState>(connection.id())->ready_state();
return IPCProxy::ready_state(connection.id()).ready_state();
}
void WebSocketClient::send(Badge<WebSocket>, WebSocket& connection, ByteBuffer data, bool is_text)
{
if (!m_connections.contains(connection.id()))
return;
post_message(Messages::WebSocketServer::Send(connection.id(), is_text, move(data)));
async_send(connection.id(), is_text, move(data));
}
void WebSocketClient::close(Badge<WebSocket>, WebSocket& connection, u16 code, String message)
{
if (!m_connections.contains(connection.id()))
return;
post_message(Messages::WebSocketServer::Close(connection.id(), code, move(message)));
async_close(connection.id(), code, move(message));
}
bool WebSocketClient::set_certificate(Badge<WebSocket>, WebSocket& connection, String certificate, String key)
{
if (!m_connections.contains(connection.id()))
return false;
return send_sync<Messages::WebSocketServer::SetCertificate>(connection.id(), move(certificate), move(key))->success();
return IPCProxy::set_certificate(connection.id(), move(certificate), move(key)).success();
}
void WebSocketClient::connected(i32 connection_id)

View file

@ -20,7 +20,7 @@ Client::Client()
void Client::handshake()
{
send_sync<Messages::SymbolServer::Greet>();
greet();
}
void Client::dummy()
@ -29,16 +29,16 @@ void Client::dummy()
Optional<Symbol> Client::symbolicate(const String& path, FlatPtr address)
{
auto response = send_sync<Messages::SymbolServer::Symbolicate>(path, address);
if (!response->success())
auto response = IPCProxy::symbolicate(path, address);
if (!response.success())
return {};
return Symbol {
.address = address,
.name = response->name(),
.offset = response->offset(),
.filename = response->filename(),
.line_number = response->line()
.name = response.name(),
.offset = response.offset(),
.filename = response.filename(),
.line_number = response.line()
};
}

View file

@ -68,26 +68,26 @@ void OutOfProcessWebView::create_client()
});
};
client().post_message(Messages::WebContentServer::UpdateSystemTheme(Gfx::current_system_theme_buffer()));
client().post_message(Messages::WebContentServer::UpdateScreenRect(GUI::Desktop::the().rect()));
client().async_update_system_theme(Gfx::current_system_theme_buffer());
client().async_update_screen_rect(GUI::Desktop::the().rect());
}
void OutOfProcessWebView::load(const URL& url)
{
m_url = url;
client().post_message(Messages::WebContentServer::LoadURL(url));
client().async_load_url(url);
}
void OutOfProcessWebView::load_html(const StringView& html, const URL& url)
{
m_url = url;
client().post_message(Messages::WebContentServer::LoadHTML(html, url));
client().async_load_html(html, url);
}
void OutOfProcessWebView::load_empty_document()
{
m_url = {};
client().post_message(Messages::WebContentServer::LoadHTML("", {}));
client().async_load_html("", {});
}
void OutOfProcessWebView::paint_event(GUI::PaintEvent& event)
@ -119,7 +119,7 @@ void OutOfProcessWebView::resize_event(GUI::ResizeEvent& event)
void OutOfProcessWebView::handle_resize()
{
client().post_message(Messages::WebContentServer::SetViewportRect(Gfx::IntRect({ horizontal_scrollbar().value(), vertical_scrollbar().value() }, available_size())));
client().async_set_viewport_rect(Gfx::IntRect({ horizontal_scrollbar().value(), vertical_scrollbar().value() }, available_size()));
if (m_client_state.has_usable_bitmap) {
// NOTE: We keep the outgoing front bitmap as a backup so we have something to paint until we get a new one.
@ -128,12 +128,12 @@ void OutOfProcessWebView::handle_resize()
if (m_client_state.front_bitmap) {
m_client_state.front_bitmap = nullptr;
client().post_message(Messages::WebContentServer::RemoveBackingStore(m_client_state.front_bitmap_id));
client().async_remove_backing_store(m_client_state.front_bitmap_id);
}
if (m_client_state.back_bitmap) {
m_client_state.back_bitmap = nullptr;
client().post_message(Messages::WebContentServer::RemoveBackingStore(m_client_state.back_bitmap_id));
client().async_remove_backing_store(m_client_state.back_bitmap_id);
}
m_client_state.front_bitmap_id = -1;
@ -146,13 +146,13 @@ void OutOfProcessWebView::handle_resize()
if (auto new_bitmap = Gfx::Bitmap::create_shareable(Gfx::BitmapFormat::BGRx8888, available_size())) {
m_client_state.front_bitmap = move(new_bitmap);
m_client_state.front_bitmap_id = m_client_state.next_bitmap_id++;
client().post_message(Messages::WebContentServer::AddBackingStore(m_client_state.front_bitmap_id, m_client_state.front_bitmap->to_shareable_bitmap()));
client().async_add_backing_store(m_client_state.front_bitmap_id, m_client_state.front_bitmap->to_shareable_bitmap());
}
if (auto new_bitmap = Gfx::Bitmap::create_shareable(Gfx::BitmapFormat::BGRx8888, available_size())) {
m_client_state.back_bitmap = move(new_bitmap);
m_client_state.back_bitmap_id = m_client_state.next_bitmap_id++;
client().post_message(Messages::WebContentServer::AddBackingStore(m_client_state.back_bitmap_id, m_client_state.back_bitmap->to_shareable_bitmap()));
client().async_add_backing_store(m_client_state.back_bitmap_id, m_client_state.back_bitmap->to_shareable_bitmap());
}
request_repaint();
@ -160,39 +160,39 @@ void OutOfProcessWebView::handle_resize()
void OutOfProcessWebView::keydown_event(GUI::KeyEvent& event)
{
client().post_message(Messages::WebContentServer::KeyDown(event.key(), event.modifiers(), event.code_point()));
client().async_key_down(event.key(), event.modifiers(), event.code_point());
}
void OutOfProcessWebView::mousedown_event(GUI::MouseEvent& event)
{
client().post_message(Messages::WebContentServer::MouseDown(to_content_position(event.position()), event.button(), event.buttons(), event.modifiers()));
client().async_mouse_down(to_content_position(event.position()), event.button(), event.buttons(), event.modifiers());
}
void OutOfProcessWebView::mouseup_event(GUI::MouseEvent& event)
{
client().post_message(Messages::WebContentServer::MouseUp(to_content_position(event.position()), event.button(), event.buttons(), event.modifiers()));
client().async_mouse_up(to_content_position(event.position()), event.button(), event.buttons(), event.modifiers());
}
void OutOfProcessWebView::mousemove_event(GUI::MouseEvent& event)
{
client().post_message(Messages::WebContentServer::MouseMove(to_content_position(event.position()), event.button(), event.buttons(), event.modifiers()));
client().async_mouse_move(to_content_position(event.position()), event.button(), event.buttons(), event.modifiers());
}
void OutOfProcessWebView::mousewheel_event(GUI::MouseEvent& event)
{
client().post_message(Messages::WebContentServer::MouseWheel(to_content_position(event.position()), event.button(), event.buttons(), event.modifiers(), event.wheel_delta()));
client().async_mouse_wheel(to_content_position(event.position()), event.button(), event.buttons(), event.modifiers(), event.wheel_delta());
}
void OutOfProcessWebView::theme_change_event(GUI::ThemeChangeEvent& event)
{
GUI::AbstractScrollableWidget::theme_change_event(event);
client().post_message(Messages::WebContentServer::UpdateSystemTheme(Gfx::current_system_theme_buffer()));
client().async_update_system_theme(Gfx::current_system_theme_buffer());
request_repaint();
}
void OutOfProcessWebView::screen_rect_change_event(GUI::ScreenRectChangeEvent& event)
{
client().post_message(Messages::WebContentServer::UpdateScreenRect(event.rect()));
client().async_update_screen_rect(event.rect());
}
void OutOfProcessWebView::notify_server_did_paint(Badge<WebContentClient>, i32 bitmap_id)
@ -360,7 +360,7 @@ void OutOfProcessWebView::notify_server_did_set_cookie(Badge<WebContentClient>,
void OutOfProcessWebView::did_scroll()
{
client().post_message(Messages::WebContentServer::SetViewportRect(visible_content_rect()));
client().async_set_viewport_rect(visible_content_rect());
request_repaint();
}
@ -370,7 +370,7 @@ void OutOfProcessWebView::request_repaint()
// it won't have a back bitmap yet, so we can just skip repaint requests.
if (!m_client_state.back_bitmap)
return;
client().post_message(Messages::WebContentServer::Paint(m_client_state.back_bitmap->rect().translated(horizontal_scrollbar().value(), vertical_scrollbar().value()), m_client_state.back_bitmap_id));
client().async_paint(m_client_state.back_bitmap->rect().translated(horizontal_scrollbar().value(), vertical_scrollbar().value()), m_client_state.back_bitmap_id);
}
WebContentClient& OutOfProcessWebView::client()
@ -381,22 +381,22 @@ WebContentClient& OutOfProcessWebView::client()
void OutOfProcessWebView::debug_request(const String& request, const String& argument)
{
client().post_message(Messages::WebContentServer::DebugRequest(request, argument));
client().async_debug_request(request, argument);
}
void OutOfProcessWebView::get_source()
{
client().post_message(Messages::WebContentServer::GetSource());
client().async_get_source();
}
void OutOfProcessWebView::js_console_initialize()
{
client().post_message(Messages::WebContentServer::JSConsoleInitialize());
client().async_jsconsole_initialize();
}
void OutOfProcessWebView::js_console_input(const String& js_source)
{
client().post_message(Messages::WebContentServer::JSConsoleInput(js_source));
client().async_jsconsole_input(js_source);
}
}

View file

@ -26,7 +26,7 @@ void WebContentClient::die()
void WebContentClient::handshake()
{
send_sync<Messages::WebContentServer::Greet>();
greet();
}
void WebContentClient::did_paint(const Gfx::IntRect&, i32 bitmap_id)