1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 18:18:12 +00:00

Userland: Change IPC funcs to use plain arguments instead of a struct

Instead of having a single overloaded handle method each method gets
its own unique method name now.
This commit is contained in:
Gunnar Beutner 2021-05-02 19:54:34 +02:00 committed by Andreas Kling
parent d47f15ab8b
commit 065040872f
50 changed files with 897 additions and 839 deletions

View file

@ -47,77 +47,77 @@ void WindowServerConnection::handshake()
Desktop::the().did_receive_screen_rect({}, response->screen_rect());
}
void WindowServerConnection::handle(const Messages::WindowClient::UpdateSystemTheme& message)
void WindowServerConnection::update_system_theme(Core::AnonymousBuffer const& theme_buffer)
{
set_system_theme_from_anonymous_buffer(message.theme_buffer());
set_system_theme_from_anonymous_buffer(theme_buffer);
Window::update_all_windows({});
Window::for_each_window({}, [](auto& window) {
Core::EventLoop::current().post_event(window, make<ThemeChangeEvent>());
});
}
void WindowServerConnection::handle(const Messages::WindowClient::Paint& message)
void WindowServerConnection::paint(i32 window_id, Gfx::IntSize const& window_size, Vector<Gfx::IntRect> const& rects)
{
if (auto* window = Window::from_window_id(message.window_id()))
Core::EventLoop::current().post_event(*window, make<MultiPaintEvent>(message.rects(), message.window_size()));
if (auto* window = Window::from_window_id(window_id))
Core::EventLoop::current().post_event(*window, make<MultiPaintEvent>(rects, window_size));
}
void WindowServerConnection::handle(const Messages::WindowClient::WindowResized& message)
void WindowServerConnection::window_resized(i32 window_id, Gfx::IntRect const& new_rect)
{
if (auto* window = Window::from_window_id(message.window_id())) {
Core::EventLoop::current().post_event(*window, make<ResizeEvent>(message.new_rect().size()));
if (auto* window = Window::from_window_id(window_id)) {
Core::EventLoop::current().post_event(*window, make<ResizeEvent>(new_rect.size()));
}
}
void WindowServerConnection::handle(const Messages::WindowClient::WindowActivated& message)
void WindowServerConnection::window_activated(i32 window_id)
{
if (auto* window = Window::from_window_id(message.window_id()))
if (auto* window = Window::from_window_id(window_id))
Core::EventLoop::current().post_event(*window, make<Event>(Event::WindowBecameActive));
}
void WindowServerConnection::handle(const Messages::WindowClient::WindowDeactivated& message)
void WindowServerConnection::window_deactivated(i32 window_id)
{
if (auto* window = Window::from_window_id(message.window_id()))
if (auto* window = Window::from_window_id(window_id))
Core::EventLoop::current().post_event(*window, make<Event>(Event::WindowBecameInactive));
}
void WindowServerConnection::handle(const Messages::WindowClient::WindowInputEntered& message)
void WindowServerConnection::window_input_entered(i32 window_id)
{
if (auto* window = Window::from_window_id(message.window_id()))
if (auto* window = Window::from_window_id(window_id))
Core::EventLoop::current().post_event(*window, make<Event>(Event::WindowInputEntered));
}
void WindowServerConnection::handle(const Messages::WindowClient::WindowInputLeft& message)
void WindowServerConnection::window_input_left(i32 window_id)
{
if (auto* window = Window::from_window_id(message.window_id()))
if (auto* window = Window::from_window_id(window_id))
Core::EventLoop::current().post_event(*window, make<Event>(Event::WindowInputLeft));
}
void WindowServerConnection::handle(const Messages::WindowClient::WindowCloseRequest& message)
void WindowServerConnection::window_close_request(i32 window_id)
{
if (auto* window = Window::from_window_id(message.window_id()))
if (auto* window = Window::from_window_id(window_id))
Core::EventLoop::current().post_event(*window, make<Event>(Event::WindowCloseRequest));
}
void WindowServerConnection::handle(const Messages::WindowClient::WindowEntered& message)
void WindowServerConnection::window_entered(i32 window_id)
{
if (auto* window = Window::from_window_id(message.window_id()))
if (auto* window = Window::from_window_id(window_id))
Core::EventLoop::current().post_event(*window, make<Event>(Event::WindowEntered));
}
void WindowServerConnection::handle(const Messages::WindowClient::WindowLeft& message)
void WindowServerConnection::window_left(i32 window_id)
{
if (auto* window = Window::from_window_id(message.window_id()))
if (auto* window = Window::from_window_id(window_id))
Core::EventLoop::current().post_event(*window, make<Event>(Event::WindowLeft));
}
void WindowServerConnection::handle(const Messages::WindowClient::KeyDown& message)
void WindowServerConnection::key_down(i32 window_id, u32 code_point, u32 key, u32 modifiers, u32 scancode)
{
auto* window = Window::from_window_id(message.window_id());
auto* window = Window::from_window_id(window_id);
if (!window)
return;
auto key_event = make<KeyEvent>(Event::KeyDown, (KeyCode)message.key(), message.modifiers(), message.code_point(), message.scancode());
auto key_event = make<KeyEvent>(Event::KeyDown, (KeyCode)key, modifiers, code_point, scancode);
Action* action = nullptr;
dbgln_if(KEYBOARD_SHORTCUTS_DEBUG, "Looking up action for {}", key_event->to_string());
@ -151,7 +151,7 @@ void WindowServerConnection::handle(const Messages::WindowClient::KeyDown& messa
}
bool focused_widget_accepts_emoji_input = window->focused_widget() && window->focused_widget()->accepts_emoji_input();
if (focused_widget_accepts_emoji_input && (message.modifiers() == (Mod_Ctrl | Mod_Alt)) && message.key() == Key_Space) {
if (focused_widget_accepts_emoji_input && (modifiers == (Mod_Ctrl | Mod_Alt)) && key == Key_Space) {
auto emoji_input_dialog = EmojiInputDialog::construct(window);
if (emoji_input_dialog->exec() != EmojiInputDialog::ExecOK)
return;
@ -159,21 +159,21 @@ void WindowServerConnection::handle(const Messages::WindowClient::KeyDown& messa
key_event->m_modifiers = 0;
Utf8View m_utf8_view(emoji_input_dialog->selected_emoji_text().characters());
u32 code_point = *m_utf8_view.begin();
u32 emoji_code_point = *m_utf8_view.begin();
key_event->m_code_point = code_point;
key_event->m_code_point = emoji_code_point;
}
Core::EventLoop::current().post_event(*window, move(key_event));
}
void WindowServerConnection::handle(const Messages::WindowClient::KeyUp& message)
void WindowServerConnection::key_up(i32 window_id, u32 code_point, u32 key, u32 modifiers, u32 scancode)
{
auto* window = Window::from_window_id(message.window_id());
auto* window = Window::from_window_id(window_id);
if (!window)
return;
auto key_event = make<KeyEvent>(Event::KeyUp, (KeyCode)message.key(), message.modifiers(), message.code_point(), message.scancode());
auto key_event = make<KeyEvent>(Event::KeyUp, (KeyCode)key, modifiers, code_point, scancode);
Core::EventLoop::current().post_event(*window, move(key_event));
}
@ -198,69 +198,69 @@ static MouseButton to_gmousebutton(u32 button)
}
}
void WindowServerConnection::handle(const Messages::WindowClient::MouseDown& message)
void WindowServerConnection::mouse_down(i32 window_id, Gfx::IntPoint const& mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta)
{
if (auto* window = Window::from_window_id(message.window_id()))
Core::EventLoop::current().post_event(*window, make<MouseEvent>(Event::MouseDown, message.mouse_position(), message.buttons(), to_gmousebutton(message.button()), message.modifiers(), message.wheel_delta()));
if (auto* window = Window::from_window_id(window_id))
Core::EventLoop::current().post_event(*window, make<MouseEvent>(Event::MouseDown, mouse_position, buttons, to_gmousebutton(button), modifiers, wheel_delta));
}
void WindowServerConnection::handle(const Messages::WindowClient::MouseUp& message)
void WindowServerConnection::mouse_up(i32 window_id, Gfx::IntPoint const& mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta)
{
if (auto* window = Window::from_window_id(message.window_id()))
Core::EventLoop::current().post_event(*window, make<MouseEvent>(Event::MouseUp, message.mouse_position(), message.buttons(), to_gmousebutton(message.button()), message.modifiers(), message.wheel_delta()));
if (auto* window = Window::from_window_id(window_id))
Core::EventLoop::current().post_event(*window, make<MouseEvent>(Event::MouseUp, mouse_position, buttons, to_gmousebutton(button), modifiers, wheel_delta));
}
void WindowServerConnection::handle(const Messages::WindowClient::MouseMove& message)
void WindowServerConnection::mouse_move(i32 window_id, Gfx::IntPoint const& mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta, bool is_drag, Vector<String> const& mime_types)
{
if (auto* window = Window::from_window_id(message.window_id())) {
if (message.is_drag())
Core::EventLoop::current().post_event(*window, make<DragEvent>(Event::DragMove, message.mouse_position(), message.mime_types()));
if (auto* window = Window::from_window_id(window_id)) {
if (is_drag)
Core::EventLoop::current().post_event(*window, make<DragEvent>(Event::DragMove, mouse_position, mime_types));
else
Core::EventLoop::current().post_event(*window, make<MouseEvent>(Event::MouseMove, message.mouse_position(), message.buttons(), to_gmousebutton(message.button()), message.modifiers(), message.wheel_delta()));
Core::EventLoop::current().post_event(*window, make<MouseEvent>(Event::MouseMove, mouse_position, buttons, to_gmousebutton(button), modifiers, wheel_delta));
}
}
void WindowServerConnection::handle(const Messages::WindowClient::MouseDoubleClick& message)
void WindowServerConnection::mouse_double_click(i32 window_id, Gfx::IntPoint const& mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta)
{
if (auto* window = Window::from_window_id(message.window_id()))
Core::EventLoop::current().post_event(*window, make<MouseEvent>(Event::MouseDoubleClick, message.mouse_position(), message.buttons(), to_gmousebutton(message.button()), message.modifiers(), message.wheel_delta()));
if (auto* window = Window::from_window_id(window_id))
Core::EventLoop::current().post_event(*window, make<MouseEvent>(Event::MouseDoubleClick, mouse_position, buttons, to_gmousebutton(button), modifiers, wheel_delta));
}
void WindowServerConnection::handle(const Messages::WindowClient::MouseWheel& message)
void WindowServerConnection::mouse_wheel(i32 window_id, Gfx::IntPoint const& mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta)
{
if (auto* window = Window::from_window_id(message.window_id()))
Core::EventLoop::current().post_event(*window, make<MouseEvent>(Event::MouseWheel, message.mouse_position(), message.buttons(), to_gmousebutton(message.button()), message.modifiers(), message.wheel_delta()));
if (auto* window = Window::from_window_id(window_id))
Core::EventLoop::current().post_event(*window, make<MouseEvent>(Event::MouseWheel, mouse_position, buttons, to_gmousebutton(button), modifiers, wheel_delta));
}
void WindowServerConnection::handle(const Messages::WindowClient::MenuVisibilityDidChange& message)
void WindowServerConnection::menu_visibility_did_change(i32 menu_id, bool visible)
{
auto* menu = Menu::from_menu_id(message.menu_id());
auto* menu = Menu::from_menu_id(menu_id);
if (!menu) {
dbgln("EventLoop received visibility change event for invalid menu ID {}", message.menu_id());
dbgln("EventLoop received visibility change event for invalid menu ID {}", menu_id);
return;
}
menu->visibility_did_change({}, message.visible());
menu->visibility_did_change({}, visible);
}
void WindowServerConnection::handle(const Messages::WindowClient::MenuItemActivated& message)
void WindowServerConnection::menu_item_activated(i32 menu_id, u32 identifier)
{
auto* menu = Menu::from_menu_id(message.menu_id());
auto* menu = Menu::from_menu_id(menu_id);
if (!menu) {
dbgln("EventLoop received event for invalid menu ID {}", message.menu_id());
dbgln("EventLoop received event for invalid menu ID {}", menu_id);
return;
}
if (auto* action = menu->action_at(message.identifier()))
if (auto* action = menu->action_at(identifier))
action->activate(menu);
}
void WindowServerConnection::handle(Messages::WindowClient::MenuItemEntered const& message)
void WindowServerConnection::menu_item_entered(i32 menu_id, u32 identifier)
{
auto* menu = Menu::from_menu_id(message.menu_id());
auto* menu = Menu::from_menu_id(menu_id);
if (!menu) {
dbgln("WindowServerConnection received MenuItemEntered for invalid menu ID {}", message.menu_id());
dbgln("WindowServerConnection received MenuItemEntered for invalid menu ID {}", menu_id);
return;
}
auto* action = menu->action_at(message.identifier());
auto* action = menu->action_at(identifier);
if (!action)
return;
auto* app = Application::the();
@ -269,14 +269,14 @@ void WindowServerConnection::handle(Messages::WindowClient::MenuItemEntered cons
Core::EventLoop::current().post_event(*app, make<ActionEvent>(GUI::Event::ActionEnter, *action));
}
void WindowServerConnection::handle(Messages::WindowClient::MenuItemLeft const& message)
void WindowServerConnection::menu_item_left(i32 menu_id, u32 identifier)
{
auto* menu = Menu::from_menu_id(message.menu_id());
auto* menu = Menu::from_menu_id(menu_id);
if (!menu) {
dbgln("WindowServerConnection received MenuItemLeft for invalid menu ID {}", message.menu_id());
dbgln("WindowServerConnection received MenuItemLeft for invalid menu ID {}", menu_id);
return;
}
auto* action = menu->action_at(message.identifier());
auto* action = menu->action_at(identifier);
if (!action)
return;
auto* app = Application::the();
@ -285,45 +285,45 @@ void WindowServerConnection::handle(Messages::WindowClient::MenuItemLeft const&
Core::EventLoop::current().post_event(*app, make<ActionEvent>(GUI::Event::ActionLeave, *action));
}
void WindowServerConnection::handle(const Messages::WindowClient::ScreenRectChanged& message)
void WindowServerConnection::screen_rect_changed(Gfx::IntRect const& rect)
{
Desktop::the().did_receive_screen_rect({}, message.rect());
Window::for_each_window({}, [message](auto& window) {
Core::EventLoop::current().post_event(window, make<ScreenRectChangeEvent>(message.rect()));
Desktop::the().did_receive_screen_rect({}, rect);
Window::for_each_window({}, [rect](auto& window) {
Core::EventLoop::current().post_event(window, make<ScreenRectChangeEvent>(rect));
});
}
void WindowServerConnection::handle(const Messages::WindowClient::AsyncSetWallpaperFinished&)
void WindowServerConnection::async_set_wallpaper_finished(bool)
{
// This is handled manually by Desktop::set_wallpaper().
}
void WindowServerConnection::handle(const Messages::WindowClient::DragDropped& message)
void WindowServerConnection::drag_dropped(i32 window_id, Gfx::IntPoint const& mouse_position, String const& text, HashMap<String, ByteBuffer> const& mime_data)
{
if (auto* window = Window::from_window_id(message.window_id())) {
auto mime_data = Core::MimeData::construct(message.mime_data());
Core::EventLoop::current().post_event(*window, make<DropEvent>(message.mouse_position(), message.text(), mime_data));
if (auto* window = Window::from_window_id(window_id)) {
auto mime_data_obj = Core::MimeData::construct(mime_data);
Core::EventLoop::current().post_event(*window, make<DropEvent>(mouse_position, text, mime_data_obj));
}
}
void WindowServerConnection::handle(const Messages::WindowClient::DragAccepted&)
void WindowServerConnection::drag_accepted()
{
DragOperation::notify_accepted({});
}
void WindowServerConnection::handle(const Messages::WindowClient::DragCancelled&)
void WindowServerConnection::drag_cancelled()
{
DragOperation::notify_cancelled({});
Application::the()->notify_drag_cancelled({});
}
void WindowServerConnection::handle(const Messages::WindowClient::WindowStateChanged& message)
void WindowServerConnection::window_state_changed(i32 window_id, bool minimized, bool occluded)
{
if (auto* window = Window::from_window_id(message.window_id()))
window->notify_state_changed({}, message.minimized(), message.occluded());
if (auto* window = Window::from_window_id(window_id))
window->notify_state_changed({}, minimized, occluded);
}
void WindowServerConnection::handle(const Messages::WindowClient::DisplayLinkNotification&)
void WindowServerConnection::display_link_notification()
{
if (m_display_link_notification_pending)
return;
@ -335,7 +335,7 @@ void WindowServerConnection::handle(const Messages::WindowClient::DisplayLinkNot
});
}
void WindowServerConnection::handle(const Messages::WindowClient::Ping&)
void WindowServerConnection::ping()
{
post_message(Messages::WindowServer::Pong());
}