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
Notes: sideshowbarker 2024-07-18 22:57:59 +09:00
50 changed files with 897 additions and 839 deletions

View file

@ -14,22 +14,22 @@
namespace HackStudio {
void ServerConnection::handle(const Messages::LanguageClient::AutoCompleteSuggestions& message)
void ServerConnection::auto_complete_suggestions(const Vector<GUI::AutocompleteProvider::Entry>& suggestions)
{
if (!m_current_language_client) {
dbgln("Language Server connection has no attached language client");
return;
}
m_current_language_client->provide_autocomplete_suggestions(message.suggestions());
m_current_language_client->provide_autocomplete_suggestions(suggestions);
}
void ServerConnection::handle(const Messages::LanguageClient::DeclarationLocation& message)
void ServerConnection::declaration_location(const GUI::AutocompleteProvider::ProjectLocation& location)
{
if (!m_current_language_client) {
dbgln("Language Server connection has no attached language client");
return;
}
m_current_language_client->declaration_found(message.location().file, message.location().line, message.location().column);
m_current_language_client->declaration_found(location.file, location.line, location.column);
}
void ServerConnection::die()
@ -100,9 +100,9 @@ void LanguageClient::set_active_client()
HashMap<String, NonnullOwnPtr<ServerConnectionWrapper>> ServerConnectionInstances::s_instance_for_language;
void ServerConnection::handle(const Messages::LanguageClient::DeclarationsInDocument& message)
void ServerConnection::declarations_in_document(const String& filename, const Vector<GUI::AutocompleteProvider::Declaration>& declarations)
{
ProjectDeclarations::the().set_declared_symbols(message.filename(), message.declarations());
ProjectDeclarations::the().set_declared_symbols(filename, declarations);
}
void LanguageClient::search_declaration(const String& path, size_t line, size_t column)

View file

@ -47,9 +47,9 @@ public:
virtual void die() override;
protected:
virtual void handle(const Messages::LanguageClient::AutoCompleteSuggestions&) override;
virtual void handle(const Messages::LanguageClient::DeclarationLocation&) override;
virtual void handle(const Messages::LanguageClient::DeclarationsInDocument&) override;
virtual void auto_complete_suggestions(Vector<GUI::AutocompleteProvider::Entry> const&) override;
virtual void declaration_location(GUI::AutocompleteProvider::ProjectLocation const&) override;
virtual void declarations_in_document(String const&, Vector<GUI::AutocompleteProvider::Declaration> const&) override;
void set_wrapper(ServerConnectionWrapper& wrapper) { m_wrapper = &wrapper; }
String m_project_path;

View file

@ -30,10 +30,10 @@ void ClientConnection::die()
exit(0);
}
void ClientConnection::handle(const Messages::LanguageServer::Greet& message)
void ClientConnection::greet(String const& project_root)
{
m_filedb.set_project_root(message.project_root());
if (unveil(message.project_root().characters(), "r") < 0) {
m_filedb.set_project_root(project_root);
if (unveil(project_root.characters(), "r") < 0) {
perror("unveil");
exit(1);
}
@ -43,80 +43,79 @@ void ClientConnection::handle(const Messages::LanguageServer::Greet& message)
}
}
void ClientConnection::handle(const Messages::LanguageServer::FileOpened& message)
void ClientConnection::file_opened(String const& filename, IPC::File const& file)
{
if (m_filedb.is_open(message.filename())) {
if (m_filedb.is_open(filename)) {
return;
}
m_filedb.add(message.filename(), message.file().take_fd());
m_autocomplete_engine->file_opened(message.filename());
m_filedb.add(filename, file.take_fd());
m_autocomplete_engine->file_opened(filename);
}
void ClientConnection::handle(const Messages::LanguageServer::FileEditInsertText& message)
void ClientConnection::file_edit_insert_text(String const& filename, String const& text, i32 start_line, i32 start_column)
{
dbgln_if(LANGUAGE_SERVER_DEBUG, "InsertText for file: {}", message.filename());
dbgln_if(LANGUAGE_SERVER_DEBUG, "Text: {}", message.text());
dbgln_if(LANGUAGE_SERVER_DEBUG, "[{}:{}]", message.start_line(), message.start_column());
m_filedb.on_file_edit_insert_text(message.filename(), message.text(), message.start_line(), message.start_column());
m_autocomplete_engine->on_edit(message.filename());
dbgln_if(LANGUAGE_SERVER_DEBUG, "InsertText for file: {}", filename);
dbgln_if(LANGUAGE_SERVER_DEBUG, "Text: {}", text);
dbgln_if(LANGUAGE_SERVER_DEBUG, "[{}:{}]", start_line, start_column);
m_filedb.on_file_edit_insert_text(filename, text, start_line, start_column);
m_autocomplete_engine->on_edit(filename);
}
void ClientConnection::handle(const Messages::LanguageServer::FileEditRemoveText& message)
void ClientConnection::file_edit_remove_text(String const& filename, i32 start_line, i32 start_column, i32 end_line, i32 end_column)
{
dbgln_if(LANGUAGE_SERVER_DEBUG, "RemoveText for file: {}", message.filename());
dbgln_if(LANGUAGE_SERVER_DEBUG, "[{}:{} - {}:{}]", message.start_line(), message.start_column(), message.end_line(), message.end_column());
m_filedb.on_file_edit_remove_text(message.filename(), message.start_line(), message.start_column(), message.end_line(), message.end_column());
m_autocomplete_engine->on_edit(message.filename());
dbgln_if(LANGUAGE_SERVER_DEBUG, "RemoveText for file: {}", filename);
dbgln_if(LANGUAGE_SERVER_DEBUG, "[{}:{} - {}:{}]", start_line, start_column, end_line, end_column);
m_filedb.on_file_edit_remove_text(filename, start_line, start_column, end_line, end_column);
m_autocomplete_engine->on_edit(filename);
}
void ClientConnection::handle(const Messages::LanguageServer::AutoCompleteSuggestions& message)
void ClientConnection::auto_complete_suggestions(GUI::AutocompleteProvider::ProjectLocation const& location)
{
dbgln_if(LANGUAGE_SERVER_DEBUG, "AutoCompleteSuggestions for: {} {}:{}", message.location().file, message.location().line, message.location().column);
dbgln_if(LANGUAGE_SERVER_DEBUG, "AutoCompleteSuggestions for: {} {}:{}", location.file, location.line, location.column);
auto document = m_filedb.get(message.location().file);
auto document = m_filedb.get(location.file);
if (!document) {
dbgln("file {} has not been opened", message.location().file);
dbgln("file {} has not been opened", location.file);
return;
}
GUI::TextPosition autocomplete_position = { (size_t)message.location().line, (size_t)max(message.location().column, message.location().column - 1) };
Vector<GUI::AutocompleteProvider::Entry> suggestions = m_autocomplete_engine->get_suggestions(message.location().file, autocomplete_position);
GUI::TextPosition autocomplete_position = { (size_t)location.line, (size_t)max(location.column, location.column - 1) };
Vector<GUI::AutocompleteProvider::Entry> suggestions = m_autocomplete_engine->get_suggestions(location.file, autocomplete_position);
post_message(Messages::LanguageClient::AutoCompleteSuggestions(move(suggestions)));
}
void ClientConnection::handle(const Messages::LanguageServer::SetFileContent& message)
void ClientConnection::set_file_content(String const& filename, String const& content)
{
dbgln_if(LANGUAGE_SERVER_DEBUG, "SetFileContent: {}", message.filename());
auto document = m_filedb.get(message.filename());
dbgln_if(LANGUAGE_SERVER_DEBUG, "SetFileContent: {}", filename);
auto document = m_filedb.get(filename);
if (!document) {
m_filedb.add(message.filename(), message.content());
VERIFY(m_filedb.is_open(message.filename()));
m_filedb.add(filename, content);
VERIFY(m_filedb.is_open(filename));
} else {
const auto& content = message.content();
document->set_text(content.view());
}
VERIFY(m_filedb.is_open(message.filename()));
m_autocomplete_engine->on_edit(message.filename());
VERIFY(m_filedb.is_open(filename));
m_autocomplete_engine->on_edit(filename);
}
void ClientConnection::handle(const Messages::LanguageServer::FindDeclaration& message)
void ClientConnection::find_declaration(GUI::AutocompleteProvider::ProjectLocation const& location)
{
dbgln_if(LANGUAGE_SERVER_DEBUG, "FindDeclaration: {} {}:{}", message.location().file, message.location().line, message.location().column);
auto document = m_filedb.get(message.location().file);
dbgln_if(LANGUAGE_SERVER_DEBUG, "FindDeclaration: {} {}:{}", location.file, location.line, location.column);
auto document = m_filedb.get(location.file);
if (!document) {
dbgln("file {} has not been opened", message.location().file);
dbgln("file {} has not been opened", location.file);
return;
}
GUI::TextPosition identifier_position = { (size_t)message.location().line, (size_t)message.location().column };
auto location = m_autocomplete_engine->find_declaration_of(message.location().file, identifier_position);
if (!location.has_value()) {
GUI::TextPosition identifier_position = { (size_t)location.line, (size_t)location.column };
auto decl_location = m_autocomplete_engine->find_declaration_of(location.file, identifier_position);
if (!decl_location.has_value()) {
dbgln("could not find declaration");
return;
}
dbgln_if(LANGUAGE_SERVER_DEBUG, "declaration location: {} {}:{}", location.value().file, location.value().line, location.value().column);
post_message(Messages::LanguageClient::DeclarationLocation(GUI::AutocompleteProvider::ProjectLocation { location.value().file, location.value().line, location.value().column }));
dbgln_if(LANGUAGE_SERVER_DEBUG, "declaration location: {} {}:{}", decl_location.value().file, decl_location.value().line, decl_location.value().column);
post_message(Messages::LanguageClient::DeclarationLocation(GUI::AutocompleteProvider::ProjectLocation { decl_location.value().file, decl_location.value().line, decl_location.value().column }));
}
void ClientConnection::set_declarations_of_document_callback(ClientConnection& instance, const String& filename, Vector<GUI::AutocompleteProvider::Declaration>&& declarations)

View file

@ -29,14 +29,14 @@ public:
virtual void die() override;
protected:
virtual void handle(const Messages::LanguageServer::Greet&) override;
virtual void handle(const Messages::LanguageServer::FileOpened&) override;
virtual void handle(const Messages::LanguageServer::FileEditInsertText&) override;
virtual void handle(const Messages::LanguageServer::FileEditRemoveText&) override;
virtual void handle(const Messages::LanguageServer::SetFileContent&) override;
virtual void handle(const Messages::LanguageServer::AutoCompleteSuggestions&) override;
virtual void handle(const Messages::LanguageServer::FindDeclaration&) override;
virtual void handle(const Messages::LanguageServer::SetAutoCompleteMode&) override = 0;
virtual void greet(String const&) override;
virtual void file_opened(String const&, IPC::File const&) override;
virtual void file_edit_insert_text(String const&, String const&, i32, i32) override;
virtual void file_edit_remove_text(String const&, i32, i32, i32, i32) override;
virtual void set_file_content(String const&, String const&) override;
virtual void auto_complete_suggestions(GUI::AutocompleteProvider::ProjectLocation const&) override;
virtual void find_declaration(GUI::AutocompleteProvider::ProjectLocation const&) override;
virtual void set_auto_complete_mode(String const&) override = 0;
static void set_declarations_of_document_callback(ClientConnection&, const String&, Vector<GUI::AutocompleteProvider::Declaration>&&);

View file

@ -26,10 +26,10 @@ public:
virtual ~ClientConnection() override = default;
private:
virtual void handle(const Messages::LanguageServer::SetAutoCompleteMode& message) override
virtual void set_auto_complete_mode(String const& mode) override
{
dbgln_if(CPP_LANGUAGE_SERVER_DEBUG, "SetAutoCompleteMode: {}", message.mode());
if (message.mode() == "Parser")
dbgln_if(CPP_LANGUAGE_SERVER_DEBUG, "SetAutoCompleteMode: {}", mode);
if (mode == "Parser")
m_autocomplete_engine = make<ParserAutoComplete>(*this, m_filedb);
else
m_autocomplete_engine = make<LexerAutoComplete>(*this, m_filedb);

View file

@ -23,6 +23,6 @@ class ClientConnection final : public LanguageServers::ClientConnection {
virtual ~ClientConnection() override = default;
private:
virtual void handle(const Messages::LanguageServer::SetAutoCompleteMode&) override { }
virtual void set_auto_complete_mode(String const&) override { }
};
}

View file

@ -45,6 +45,21 @@ struct Endpoint {
Vector<Message> messages;
};
static String snake_case(String const& identifier)
{
StringBuilder builder;
bool was_new_word = true;
for (auto ch : identifier) {
if (!builder.is_empty() && isupper(ch) && !was_new_word) {
builder.append('_');
was_new_word = true;
} else if (!isupper(ch))
was_new_word = false;
builder.append(tolower(ch));
}
return builder.to_string();
}
int main(int argc, char** argv)
{
if (argc != 2) {
@ -540,24 +555,38 @@ public:
switch (message.message_id()) {
)~~~");
for (auto& message : endpoint.messages) {
auto do_handle_message = [&](const String& name, bool returns_something) {
auto do_handle_message = [&](String const& name, Vector<Parameter> const& parameters, bool returns_something) {
auto message_generator = endpoint_generator.fork();
StringBuilder argument_generator;
for (size_t i = 0; i < parameters.size(); ++i) {
auto& parameter = parameters[i];
argument_generator.append("request.");
argument_generator.append(parameter.name);
argument_generator.append("()");
if (i != parameters.size() - 1)
argument_generator.append(", ");
}
message_generator.set("message.name", name);
message_generator.set("message.response_type", message.response_name());
message_generator.set("handler_name", snake_case(name));
message_generator.set("arguments", argument_generator.to_string());
message_generator.append(R"~~~(
case (int)Messages::@endpoint.name@::MessageID::@message.name@: {
)~~~");
if (returns_something) {
if (message.outputs.is_empty()) {
message_generator.append(R"~~~(
handle(static_cast<const Messages::@endpoint.name@::@message.name@&>(message));
[[maybe_unused]] auto& request = static_cast<const Messages::@endpoint.name@::@message.name@&>(message);
@handler_name@(@arguments@);
auto response = Messages::@endpoint.name@::@message.response_type@ { };
return make<IPC::MessageBuffer>(response.encode());
)~~~");
} else {
message_generator.append(R"~~~(
auto response = handle(static_cast<const Messages::@endpoint.name@::@message.name@&>(message));
[[maybe_unused]] auto& request = static_cast<const Messages::@endpoint.name@::@message.name@&>(message);
auto response = @handler_name@(@arguments@);
if (!response.valid())
return {};
return make<IPC::MessageBuffer>(response.encode());
@ -565,7 +594,8 @@ public:
}
} else {
message_generator.append(R"~~~(
handle(static_cast<const Messages::@endpoint.name@::@message.name@&>(message));
[[maybe_unused]] auto& request = static_cast<const Messages::@endpoint.name@::@message.name@&>(message);
@handler_name@(@arguments@);
return {};
)~~~");
}
@ -573,9 +603,9 @@ public:
}
)~~~");
};
do_handle_message(message.name, message.is_synchronous);
do_handle_message(message.name, message.inputs, message.is_synchronous);
if (message.is_synchronous)
do_handle_message(message.response_name(), false);
do_handle_message(message.response_name(), message.outputs, false);
}
endpoint_generator.append(R"~~~(
default:
@ -587,10 +617,9 @@ public:
for (auto& message : endpoint.messages) {
auto message_generator = endpoint_generator.fork();
message_generator.set("message.name", message.name);
auto do_handle_message_decl = [&](String const& name, Vector<Parameter> const& parameters, bool is_response) {
String return_type = "void";
if (message.is_synchronous && !message.outputs.is_empty()) {
if (message.is_synchronous && !message.outputs.is_empty() && !is_response) {
StringBuilder builder;
builder.append("Messages::");
builder.append(endpoint.name);
@ -601,9 +630,48 @@ public:
}
message_generator.set("message.complex_return_type", return_type);
message_generator.set("handler_name", snake_case(name));
message_generator.append(R"~~~(
virtual @message.complex_return_type@ handle(const Messages::@endpoint.name@::@message.name@&) = 0;
virtual @message.complex_return_type@ @handler_name@()~~~");
auto make_argument_type = [](String const& type) {
StringBuilder builder;
bool const_ref = true;
if (type == "u8" || type == "i8" || type == "u16" || type == "i16"
|| type == "u32" || type == "i32" || type == "bool" || type == "double"
|| type == "float" || type == "int" || type == "unsigned" || type == "unsigned int")
const_ref = false;
builder.append(type);
if (const_ref)
builder.append(" const&");
return builder.to_string();
};
for (size_t i = 0; i < parameters.size(); ++i) {
auto& parameter = parameters[i];
auto argument_generator = message_generator.fork();
argument_generator.set("argument.type", make_argument_type(parameter.type));
argument_generator.set("argument.name", parameter.name);
argument_generator.append("[[maybe_unused]] @argument.type@ @argument.name@");
if (i != parameters.size() - 1)
argument_generator.append(", ");
}
if (is_response) {
message_generator.append(R"~~~() { };
)~~~");
} else {
message_generator.append(R"~~~() = 0;
)~~~");
}
};
do_handle_message_decl(message.name, message.inputs, false);
if (message.is_synchronous)
do_handle_message_decl(message.response_name(), message.outputs, true);
}
endpoint_generator.append(R"~~~(

View file

@ -80,22 +80,22 @@ int ClientConnection::get_playing_buffer()
return send_sync<Messages::AudioServer::GetPlayingBuffer>()->buffer_id();
}
void ClientConnection::handle(const Messages::AudioClient::FinishedPlayingBuffer& message)
void ClientConnection::finished_playing_buffer(i32 buffer_id)
{
if (on_finish_playing_buffer)
on_finish_playing_buffer(message.buffer_id());
on_finish_playing_buffer(buffer_id);
}
void ClientConnection::handle(const Messages::AudioClient::MutedStateChanged& message)
void ClientConnection::muted_state_changed(bool muted)
{
if (on_muted_state_change)
on_muted_state_change(message.muted());
on_muted_state_change(muted);
}
void ClientConnection::handle(const Messages::AudioClient::MainMixVolumeChanged& message)
void ClientConnection::main_mix_volume_changed(i32 volume)
{
if (on_main_mix_volume_change)
on_main_mix_volume_change(message.volume());
on_main_mix_volume_change(volume);
}
}

View file

@ -42,9 +42,9 @@ public:
Function<void(int volume)> on_main_mix_volume_change;
private:
virtual void handle(const Messages::AudioClient::FinishedPlayingBuffer&) override;
virtual void handle(const Messages::AudioClient::MutedStateChanged&) override;
virtual void handle(const Messages::AudioClient::MainMixVolumeChanged&) override;
virtual void finished_playing_buffer(i32) override;
virtual void muted_state_changed(bool) override;
virtual void main_mix_volume_changed(i32) override;
};
}

View file

@ -48,7 +48,7 @@ private:
: IPC::ServerConnection<LaunchClientEndpoint, LaunchServerEndpoint>(*this, "/tmp/portal/launch")
{
}
virtual void handle(const Messages::LaunchClient::Dummy&) override { }
virtual void dummy() override { }
};
static LaunchServerConnection& connection()

View file

@ -27,7 +27,7 @@ private:
: IPC::ServerConnection<ClipboardClientEndpoint, ClipboardServerEndpoint>(*this, "/tmp/portal/clipboard")
{
}
virtual void handle(const Messages::ClipboardClient::ClipboardDataChanged&) override;
virtual void clipboard_data_changed(String const& mime_type) override;
};
Clipboard& Clipboard::the()
@ -78,11 +78,11 @@ void Clipboard::set_data(ReadonlyBytes data, const String& type, const HashMap<S
connection().send_sync<Messages::ClipboardServer::SetClipboardData>(move(buffer), type, metadata);
}
void ClipboardServerConnection::handle(const Messages::ClipboardClient::ClipboardDataChanged& message)
void ClipboardServerConnection::clipboard_data_changed(String const& mime_type)
{
auto& clipboard = Clipboard::the();
if (clipboard.on_change)
clipboard.on_change(message.mime_type());
clipboard.on_change(mime_type);
}
RefPtr<Gfx::Bitmap> Clipboard::bitmap() const

View file

@ -34,7 +34,7 @@ private:
, m_notification(notification)
{
}
virtual void handle(const Messages::NotificationClient::Dummy&) override { }
virtual void dummy() override { }
Notification* m_notification;
};

View file

@ -24,40 +24,42 @@ void WindowManagerServerConnection::handshake()
// :^)
}
void WindowManagerServerConnection::handle(const Messages::WindowManagerClient::WindowStateChanged& message)
void WindowManagerServerConnection::window_state_changed(i32 wm_id, i32 client_id, i32 window_id,
i32 parent_client_id, i32 parent_window_id, bool is_active, bool is_minimized, bool is_modal,
bool is_frameless, i32 window_type, String const& title, Gfx::IntRect const& rect, Optional<i32> const& progress)
{
if (auto* window = Window::from_window_id(message.wm_id()))
Core::EventLoop::current().post_event(*window, make<WMWindowStateChangedEvent>(message.client_id(), message.window_id(), message.parent_client_id(), message.parent_window_id(), message.title(), message.rect(), message.is_active(), message.is_modal(), static_cast<WindowType>(message.window_type()), message.is_minimized(), message.is_frameless(), message.progress()));
if (auto* window = Window::from_window_id(wm_id))
Core::EventLoop::current().post_event(*window, make<WMWindowStateChangedEvent>(client_id, window_id, parent_client_id, parent_window_id, title, rect, is_active, is_modal, static_cast<WindowType>(window_type), is_minimized, is_frameless, progress));
}
void WindowManagerServerConnection::handle(const Messages::WindowManagerClient::AppletAreaSizeChanged& message)
void WindowManagerServerConnection::applet_area_size_changed(i32 wm_id, const Gfx::IntSize& size)
{
if (auto* window = Window::from_window_id(message.wm_id()))
Core::EventLoop::current().post_event(*window, make<WMAppletAreaSizeChangedEvent>(message.size()));
if (auto* window = Window::from_window_id(wm_id))
Core::EventLoop::current().post_event(*window, make<WMAppletAreaSizeChangedEvent>(size));
}
void WindowManagerServerConnection::handle(const Messages::WindowManagerClient::WindowRectChanged& message)
void WindowManagerServerConnection::window_rect_changed(i32 wm_id, i32 client_id, i32 window_id, Gfx::IntRect const& rect)
{
if (auto* window = Window::from_window_id(message.wm_id()))
Core::EventLoop::current().post_event(*window, make<WMWindowRectChangedEvent>(message.client_id(), message.window_id(), message.rect()));
if (auto* window = Window::from_window_id(wm_id))
Core::EventLoop::current().post_event(*window, make<WMWindowRectChangedEvent>(client_id, window_id, rect));
}
void WindowManagerServerConnection::handle(const Messages::WindowManagerClient::WindowIconBitmapChanged& message)
void WindowManagerServerConnection::window_icon_bitmap_changed(i32 wm_id, i32 client_id, i32 window_id, Gfx::ShareableBitmap const& bitmap)
{
if (auto* window = Window::from_window_id(message.wm_id())) {
Core::EventLoop::current().post_event(*window, make<WMWindowIconBitmapChangedEvent>(message.client_id(), message.window_id(), message.bitmap().bitmap()));
if (auto* window = Window::from_window_id(wm_id)) {
Core::EventLoop::current().post_event(*window, make<WMWindowIconBitmapChangedEvent>(client_id, window_id, bitmap.bitmap()));
}
}
void WindowManagerServerConnection::handle(const Messages::WindowManagerClient::WindowRemoved& message)
void WindowManagerServerConnection::window_removed(i32 wm_id, i32 client_id, i32 window_id)
{
if (auto* window = Window::from_window_id(message.wm_id()))
Core::EventLoop::current().post_event(*window, make<WMWindowRemovedEvent>(message.client_id(), message.window_id()));
if (auto* window = Window::from_window_id(wm_id))
Core::EventLoop::current().post_event(*window, make<WMWindowRemovedEvent>(client_id, window_id));
}
void WindowManagerServerConnection::handle(const Messages::WindowManagerClient::SuperKeyPressed& message)
void WindowManagerServerConnection::super_key_pressed(i32 wm_id)
{
if (auto* window = Window::from_window_id(message.wm_id()))
Core::EventLoop::current().post_event(*window, make<WMSuperKeyPressedEvent>(message.wm_id()));
if (auto* window = Window::from_window_id(wm_id))
Core::EventLoop::current().post_event(*window, make<WMSuperKeyPressedEvent>(wm_id));
}
}

View file

@ -27,12 +27,12 @@ public:
static WindowManagerServerConnection& the();
private:
virtual void handle(const Messages::WindowManagerClient::WindowRemoved&) override;
virtual void handle(const Messages::WindowManagerClient::WindowStateChanged&) override;
virtual void handle(const Messages::WindowManagerClient::WindowIconBitmapChanged&) override;
virtual void handle(const Messages::WindowManagerClient::WindowRectChanged&) override;
virtual void handle(const Messages::WindowManagerClient::AppletAreaSizeChanged&) override;
virtual void handle(const Messages::WindowManagerClient::SuperKeyPressed&) override;
virtual void window_removed(i32, i32, i32) override;
virtual void window_state_changed(i32, i32, i32, i32, i32, bool, bool, bool, bool, i32, String const&, Gfx::IntRect const&, Optional<i32> const&) override;
virtual void window_icon_bitmap_changed(i32, i32, i32, Gfx::ShareableBitmap const&) override;
virtual void window_rect_changed(i32, i32, i32, Gfx::IntRect const&) override;
virtual void applet_area_size_changed(i32, Gfx::IntSize const&) override;
virtual void super_key_pressed(i32) override;
};
}

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());
}

View file

@ -27,35 +27,35 @@ public:
static WindowServerConnection& the();
private:
virtual void handle(const Messages::WindowClient::Paint&) override;
virtual void handle(const Messages::WindowClient::MouseMove&) override;
virtual void handle(const Messages::WindowClient::MouseDown&) override;
virtual void handle(const Messages::WindowClient::MouseDoubleClick&) override;
virtual void handle(const Messages::WindowClient::MouseUp&) override;
virtual void handle(const Messages::WindowClient::MouseWheel&) override;
virtual void handle(const Messages::WindowClient::WindowEntered&) override;
virtual void handle(const Messages::WindowClient::WindowLeft&) override;
virtual void handle(const Messages::WindowClient::KeyDown&) override;
virtual void handle(const Messages::WindowClient::KeyUp&) override;
virtual void handle(const Messages::WindowClient::WindowActivated&) override;
virtual void handle(const Messages::WindowClient::WindowDeactivated&) override;
virtual void handle(const Messages::WindowClient::WindowInputEntered&) override;
virtual void handle(const Messages::WindowClient::WindowInputLeft&) override;
virtual void handle(const Messages::WindowClient::WindowCloseRequest&) override;
virtual void handle(const Messages::WindowClient::WindowResized&) override;
virtual void handle(const Messages::WindowClient::MenuItemActivated&) override;
virtual void handle(const Messages::WindowClient::MenuItemEntered&) override;
virtual void handle(const Messages::WindowClient::MenuItemLeft&) override;
virtual void handle(const Messages::WindowClient::MenuVisibilityDidChange&) override;
virtual void handle(const Messages::WindowClient::ScreenRectChanged&) override;
virtual void handle(const Messages::WindowClient::AsyncSetWallpaperFinished&) override;
virtual void handle(const Messages::WindowClient::DragDropped&) override;
virtual void handle(const Messages::WindowClient::DragAccepted&) override;
virtual void handle(const Messages::WindowClient::DragCancelled&) override;
virtual void handle(const Messages::WindowClient::UpdateSystemTheme&) override;
virtual void handle(const Messages::WindowClient::WindowStateChanged&) override;
virtual void handle(const Messages::WindowClient::DisplayLinkNotification&) override;
virtual void handle(const Messages::WindowClient::Ping&) 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;
virtual void mouse_double_click(i32, Gfx::IntPoint const&, u32, u32, u32, i32) override;
virtual void mouse_up(i32, Gfx::IntPoint const&, u32, u32, u32, i32) override;
virtual void mouse_wheel(i32, Gfx::IntPoint const&, u32, u32, u32, i32) override;
virtual void window_entered(i32) override;
virtual void window_left(i32) override;
virtual void key_down(i32, u32, u32, u32, u32) override;
virtual void key_up(i32, u32, u32, u32, u32) override;
virtual void window_activated(i32) override;
virtual void window_deactivated(i32) override;
virtual void window_input_entered(i32) override;
virtual void window_input_left(i32) override;
virtual void window_close_request(i32) override;
virtual void window_resized(i32, Gfx::IntRect const&) override;
virtual void menu_item_activated(i32, u32) override;
virtual void menu_item_entered(i32, u32) override;
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 drag_dropped(i32, Gfx::IntPoint const&, String const&, HashMap<String, ByteBuffer> const&) override;
virtual void drag_accepted() override;
virtual void drag_cancelled() override;
virtual void update_system_theme(Core::AnonymousBuffer const&) override;
virtual void window_state_changed(i32, bool, bool) override;
virtual void display_link_notification() override;
virtual void ping() override;
bool m_display_link_notification_pending { false };
};

View file

@ -26,7 +26,7 @@ void Client::handshake()
send_sync<Messages::ImageDecoderServer::Greet>();
}
void Client::handle(const Messages::ImageDecoderClient::Dummy&)
void Client::dummy()
{
}

View file

@ -41,7 +41,7 @@ private:
virtual void die() override;
virtual void handle(const Messages::ImageDecoderClient::Dummy&) override;
virtual void dummy() override;
};
}

View file

@ -58,34 +58,34 @@ bool RequestClient::set_certificate(Badge<Request>, Request& request, String cer
return send_sync<Messages::RequestServer::SetCertificate>(request.id(), move(certificate), move(key))->success();
}
void RequestClient::handle(const Messages::RequestClient::RequestFinished& message)
void RequestClient::request_finished(i32 request_id, bool success, u32 total_size)
{
RefPtr<Request> request;
if ((request = m_requests.get(message.request_id()).value_or(nullptr))) {
request->did_finish({}, message.success(), message.total_size());
if ((request = m_requests.get(request_id).value_or(nullptr))) {
request->did_finish({}, success, total_size);
}
m_requests.remove(message.request_id());
m_requests.remove(request_id);
}
void RequestClient::handle(const Messages::RequestClient::RequestProgress& message)
void RequestClient::request_progress(i32 request_id, const Optional<u32>& total_size, u32 downloaded_size)
{
if (auto request = const_cast<Request*>(m_requests.get(message.request_id()).value_or(nullptr))) {
request->did_progress({}, message.total_size(), message.downloaded_size());
if (auto request = const_cast<Request*>(m_requests.get(request_id).value_or(nullptr))) {
request->did_progress({}, total_size, downloaded_size);
}
}
void RequestClient::handle(const Messages::RequestClient::HeadersBecameAvailable& message)
void RequestClient::headers_became_available(i32 request_id, const IPC::Dictionary& response_headers, const Optional<u32>& status_code)
{
if (auto request = const_cast<Request*>(m_requests.get(message.request_id()).value_or(nullptr))) {
if (auto request = const_cast<Request*>(m_requests.get(request_id).value_or(nullptr))) {
HashMap<String, String, CaseInsensitiveStringTraits> headers;
message.response_headers().for_each_entry([&](auto& name, auto& value) { headers.set(name, value); });
request->did_receive_headers({}, headers, message.status_code());
response_headers.for_each_entry([&](auto& name, auto& value) { headers.set(name, value); });
request->did_receive_headers({}, headers, status_code);
}
}
void RequestClient::handle(const Messages::RequestClient::CertificateRequested& message)
void RequestClient::certificate_requested(i32 request_id)
{
if (auto request = const_cast<Request*>(m_requests.get(message.request_id()).value_or(nullptr))) {
if (auto request = const_cast<Request*>(m_requests.get(request_id).value_or(nullptr))) {
request->did_request_certificates({});
}
}

View file

@ -33,10 +33,10 @@ public:
private:
RequestClient();
virtual void handle(const Messages::RequestClient::RequestProgress&) override;
virtual void handle(const Messages::RequestClient::RequestFinished&) override;
virtual void handle(const Messages::RequestClient::CertificateRequested&) override;
virtual void handle(const Messages::RequestClient::HeadersBecameAvailable&) override;
virtual void request_progress(i32, Optional<u32> const&, u32) override;
virtual void request_finished(i32, bool, u32) override;
virtual void certificate_requested(i32) override;
virtual void headers_became_available(i32, IPC::Dictionary const&, Optional<u32> const&) override;
HashMap<i32, RefPtr<Request>> m_requests;
};

View file

@ -62,37 +62,37 @@ bool WebSocketClient::set_certificate(Badge<WebSocket>, WebSocket& connection, S
return send_sync<Messages::WebSocketServer::SetCertificate>(connection.id(), move(certificate), move(key))->success();
}
void WebSocketClient::handle(const Messages::WebSocketClient::Connected& message)
void WebSocketClient::connected(i32 connection_id)
{
auto maybe_connection = m_connections.get(message.connection_id());
auto maybe_connection = m_connections.get(connection_id);
if (maybe_connection.has_value())
maybe_connection.value()->did_open({});
}
void WebSocketClient::handle(const Messages::WebSocketClient::Received& message)
void WebSocketClient::received(i32 connection_id, bool is_text, ByteBuffer const& data)
{
auto maybe_connection = m_connections.get(message.connection_id());
auto maybe_connection = m_connections.get(connection_id);
if (maybe_connection.has_value())
maybe_connection.value()->did_receive({}, message.data(), message.is_text());
maybe_connection.value()->did_receive({}, data, is_text);
}
void WebSocketClient::handle(const Messages::WebSocketClient::Errored& message)
void WebSocketClient::errored(i32 connection_id, i32 message)
{
auto maybe_connection = m_connections.get(message.connection_id());
auto maybe_connection = m_connections.get(connection_id);
if (maybe_connection.has_value())
maybe_connection.value()->did_error({}, message.message());
maybe_connection.value()->did_error({}, message);
}
void WebSocketClient::handle(const Messages::WebSocketClient::Closed& message)
void WebSocketClient::closed(i32 connection_id, u16 code, String const& reason, bool clean)
{
auto maybe_connection = m_connections.get(message.connection_id());
auto maybe_connection = m_connections.get(connection_id);
if (maybe_connection.has_value())
maybe_connection.value()->did_close({}, message.code(), message.reason(), message.clean());
maybe_connection.value()->did_close({}, code, reason, clean);
}
void WebSocketClient::handle(const Messages::WebSocketClient::CertificateRequested& message)
void WebSocketClient::certificate_requested(i32 connection_id)
{
auto maybe_connection = m_connections.get(message.connection_id());
auto maybe_connection = m_connections.get(connection_id);
if (maybe_connection.has_value())
maybe_connection.value()->did_request_certificates({});
}

View file

@ -33,11 +33,11 @@ public:
private:
WebSocketClient();
virtual void handle(const Messages::WebSocketClient::Connected&) override;
virtual void handle(const Messages::WebSocketClient::Received&) override;
virtual void handle(const Messages::WebSocketClient::Errored&) override;
virtual void handle(const Messages::WebSocketClient::Closed&) override;
virtual void handle(const Messages::WebSocketClient::CertificateRequested&) override;
virtual void connected(i32) override;
virtual void received(i32, bool, ByteBuffer const&) override;
virtual void errored(i32, i32) override;
virtual void closed(i32, u16, String const&, bool) override;
virtual void certificate_requested(i32) override;
HashMap<i32, NonnullRefPtr<WebSocket>> m_connections;
};

View file

@ -23,7 +23,7 @@ void Client::handshake()
send_sync<Messages::SymbolServer::Greet>();
}
void Client::handle(const Messages::SymbolClient::Dummy&)
void Client::dummy()
{
}

View file

@ -35,7 +35,7 @@ public:
private:
Client();
virtual void handle(const Messages::SymbolClient::Dummy&) override;
virtual void dummy() override;
};
}

View file

@ -29,156 +29,156 @@ void WebContentClient::handshake()
send_sync<Messages::WebContentServer::Greet>();
}
void WebContentClient::handle(const Messages::WebContentClient::DidPaint& message)
void WebContentClient::did_paint(const Gfx::IntRect&, i32 bitmap_id)
{
m_view.notify_server_did_paint({}, message.bitmap_id());
m_view.notify_server_did_paint({}, bitmap_id);
}
void WebContentClient::handle([[maybe_unused]] const Messages::WebContentClient::DidFinishLoading& message)
void WebContentClient::did_finish_loading(URL const& url)
{
m_view.notify_server_did_finish_loading({}, message.url());
m_view.notify_server_did_finish_loading({}, url);
}
void WebContentClient::handle(const Messages::WebContentClient::DidInvalidateContentRect& message)
void WebContentClient::did_invalidate_content_rect(Gfx::IntRect const& content_rect)
{
dbgln_if(SPAM_DEBUG, "handle: WebContentClient::DidInvalidateContentRect! content_rect={}", message.content_rect());
dbgln_if(SPAM_DEBUG, "handle: WebContentClient::DidInvalidateContentRect! content_rect={}", content_rect);
// FIXME: Figure out a way to coalesce these messages to reduce unnecessary painting
m_view.notify_server_did_invalidate_content_rect({}, message.content_rect());
m_view.notify_server_did_invalidate_content_rect({}, content_rect);
}
void WebContentClient::handle(const Messages::WebContentClient::DidChangeSelection&)
void WebContentClient::did_change_selection()
{
dbgln_if(SPAM_DEBUG, "handle: WebContentClient::DidChangeSelection!");
m_view.notify_server_did_change_selection({});
}
void WebContentClient::handle(const Messages::WebContentClient::DidRequestCursorChange& message)
void WebContentClient::did_request_cursor_change(i32 cursor_type)
{
if (message.cursor_type() < 0 || message.cursor_type() >= (i32)Gfx::StandardCursor::__Count) {
if (cursor_type < 0 || cursor_type >= (i32)Gfx::StandardCursor::__Count) {
dbgln("DidRequestCursorChange: Bad cursor type");
return;
}
m_view.notify_server_did_request_cursor_change({}, (Gfx::StandardCursor)message.cursor_type());
m_view.notify_server_did_request_cursor_change({}, (Gfx::StandardCursor)cursor_type);
}
void WebContentClient::handle(const Messages::WebContentClient::DidLayout& message)
void WebContentClient::did_layout(Gfx::IntSize const& content_size)
{
dbgln_if(SPAM_DEBUG, "handle: WebContentClient::DidLayout! content_size={}", message.content_size());
m_view.notify_server_did_layout({}, message.content_size());
dbgln_if(SPAM_DEBUG, "handle: WebContentClient::DidLayout! content_size={}", content_size);
m_view.notify_server_did_layout({}, content_size);
}
void WebContentClient::handle(const Messages::WebContentClient::DidChangeTitle& message)
void WebContentClient::did_change_title(String const& title)
{
dbgln_if(SPAM_DEBUG, "handle: WebContentClient::DidChangeTitle! title={}", message.title());
m_view.notify_server_did_change_title({}, message.title());
dbgln_if(SPAM_DEBUG, "handle: WebContentClient::DidChangeTitle! title={}", title);
m_view.notify_server_did_change_title({}, title);
}
void WebContentClient::handle(const Messages::WebContentClient::DidRequestScroll& message)
void WebContentClient::did_request_scroll(int wheel_delta)
{
m_view.notify_server_did_request_scroll({}, message.wheel_delta());
m_view.notify_server_did_request_scroll({}, wheel_delta);
}
void WebContentClient::handle(const Messages::WebContentClient::DidRequestScrollIntoView& message)
void WebContentClient::did_request_scroll_into_view(Gfx::IntRect const& rect)
{
dbgln_if(SPAM_DEBUG, "handle: WebContentClient::DidRequestScrollIntoView! rect={}", message.rect());
m_view.notify_server_did_request_scroll_into_view({}, message.rect());
dbgln_if(SPAM_DEBUG, "handle: WebContentClient::DidRequestScrollIntoView! rect={}", rect);
m_view.notify_server_did_request_scroll_into_view({}, rect);
}
void WebContentClient::handle(const Messages::WebContentClient::DidEnterTooltipArea& message)
void WebContentClient::did_enter_tooltip_area(Gfx::IntPoint const& content_position, String const& title)
{
m_view.notify_server_did_enter_tooltip_area({}, message.content_position(), message.title());
m_view.notify_server_did_enter_tooltip_area({}, content_position, title);
}
void WebContentClient::handle(const Messages::WebContentClient::DidLeaveTooltipArea&)
void WebContentClient::did_leave_tooltip_area()
{
m_view.notify_server_did_leave_tooltip_area({});
}
void WebContentClient::handle(const Messages::WebContentClient::DidHoverLink& message)
void WebContentClient::did_hover_link(URL const& url)
{
dbgln_if(SPAM_DEBUG, "handle: WebContentClient::DidHoverLink! url={}", message.url());
m_view.notify_server_did_hover_link({}, message.url());
dbgln_if(SPAM_DEBUG, "handle: WebContentClient::DidHoverLink! url={}", url);
m_view.notify_server_did_hover_link({}, url);
}
void WebContentClient::handle(const Messages::WebContentClient::DidUnhoverLink&)
void WebContentClient::did_unhover_link()
{
dbgln_if(SPAM_DEBUG, "handle: WebContentClient::DidUnhoverLink!");
m_view.notify_server_did_unhover_link({});
}
void WebContentClient::handle(const Messages::WebContentClient::DidClickLink& message)
void WebContentClient::did_click_link(URL const& url, String const& target, unsigned modifiers)
{
m_view.notify_server_did_click_link({}, message.url(), message.target(), message.modifiers());
m_view.notify_server_did_click_link({}, url, target, modifiers);
}
void WebContentClient::handle(const Messages::WebContentClient::DidMiddleClickLink& message)
void WebContentClient::did_middle_click_link(URL const& url, String const& target, unsigned modifiers)
{
m_view.notify_server_did_middle_click_link({}, message.url(), message.target(), message.modifiers());
m_view.notify_server_did_middle_click_link({}, url, target, modifiers);
}
void WebContentClient::handle(const Messages::WebContentClient::DidStartLoading& message)
void WebContentClient::did_start_loading(URL const& url)
{
m_view.notify_server_did_start_loading({}, message.url());
m_view.notify_server_did_start_loading({}, url);
}
void WebContentClient::handle(const Messages::WebContentClient::DidRequestContextMenu& message)
void WebContentClient::did_request_context_menu(Gfx::IntPoint const& content_position)
{
m_view.notify_server_did_request_context_menu({}, message.content_position());
m_view.notify_server_did_request_context_menu({}, content_position);
}
void WebContentClient::handle(const Messages::WebContentClient::DidRequestLinkContextMenu& message)
void WebContentClient::did_request_link_context_menu(Gfx::IntPoint const& content_position, URL const& url, String const& target, unsigned modifiers)
{
m_view.notify_server_did_request_link_context_menu({}, message.content_position(), message.url(), message.target(), message.modifiers());
m_view.notify_server_did_request_link_context_menu({}, content_position, url, target, modifiers);
}
void WebContentClient::handle(const Messages::WebContentClient::DidRequestImageContextMenu& message)
void WebContentClient::did_request_image_context_menu(Gfx::IntPoint const& content_position, URL const& url, String const& target, unsigned modifiers, Gfx::ShareableBitmap const& bitmap)
{
m_view.notify_server_did_request_image_context_menu({}, message.content_position(), message.url(), message.target(), message.modifiers(), message.bitmap());
m_view.notify_server_did_request_image_context_menu({}, content_position, url, target, modifiers, bitmap);
}
void WebContentClient::handle(const Messages::WebContentClient::DidGetSource& message)
void WebContentClient::did_get_source(URL const& url, String const& source)
{
m_view.notify_server_did_get_source(message.url(), message.source());
m_view.notify_server_did_get_source(url, source);
}
void WebContentClient::handle(const Messages::WebContentClient::DidJSConsoleOutput& message)
void WebContentClient::did_jsconsole_output(String const& method, String const& line)
{
m_view.notify_server_did_js_console_output(message.method(), message.line());
m_view.notify_server_did_js_console_output(method, line);
}
void WebContentClient::handle(const Messages::WebContentClient::DidRequestAlert& message)
void WebContentClient::did_request_alert(String const& message)
{
m_view.notify_server_did_request_alert({}, message.message());
m_view.notify_server_did_request_alert({}, message);
}
Messages::WebContentClient::DidRequestConfirmResponse WebContentClient::handle(const Messages::WebContentClient::DidRequestConfirm& message)
Messages::WebContentClient::DidRequestConfirmResponse WebContentClient::did_request_confirm(String const& message)
{
return m_view.notify_server_did_request_confirm({}, message.message());
return m_view.notify_server_did_request_confirm({}, message);
}
Messages::WebContentClient::DidRequestPromptResponse WebContentClient::handle(const Messages::WebContentClient::DidRequestPrompt& message)
Messages::WebContentClient::DidRequestPromptResponse WebContentClient::did_request_prompt(String const& message, String const& default_)
{
return m_view.notify_server_did_request_prompt({}, message.message(), message.default_());
return m_view.notify_server_did_request_prompt({}, message, default_);
}
void WebContentClient::handle(const Messages::WebContentClient::DidChangeFavicon& message)
void WebContentClient::did_change_favicon(Gfx::ShareableBitmap const& favicon)
{
if (!message.favicon().is_valid()) {
if (!favicon.is_valid()) {
dbgln("DidChangeFavicon: Received invalid favicon");
return;
}
m_view.notify_server_did_change_favicon(*message.favicon().bitmap());
m_view.notify_server_did_change_favicon(*favicon.bitmap());
}
Messages::WebContentClient::DidRequestCookieResponse WebContentClient::handle(const Messages::WebContentClient::DidRequestCookie& message)
Messages::WebContentClient::DidRequestCookieResponse WebContentClient::did_request_cookie(URL const& url, u8 source)
{
return m_view.notify_server_did_request_cookie({}, message.url(), static_cast<Cookie::Source>(message.source()));
return m_view.notify_server_did_request_cookie({}, url, static_cast<Cookie::Source>(source));
}
void WebContentClient::handle(const Messages::WebContentClient::DidSetCookie& message)
void WebContentClient::did_set_cookie(URL const& url, Web::Cookie::ParsedCookie const& cookie, u8 source)
{
m_view.notify_server_did_set_cookie({}, message.url(), message.cookie(), static_cast<Cookie::Source>(message.source()));
m_view.notify_server_did_set_cookie({}, url, cookie, static_cast<Cookie::Source>(source));
}
}

View file

@ -31,33 +31,33 @@ private:
virtual void die() override;
virtual void handle(const Messages::WebContentClient::DidPaint&) override;
virtual void handle(const Messages::WebContentClient::DidFinishLoading&) override;
virtual void handle(const Messages::WebContentClient::DidInvalidateContentRect&) override;
virtual void handle(const Messages::WebContentClient::DidChangeSelection&) override;
virtual void handle(const Messages::WebContentClient::DidRequestCursorChange&) override;
virtual void handle(const Messages::WebContentClient::DidLayout&) override;
virtual void handle(const Messages::WebContentClient::DidChangeTitle&) override;
virtual void handle(const Messages::WebContentClient::DidRequestScroll&) override;
virtual void handle(const Messages::WebContentClient::DidRequestScrollIntoView&) override;
virtual void handle(const Messages::WebContentClient::DidEnterTooltipArea&) override;
virtual void handle(const Messages::WebContentClient::DidLeaveTooltipArea&) override;
virtual void handle(const Messages::WebContentClient::DidHoverLink&) override;
virtual void handle(const Messages::WebContentClient::DidUnhoverLink&) override;
virtual void handle(const Messages::WebContentClient::DidClickLink&) override;
virtual void handle(const Messages::WebContentClient::DidMiddleClickLink&) override;
virtual void handle(const Messages::WebContentClient::DidStartLoading&) override;
virtual void handle(const Messages::WebContentClient::DidRequestContextMenu&) override;
virtual void handle(const Messages::WebContentClient::DidRequestLinkContextMenu&) override;
virtual void handle(const Messages::WebContentClient::DidRequestImageContextMenu&) override;
virtual void handle(const Messages::WebContentClient::DidGetSource&) override;
virtual void handle(const Messages::WebContentClient::DidJSConsoleOutput&) override;
virtual void handle(const Messages::WebContentClient::DidChangeFavicon&) override;
virtual void handle(const Messages::WebContentClient::DidRequestAlert&) override;
virtual Messages::WebContentClient::DidRequestConfirmResponse handle(const Messages::WebContentClient::DidRequestConfirm&) override;
virtual Messages::WebContentClient::DidRequestPromptResponse handle(const Messages::WebContentClient::DidRequestPrompt&) override;
virtual Messages::WebContentClient::DidRequestCookieResponse handle(const Messages::WebContentClient::DidRequestCookie&) override;
virtual void handle(const Messages::WebContentClient::DidSetCookie&) override;
virtual void did_paint(Gfx::IntRect const&, i32) override;
virtual void did_finish_loading(URL const&) override;
virtual void did_invalidate_content_rect(Gfx::IntRect const&) override;
virtual void did_change_selection() override;
virtual void did_request_cursor_change(i32) override;
virtual void did_layout(Gfx::IntSize const&) override;
virtual void did_change_title(String const&) override;
virtual void did_request_scroll(int) override;
virtual void did_request_scroll_into_view(Gfx::IntRect const&) override;
virtual void did_enter_tooltip_area(Gfx::IntPoint const&, String const&) override;
virtual void did_leave_tooltip_area() override;
virtual void did_hover_link(URL const&) override;
virtual void did_unhover_link() override;
virtual void did_click_link(URL const&, String const&, unsigned) override;
virtual void did_middle_click_link(URL const&, String const&, unsigned) override;
virtual void did_start_loading(URL const&) override;
virtual void did_request_context_menu(Gfx::IntPoint const&) override;
virtual void did_request_link_context_menu(Gfx::IntPoint const&, URL const&, String const&, unsigned) override;
virtual void did_request_image_context_menu(Gfx::IntPoint const&, URL const&, String const&, unsigned, Gfx::ShareableBitmap const&) override;
virtual void did_get_source(URL const&, String const&) override;
virtual void did_jsconsole_output(String const&, String const&) override;
virtual void did_change_favicon(Gfx::ShareableBitmap const&) override;
virtual void did_request_alert(String const&) override;
virtual Messages::WebContentClient::DidRequestConfirmResponse did_request_confirm(String const&) override;
virtual Messages::WebContentClient::DidRequestPromptResponse did_request_prompt(String const&, String const&) override;
virtual Messages::WebContentClient::DidRequestCookieResponse did_request_cookie(URL const&, u8) override;
virtual void did_set_cookie(URL const&, Web::Cookie::ParsedCookie const&, u8) override;
OutOfProcessWebView& m_view;
};

View file

@ -59,21 +59,21 @@ void ClientConnection::did_change_main_mix_volume(Badge<Mixer>, int volume)
post_message(Messages::AudioClient::MainMixVolumeChanged(volume));
}
void ClientConnection::handle(const Messages::AudioServer::Greet&)
void ClientConnection::greet()
{
}
Messages::AudioServer::GetMainMixVolumeResponse ClientConnection::handle(const Messages::AudioServer::GetMainMixVolume&)
Messages::AudioServer::GetMainMixVolumeResponse ClientConnection::get_main_mix_volume()
{
return m_mixer.main_volume();
}
void ClientConnection::handle(const Messages::AudioServer::SetMainMixVolume& message)
void ClientConnection::set_main_mix_volume(i32 volume)
{
m_mixer.set_main_volume(message.volume());
m_mixer.set_main_volume(volume);
}
Messages::AudioServer::EnqueueBufferResponse ClientConnection::handle(const Messages::AudioServer::EnqueueBuffer& message)
Messages::AudioServer::EnqueueBufferResponse ClientConnection::enqueue_buffer(Core::AnonymousBuffer const& buffer, i32 buffer_id, int sample_count)
{
if (!m_queue)
m_queue = m_mixer.create_queue(*this);
@ -81,11 +81,11 @@ Messages::AudioServer::EnqueueBufferResponse ClientConnection::handle(const Mess
if (m_queue->is_full())
return false;
m_queue->enqueue(Audio::Buffer::create_with_anonymous_buffer(message.buffer(), message.buffer_id(), message.sample_count()));
m_queue->enqueue(Audio::Buffer::create_with_anonymous_buffer(buffer, buffer_id, sample_count));
return true;
}
Messages::AudioServer::GetRemainingSamplesResponse ClientConnection::handle(const Messages::AudioServer::GetRemainingSamples&)
Messages::AudioServer::GetRemainingSamplesResponse ClientConnection::get_remaining_samples()
{
int remaining = 0;
if (m_queue)
@ -94,7 +94,7 @@ Messages::AudioServer::GetRemainingSamplesResponse ClientConnection::handle(cons
return remaining;
}
Messages::AudioServer::GetPlayedSamplesResponse ClientConnection::handle(const Messages::AudioServer::GetPlayedSamples&)
Messages::AudioServer::GetPlayedSamplesResponse ClientConnection::get_played_samples()
{
int played = 0;
if (m_queue)
@ -103,19 +103,19 @@ Messages::AudioServer::GetPlayedSamplesResponse ClientConnection::handle(const M
return played;
}
void ClientConnection::handle(const Messages::AudioServer::SetPaused& message)
void ClientConnection::set_paused(bool paused)
{
if (m_queue)
m_queue->set_paused(message.paused());
m_queue->set_paused(paused);
}
void ClientConnection::handle(const Messages::AudioServer::ClearBuffer& message)
void ClientConnection::clear_buffer(bool paused)
{
if (m_queue)
m_queue->clear(message.paused());
m_queue->clear(paused);
}
Messages::AudioServer::GetPlayingBufferResponse ClientConnection::handle(const Messages::AudioServer::GetPlayingBuffer&)
Messages::AudioServer::GetPlayingBufferResponse ClientConnection::get_playing_buffer()
{
int id = -1;
if (m_queue)
@ -123,13 +123,13 @@ Messages::AudioServer::GetPlayingBufferResponse ClientConnection::handle(const M
return id;
}
Messages::AudioServer::GetMutedResponse ClientConnection::handle(const Messages::AudioServer::GetMuted&)
Messages::AudioServer::GetMutedResponse ClientConnection::get_muted()
{
return m_mixer.is_muted();
}
void ClientConnection::handle(const Messages::AudioServer::SetMuted& message)
void ClientConnection::set_muted(bool muted)
{
m_mixer.set_muted(message.muted());
m_mixer.set_muted(muted);
}
}

View file

@ -36,17 +36,17 @@ public:
static void for_each(Function<void(ClientConnection&)>);
private:
virtual void handle(const Messages::AudioServer::Greet&) override;
virtual Messages::AudioServer::GetMainMixVolumeResponse handle(const Messages::AudioServer::GetMainMixVolume&) override;
virtual void handle(const Messages::AudioServer::SetMainMixVolume&) override;
virtual Messages::AudioServer::EnqueueBufferResponse handle(const Messages::AudioServer::EnqueueBuffer&) override;
virtual Messages::AudioServer::GetRemainingSamplesResponse handle(const Messages::AudioServer::GetRemainingSamples&) override;
virtual Messages::AudioServer::GetPlayedSamplesResponse handle(const Messages::AudioServer::GetPlayedSamples&) override;
virtual void handle(const Messages::AudioServer::SetPaused&) override;
virtual void handle(const Messages::AudioServer::ClearBuffer&) override;
virtual Messages::AudioServer::GetPlayingBufferResponse handle(const Messages::AudioServer::GetPlayingBuffer&) override;
virtual Messages::AudioServer::GetMutedResponse handle(const Messages::AudioServer::GetMuted&) override;
virtual void handle(const Messages::AudioServer::SetMuted&) override;
virtual void greet() override;
virtual Messages::AudioServer::GetMainMixVolumeResponse get_main_mix_volume() override;
virtual void set_main_mix_volume(i32) override;
virtual Messages::AudioServer::EnqueueBufferResponse enqueue_buffer(Core::AnonymousBuffer const&, i32, int) override;
virtual Messages::AudioServer::GetRemainingSamplesResponse get_remaining_samples() override;
virtual Messages::AudioServer::GetPlayedSamplesResponse get_played_samples() override;
virtual void set_paused(bool) override;
virtual void clear_buffer(bool) override;
virtual Messages::AudioServer::GetPlayingBufferResponse get_playing_buffer() override;
virtual Messages::AudioServer::GetMutedResponse get_muted() override;
virtual void set_muted(bool) override;
Mixer& m_mixer;
RefPtr<BufferQueue> m_queue;

View file

@ -35,16 +35,16 @@ void ClientConnection::die()
s_connections.remove(client_id());
}
void ClientConnection::handle(const Messages::ClipboardServer::Greet&)
void ClientConnection::greet()
{
}
void ClientConnection::handle(const Messages::ClipboardServer::SetClipboardData& message)
void ClientConnection::set_clipboard_data(Core::AnonymousBuffer const& data, String const& mime_type, IPC::Dictionary const& metadata)
{
Storage::the().set_data(message.data(), message.mime_type(), message.metadata().entries());
Storage::the().set_data(data, mime_type, metadata.entries());
}
Messages::ClipboardServer::GetClipboardDataResponse ClientConnection::handle(const Messages::ClipboardServer::GetClipboardData&)
Messages::ClipboardServer::GetClipboardDataResponse ClientConnection::get_clipboard_data()
{
auto& storage = Storage::the();
return { storage.buffer(), storage.mime_type(), storage.metadata() };

View file

@ -30,9 +30,9 @@ public:
void notify_about_clipboard_change();
private:
virtual void handle(const Messages::ClipboardServer::Greet&) override;
virtual Messages::ClipboardServer::GetClipboardDataResponse handle(const Messages::ClipboardServer::GetClipboardData&) override;
virtual void handle(const Messages::ClipboardServer::SetClipboardData&) override;
virtual void greet() override;
virtual Messages::ClipboardServer::GetClipboardDataResponse get_clipboard_data() override;
virtual void set_clipboard_data(Core::AnonymousBuffer const&, String const&, IPC::Dictionary const&) override;
};
}

View file

@ -30,13 +30,12 @@ void ClientConnection::die()
exit(0);
}
void ClientConnection::handle(const Messages::ImageDecoderServer::Greet&)
void ClientConnection::greet()
{
}
Messages::ImageDecoderServer::DecodeImageResponse ClientConnection::handle(const Messages::ImageDecoderServer::DecodeImage& message)
Messages::ImageDecoderServer::DecodeImageResponse ClientConnection::decode_image(Core::AnonymousBuffer const& encoded_buffer)
{
auto encoded_buffer = message.data();
if (!encoded_buffer.is_valid()) {
dbgln_if(IMAGE_DECODER_DEBUG, "Encoded data is invalid");
return nullptr;

View file

@ -27,8 +27,8 @@ public:
virtual void die() override;
private:
virtual void handle(const Messages::ImageDecoderServer::Greet&) override;
virtual Messages::ImageDecoderServer::DecodeImageResponse handle(const Messages::ImageDecoderServer::DecodeImage&) override;
virtual void greet() override;
virtual Messages::ImageDecoderServer::DecodeImageResponse decode_image(Core::AnonymousBuffer const&) override;
};
}

View file

@ -28,18 +28,18 @@ void ClientConnection::die()
s_connections.remove(client_id());
}
void ClientConnection::handle(const Messages::LaunchServer::Greet&)
void ClientConnection::greet()
{
}
Messages::LaunchServer::OpenURLResponse ClientConnection::handle(const Messages::LaunchServer::OpenURL& request)
Messages::LaunchServer::OpenURLResponse ClientConnection::open_url(URL const& url, String const& handler_name)
{
if (!m_allowlist.is_empty()) {
bool allowed = false;
auto request_url_without_fragment = request.url();
auto request_url_without_fragment = url;
request_url_without_fragment.set_fragment({});
for (auto& allowed_handler : m_allowlist) {
if (allowed_handler.handler_name == request.handler_name()
if (allowed_handler.handler_name == handler_name
&& (allowed_handler.any_url || allowed_handler.urls.contains_slow(request_url_without_fragment))) {
allowed = true;
break;
@ -47,78 +47,75 @@ Messages::LaunchServer::OpenURLResponse ClientConnection::handle(const Messages:
}
if (!allowed) {
// You are not on the list, go home!
did_misbehave(String::formatted("Client requested a combination of handler/URL that was not on the list: '{}' with '{}'", request.handler_name(), request.url()).characters());
did_misbehave(String::formatted("Client requested a combination of handler/URL that was not on the list: '{}' with '{}'", handler_name, url).characters());
return nullptr;
}
}
URL url(request.url());
return Launcher::the().open_url(url, request.handler_name());
return Launcher::the().open_url(url, handler_name);
}
Messages::LaunchServer::GetHandlersForURLResponse ClientConnection::handle(const Messages::LaunchServer::GetHandlersForURL& request)
Messages::LaunchServer::GetHandlersForURLResponse ClientConnection::get_handlers_for_url(URL const& url)
{
URL url(request.url());
return Launcher::the().handlers_for_url(url);
}
Messages::LaunchServer::GetHandlersWithDetailsForURLResponse ClientConnection::handle(const Messages::LaunchServer::GetHandlersWithDetailsForURL& request)
Messages::LaunchServer::GetHandlersWithDetailsForURLResponse ClientConnection::get_handlers_with_details_for_url(URL const& url)
{
URL url(request.url());
return Launcher::the().handlers_with_details_for_url(url);
}
void ClientConnection::handle(const Messages::LaunchServer::AddAllowedURL& request)
void ClientConnection::add_allowed_url(URL const& url)
{
if (m_allowlist_is_sealed) {
did_misbehave("Got request to add more allowed handlers after list was sealed");
return;
}
if (!request.url().is_valid()) {
if (!url.is_valid()) {
did_misbehave("Got request to allow invalid URL");
return;
}
m_allowlist.empend(String(), false, Vector<URL> { request.url() });
m_allowlist.empend(String(), false, Vector<URL> { url });
}
void ClientConnection::handle(const Messages::LaunchServer::AddAllowedHandlerWithAnyURL& request)
void ClientConnection::add_allowed_handler_with_any_url(String const& handler_name)
{
if (m_allowlist_is_sealed) {
did_misbehave("Got request to add more allowed handlers after list was sealed");
return;
}
if (request.handler_name().is_empty()) {
if (handler_name.is_empty()) {
did_misbehave("Got request to allow empty handler name");
return;
}
m_allowlist.empend(request.handler_name(), true, Vector<URL>());
m_allowlist.empend(handler_name, true, Vector<URL>());
}
void ClientConnection::handle(const Messages::LaunchServer::AddAllowedHandlerWithOnlySpecificURLs& request)
void ClientConnection::add_allowed_handler_with_only_specific_urls(String const& handler_name, Vector<URL> const& urls)
{
if (m_allowlist_is_sealed) {
did_misbehave("Got request to add more allowed handlers after list was sealed");
return;
}
if (request.handler_name().is_empty()) {
if (handler_name.is_empty()) {
did_misbehave("Got request to allow empty handler name");
return;
}
if (request.urls().is_empty()) {
if (urls.is_empty()) {
did_misbehave("Got request to allow empty URL list");
return;
}
m_allowlist.empend(request.handler_name(), false, request.urls());
m_allowlist.empend(handler_name, false, urls);
}
void ClientConnection::handle(const Messages::LaunchServer::SealAllowlist&)
void ClientConnection::seal_allowlist()
{
if (m_allowlist_is_sealed) {
did_misbehave("Got more than one request to seal the allowed handlers list");

View file

@ -23,14 +23,14 @@ public:
private:
explicit ClientConnection(NonnullRefPtr<Core::LocalSocket>, int client_id);
virtual void handle(const Messages::LaunchServer::Greet&) override;
virtual Messages::LaunchServer::OpenURLResponse handle(const Messages::LaunchServer::OpenURL&) override;
virtual Messages::LaunchServer::GetHandlersForURLResponse handle(const Messages::LaunchServer::GetHandlersForURL&) override;
virtual Messages::LaunchServer::GetHandlersWithDetailsForURLResponse handle(const Messages::LaunchServer::GetHandlersWithDetailsForURL&) override;
virtual void handle(const Messages::LaunchServer::AddAllowedURL&) override;
virtual void handle(const Messages::LaunchServer::AddAllowedHandlerWithAnyURL&) override;
virtual void handle(const Messages::LaunchServer::AddAllowedHandlerWithOnlySpecificURLs&) override;
virtual void handle(const Messages::LaunchServer::SealAllowlist&) override;
virtual void greet() override;
virtual Messages::LaunchServer::OpenURLResponse open_url(URL const&, String const&) override;
virtual Messages::LaunchServer::GetHandlersForURLResponse get_handlers_for_url(URL const&) override;
virtual Messages::LaunchServer::GetHandlersWithDetailsForURLResponse get_handlers_with_details_for_url(URL const&) override;
virtual void add_allowed_url(URL const&) override;
virtual void add_allowed_handler_with_any_url(String const&) override;
virtual void add_allowed_handler_with_only_specific_urls(String const&, Vector<URL> const&) override;
virtual void seal_allowlist() override;
struct AllowlistEntry {
String handler_name;

View file

@ -28,9 +28,9 @@ void ClientConnection::die()
s_connections.remove(client_id());
}
Messages::LookupServer::LookupNameResponse ClientConnection::handle(const Messages::LookupServer::LookupName& message)
Messages::LookupServer::LookupNameResponse ClientConnection::lookup_name(String const& name)
{
auto answers = LookupServer::the().lookup(message.name(), T_A);
auto answers = LookupServer::the().lookup(name, T_A);
if (answers.is_empty())
return { 1, Vector<String>() };
Vector<String> addresses;
@ -40,16 +40,16 @@ Messages::LookupServer::LookupNameResponse ClientConnection::handle(const Messag
return { 0, move(addresses) };
}
Messages::LookupServer::LookupAddressResponse ClientConnection::handle(const Messages::LookupServer::LookupAddress& message)
Messages::LookupServer::LookupAddressResponse ClientConnection::lookup_address(String const& address)
{
if (message.address().length() != 4)
if (address.length() != 4)
return { 1, String() };
IPv4Address address { (const u8*)message.address().characters() };
IPv4Address ip_address { (const u8*)address.characters() };
auto name = String::formatted("{}.{}.{}.{}.in-addr.arpa",
address[3],
address[2],
address[1],
address[0]);
ip_address[3],
ip_address[2],
ip_address[1],
ip_address[0]);
auto answers = LookupServer::the().lookup(name, T_PTR);
if (answers.is_empty())
return { 1, String() };

View file

@ -26,8 +26,8 @@ public:
virtual void die() override;
private:
virtual Messages::LookupServer::LookupNameResponse handle(const Messages::LookupServer::LookupName&) override;
virtual Messages::LookupServer::LookupAddressResponse handle(const Messages::LookupServer::LookupAddress&) override;
virtual Messages::LookupServer::LookupNameResponse lookup_name(String const&) override;
virtual Messages::LookupServer::LookupAddressResponse lookup_address(String const&) override;
};
}

View file

@ -28,17 +28,17 @@ void ClientConnection::die()
s_connections.remove(client_id());
}
void ClientConnection::handle(const Messages::NotificationServer::Greet&)
void ClientConnection::greet()
{
}
void ClientConnection::handle(const Messages::NotificationServer::ShowNotification& message)
void ClientConnection::show_notification(String const& text, String const& title, Gfx::ShareableBitmap const& icon)
{
auto window = NotificationWindow::construct(client_id(), message.text(), message.title(), message.icon());
auto window = NotificationWindow::construct(client_id(), text, title, icon);
window->show();
}
void ClientConnection::handle([[maybe_unused]] const Messages::NotificationServer::CloseNotification& message)
void ClientConnection::close_notification()
{
auto window = NotificationWindow::get_window_by_id(client_id());
if (window) {
@ -46,26 +46,26 @@ void ClientConnection::handle([[maybe_unused]] const Messages::NotificationServe
}
}
Messages::NotificationServer::UpdateNotificationIconResponse ClientConnection::handle(const Messages::NotificationServer::UpdateNotificationIcon& message)
Messages::NotificationServer::UpdateNotificationIconResponse ClientConnection::update_notification_icon(Gfx::ShareableBitmap const& icon)
{
auto window = NotificationWindow::get_window_by_id(client_id());
if (window) {
window->set_image(message.icon());
window->set_image(icon);
}
return !!window;
}
Messages::NotificationServer::UpdateNotificationTextResponse ClientConnection::handle(const Messages::NotificationServer::UpdateNotificationText& message)
Messages::NotificationServer::UpdateNotificationTextResponse ClientConnection::update_notification_text(String const& text, String const& title)
{
auto window = NotificationWindow::get_window_by_id(client_id());
if (window) {
window->set_text(message.text());
window->set_title(message.title());
window->set_text(text);
window->set_title(title);
}
return !!window;
}
Messages::NotificationServer::IsShowingResponse ClientConnection::handle(const Messages::NotificationServer::IsShowing&)
Messages::NotificationServer::IsShowingResponse ClientConnection::is_showing()
{
auto window = NotificationWindow::get_window_by_id(client_id());
return !!window;

View file

@ -23,12 +23,12 @@ public:
private:
explicit ClientConnection(NonnullRefPtr<Core::LocalSocket>, int client_id);
virtual void handle(const Messages::NotificationServer::Greet&) override;
virtual void handle(const Messages::NotificationServer::ShowNotification&) override;
virtual void handle(const Messages::NotificationServer::CloseNotification& message) override;
virtual Messages::NotificationServer::UpdateNotificationIconResponse handle(const Messages::NotificationServer::UpdateNotificationIcon& message) override;
virtual Messages::NotificationServer::UpdateNotificationTextResponse handle(const Messages::NotificationServer::UpdateNotificationText& message) override;
virtual Messages::NotificationServer::IsShowingResponse handle(const Messages::NotificationServer::IsShowing& message) override;
virtual void greet() override;
virtual void show_notification(String const&, String const&, Gfx::ShareableBitmap const&) override;
virtual void close_notification() override;
virtual Messages::NotificationServer::UpdateNotificationIconResponse update_notification_icon(Gfx::ShareableBitmap const&) override;
virtual Messages::NotificationServer::UpdateNotificationTextResponse update_notification_text(String const&, String const&) override;
virtual Messages::NotificationServer::IsShowingResponse is_showing() override;
};
}

View file

@ -31,15 +31,14 @@ void ClientConnection::die()
Core::EventLoop::current().quit(0);
}
Messages::RequestServer::IsSupportedProtocolResponse ClientConnection::handle(const Messages::RequestServer::IsSupportedProtocol& message)
Messages::RequestServer::IsSupportedProtocolResponse ClientConnection::is_supported_protocol(String const& protocol)
{
bool supported = Protocol::find_by_name(message.protocol().to_lowercase());
bool supported = Protocol::find_by_name(protocol.to_lowercase());
return supported;
}
Messages::RequestServer::StartRequestResponse ClientConnection::handle(const Messages::RequestServer::StartRequest& message)
Messages::RequestServer::StartRequestResponse ClientConnection::start_request(String const& method, URL const& url, IPC::Dictionary const& request_headers, ByteBuffer const& request_body)
{
const auto& url = message.url();
if (!url.is_valid()) {
dbgln("StartRequest: Invalid URL requested: '{}'", url);
return { -1, Optional<IPC::File> {} };
@ -49,7 +48,7 @@ Messages::RequestServer::StartRequestResponse ClientConnection::handle(const Mes
dbgln("StartRequest: No protocol handler for URL: '{}'", url);
return { -1, Optional<IPC::File> {} };
}
auto request = protocol->start_request(*this, message.method(), url, message.request_headers().entries(), message.request_body());
auto request = protocol->start_request(*this, method, url, request_headers.entries(), request_body);
if (!request) {
dbgln("StartRequest: Protocol handler failed to start request: '{}'", url);
return { -1, Optional<IPC::File> {} };
@ -60,13 +59,13 @@ Messages::RequestServer::StartRequestResponse ClientConnection::handle(const Mes
return { id, IPC::File(fd, IPC::File::CloseAfterSending) };
}
Messages::RequestServer::StopRequestResponse ClientConnection::handle(const Messages::RequestServer::StopRequest& message)
Messages::RequestServer::StopRequestResponse ClientConnection::stop_request(i32 request_id)
{
auto* request = const_cast<Request*>(m_requests.get(message.request_id()).value_or(nullptr));
auto* request = const_cast<Request*>(m_requests.get(request_id).value_or(nullptr));
bool success = false;
if (request) {
request->stop();
m_requests.remove(message.request_id());
m_requests.remove(request_id);
success = true;
}
return success;
@ -100,16 +99,16 @@ void ClientConnection::did_request_certificates(Badge<Request>, Request& request
post_message(Messages::RequestClient::CertificateRequested(request.id()));
}
void ClientConnection::handle(const Messages::RequestServer::Greet&)
void ClientConnection::greet()
{
}
Messages::RequestServer::SetCertificateResponse ClientConnection::handle(const Messages::RequestServer::SetCertificate& message)
Messages::RequestServer::SetCertificateResponse ClientConnection::set_certificate(i32 request_id, String const& certificate, String const& key)
{
auto* request = const_cast<Request*>(m_requests.get(message.request_id()).value_or(nullptr));
auto* request = const_cast<Request*>(m_requests.get(request_id).value_or(nullptr));
bool success = false;
if (request) {
request->set_certificate(message.certificate(), message.key());
request->set_certificate(certificate, key);
success = true;
}
return success;

View file

@ -31,11 +31,11 @@ public:
void did_request_certificates(Badge<Request>, Request&);
private:
virtual void handle(const Messages::RequestServer::Greet&) override;
virtual Messages::RequestServer::IsSupportedProtocolResponse handle(const Messages::RequestServer::IsSupportedProtocol&) override;
virtual Messages::RequestServer::StartRequestResponse handle(const Messages::RequestServer::StartRequest&) override;
virtual Messages::RequestServer::StopRequestResponse handle(const Messages::RequestServer::StopRequest&) override;
virtual Messages::RequestServer::SetCertificateResponse handle(const Messages::RequestServer::SetCertificate&) override;
virtual void greet() override;
virtual Messages::RequestServer::IsSupportedProtocolResponse is_supported_protocol(String const&) override;
virtual Messages::RequestServer::StartRequestResponse start_request(String const&, URL const&, IPC::Dictionary const&, ByteBuffer const&) override;
virtual Messages::RequestServer::StopRequestResponse stop_request(i32) override;
virtual Messages::RequestServer::SetCertificateResponse set_certificate(i32, String const&, String const&) override;
HashMap<i32, OwnPtr<Request>> m_requests;
};

View file

@ -35,13 +35,12 @@ void ClientConnection::die()
s_connections.remove(client_id());
}
void ClientConnection::handle(const Messages::SymbolServer::Greet&)
void ClientConnection::greet()
{
}
Messages::SymbolServer::SymbolicateResponse ClientConnection::handle(const Messages::SymbolServer::Symbolicate& message)
Messages::SymbolServer::SymbolicateResponse ClientConnection::symbolicate(String const& path, u32 address)
{
auto path = message.path();
if (!s_cache.contains(path)) {
auto mapped_file = MappedFile::map(path);
if (mapped_file.is_error()) {
@ -68,8 +67,8 @@ Messages::SymbolServer::SymbolicateResponse ClientConnection::handle(const Messa
return { false, String {}, 0, String {}, 0 };
u32 offset = 0;
auto symbol = cached_elf->debug_info.elf().symbolicate(message.address(), &offset);
auto source_position = cached_elf->debug_info.get_source_position(message.address());
auto symbol = cached_elf->debug_info.elf().symbolicate(address, &offset);
auto source_position = cached_elf->debug_info.get_source_position(address);
String filename;
u32 line_number = 0;
if (source_position.has_value()) {

View file

@ -27,8 +27,8 @@ public:
virtual void die() override;
private:
virtual void handle(const Messages::SymbolServer::Greet&) override;
virtual Messages::SymbolServer::SymbolicateResponse handle(const Messages::SymbolServer::Symbolicate&) override;
virtual void greet() override;
virtual Messages::SymbolServer::SymbolicateResponse symbolicate(String const&, u32) override;
};
}

View file

@ -58,76 +58,76 @@ const Web::Page& ClientConnection::page() const
return m_page_host->page();
}
void ClientConnection::handle(const Messages::WebContentServer::Greet&)
void ClientConnection::greet()
{
}
void ClientConnection::handle(const Messages::WebContentServer::UpdateSystemTheme& message)
void ClientConnection::update_system_theme(const Core::AnonymousBuffer& theme_buffer)
{
Gfx::set_system_theme(message.theme_buffer());
auto impl = Gfx::PaletteImpl::create_with_anonymous_buffer(message.theme_buffer());
Gfx::set_system_theme(theme_buffer);
auto impl = Gfx::PaletteImpl::create_with_anonymous_buffer(theme_buffer);
m_page_host->set_palette_impl(*impl);
}
void ClientConnection::handle(const Messages::WebContentServer::UpdateScreenRect& message)
void ClientConnection::update_screen_rect(const Gfx::IntRect& rect)
{
m_page_host->set_screen_rect(message.rect());
m_page_host->set_screen_rect(rect);
}
void ClientConnection::handle(const Messages::WebContentServer::LoadURL& message)
void ClientConnection::load_url(const URL& url)
{
dbgln_if(SPAM_DEBUG, "handle: WebContentServer::LoadURL: url={}", message.url());
dbgln_if(SPAM_DEBUG, "handle: WebContentServer::LoadURL: url={}", url);
String process_name;
if (message.url().host().is_empty())
if (url.host().is_empty())
process_name = "WebContent";
else
process_name = String::formatted("WebContent: {}", message.url().host());
process_name = String::formatted("WebContent: {}", url.host());
pthread_setname_np(pthread_self(), process_name.characters());
page().load(message.url());
page().load(url);
}
void ClientConnection::handle(const Messages::WebContentServer::LoadHTML& message)
void ClientConnection::load_html(const String& html, const URL& url)
{
dbgln_if(SPAM_DEBUG, "handle: WebContentServer::LoadHTML: html={}, url={}", message.html(), message.url());
page().load_html(message.html(), message.url());
dbgln_if(SPAM_DEBUG, "handle: WebContentServer::LoadHTML: html={}, url={}", html, url);
page().load_html(html, url);
}
void ClientConnection::handle(const Messages::WebContentServer::SetViewportRect& message)
void ClientConnection::set_viewport_rect(const Gfx::IntRect& rect)
{
dbgln_if(SPAM_DEBUG, "handle: WebContentServer::SetViewportRect: rect={}", message.rect());
m_page_host->set_viewport_rect(message.rect());
dbgln_if(SPAM_DEBUG, "handle: WebContentServer::SetViewportRect: rect={}", rect);
m_page_host->set_viewport_rect(rect);
}
void ClientConnection::handle(const Messages::WebContentServer::AddBackingStore& message)
void ClientConnection::add_backing_store(i32 backing_store_id, const Gfx::ShareableBitmap& bitmap)
{
m_backing_stores.set(message.backing_store_id(), *message.bitmap().bitmap());
m_backing_stores.set(backing_store_id, *bitmap.bitmap());
}
void ClientConnection::handle(const Messages::WebContentServer::RemoveBackingStore& message)
void ClientConnection::remove_backing_store(i32 backing_store_id)
{
m_backing_stores.remove(message.backing_store_id());
m_backing_stores.remove(backing_store_id);
}
void ClientConnection::handle(const Messages::WebContentServer::Paint& message)
void ClientConnection::paint(const Gfx::IntRect& content_rect, i32 backing_store_id)
{
for (auto& pending_paint : m_pending_paint_requests) {
if (pending_paint.bitmap_id == message.backing_store_id()) {
pending_paint.content_rect = message.content_rect();
if (pending_paint.bitmap_id == backing_store_id) {
pending_paint.content_rect = content_rect;
return;
}
}
auto it = m_backing_stores.find(message.backing_store_id());
auto it = m_backing_stores.find(backing_store_id);
if (it == m_backing_stores.end()) {
did_misbehave("Client requested paint with backing store ID");
return;
}
auto& bitmap = *it->value;
m_pending_paint_requests.append({ message.content_rect(), bitmap, message.backing_store_id() });
m_pending_paint_requests.append({ content_rect, bitmap, backing_store_id });
m_paint_flush_timer->start();
}
@ -140,46 +140,46 @@ void ClientConnection::flush_pending_paint_requests()
m_pending_paint_requests.clear();
}
void ClientConnection::handle(const Messages::WebContentServer::MouseDown& message)
void ClientConnection::mouse_down(const Gfx::IntPoint& position, unsigned int button, [[maybe_unused]] unsigned int buttons, unsigned int modifiers)
{
page().handle_mousedown(message.position(), message.button(), message.modifiers());
page().handle_mousedown(position, button, modifiers);
}
void ClientConnection::handle(const Messages::WebContentServer::MouseMove& message)
void ClientConnection::mouse_move(const Gfx::IntPoint& position, [[maybe_unused]] unsigned int button, unsigned int buttons, unsigned int modifiers)
{
page().handle_mousemove(message.position(), message.buttons(), message.modifiers());
page().handle_mousemove(position, buttons, modifiers);
}
void ClientConnection::handle(const Messages::WebContentServer::MouseUp& message)
void ClientConnection::mouse_up(const Gfx::IntPoint& position, unsigned int button, [[maybe_unused]] unsigned int buttons, unsigned int modifiers)
{
page().handle_mouseup(message.position(), message.button(), message.modifiers());
page().handle_mouseup(position, button, modifiers);
}
void ClientConnection::handle(const Messages::WebContentServer::MouseWheel& message)
void ClientConnection::mouse_wheel(const Gfx::IntPoint& position, unsigned int button, [[maybe_unused]] unsigned int buttons, unsigned int modifiers, i32 wheel_delta)
{
page().handle_mousewheel(message.position(), message.button(), message.modifiers(), message.wheel_delta());
page().handle_mousewheel(position, button, modifiers, wheel_delta);
}
void ClientConnection::handle(const Messages::WebContentServer::KeyDown& message)
void ClientConnection::key_down(i32 key, unsigned int modifiers, u32 code_point)
{
page().handle_keydown((KeyCode)message.key(), message.modifiers(), message.code_point());
page().handle_keydown((KeyCode)key, modifiers, code_point);
}
void ClientConnection::handle(const Messages::WebContentServer::DebugRequest& message)
void ClientConnection::debug_request(const String& request, const String& argument)
{
if (message.request() == "dump-dom-tree") {
if (request == "dump-dom-tree") {
if (auto* doc = page().main_frame().document())
Web::dump_tree(*doc);
}
if (message.request() == "dump-layout-tree") {
if (request == "dump-layout-tree") {
if (auto* doc = page().main_frame().document()) {
if (auto* icb = doc->layout_node())
Web::dump_tree(*icb);
}
}
if (message.request() == "dump-style-sheets") {
if (request == "dump-style-sheets") {
if (auto* doc = page().main_frame().document()) {
for (auto& sheet : doc->style_sheets().sheets()) {
Web::dump_sheet(sheet);
@ -187,33 +187,33 @@ void ClientConnection::handle(const Messages::WebContentServer::DebugRequest& me
}
}
if (message.request() == "collect-garbage") {
if (request == "collect-garbage") {
Web::Bindings::main_thread_vm().heap().collect_garbage(JS::Heap::CollectionType::CollectGarbage, true);
}
if (message.request() == "set-line-box-borders") {
bool state = message.argument() == "on";
if (request == "set-line-box-borders") {
bool state = argument == "on";
m_page_host->set_should_show_line_box_borders(state);
page().main_frame().set_needs_display(page().main_frame().viewport_rect());
}
if (message.request() == "clear-cache") {
if (request == "clear-cache") {
Web::ResourceLoader::the().clear_cache();
}
if (message.request() == "spoof-user-agent") {
Web::ResourceLoader::the().set_user_agent(message.argument());
if (request == "spoof-user-agent") {
Web::ResourceLoader::the().set_user_agent(argument);
}
}
void ClientConnection::handle(const Messages::WebContentServer::GetSource&)
void ClientConnection::get_source()
{
if (auto* doc = page().main_frame().document()) {
post_message(Messages::WebContentClient::DidGetSource(doc->url(), doc->source()));
}
}
void ClientConnection::handle(const Messages::WebContentServer::JSConsoleInitialize&)
void ClientConnection::jsconsole_initialize()
{
if (auto* document = page().main_frame().document()) {
auto interpreter = document->interpreter().make_weak_ptr();
@ -226,10 +226,10 @@ void ClientConnection::handle(const Messages::WebContentServer::JSConsoleInitial
}
}
void ClientConnection::handle(const Messages::WebContentServer::JSConsoleInput& message)
void ClientConnection::jsconsole_input(const String& js_source)
{
if (m_console_client)
m_console_client->handle_input(message.js_source());
m_console_client->handle_input(js_source);
}
}

View file

@ -33,24 +33,24 @@ private:
Web::Page& page();
const Web::Page& page() const;
virtual void handle(const Messages::WebContentServer::Greet&) override;
virtual void handle(const Messages::WebContentServer::UpdateSystemTheme&) override;
virtual void handle(const Messages::WebContentServer::UpdateScreenRect&) override;
virtual void handle(const Messages::WebContentServer::LoadURL&) override;
virtual void handle(const Messages::WebContentServer::LoadHTML&) override;
virtual void handle(const Messages::WebContentServer::Paint&) override;
virtual void handle(const Messages::WebContentServer::SetViewportRect&) override;
virtual void handle(const Messages::WebContentServer::MouseDown&) override;
virtual void handle(const Messages::WebContentServer::MouseMove&) override;
virtual void handle(const Messages::WebContentServer::MouseUp&) override;
virtual void handle(const Messages::WebContentServer::MouseWheel&) override;
virtual void handle(const Messages::WebContentServer::KeyDown&) override;
virtual void handle(const Messages::WebContentServer::AddBackingStore&) override;
virtual void handle(const Messages::WebContentServer::RemoveBackingStore&) override;
virtual void handle(const Messages::WebContentServer::DebugRequest&) override;
virtual void handle(const Messages::WebContentServer::GetSource&) override;
virtual void handle(const Messages::WebContentServer::JSConsoleInitialize&) override;
virtual void handle(const Messages::WebContentServer::JSConsoleInput&) override;
virtual void greet() override;
virtual void update_system_theme(Core::AnonymousBuffer const&) override;
virtual void update_screen_rect(Gfx::IntRect const&) override;
virtual void load_url(URL const&) override;
virtual void load_html(String const&, URL const&) override;
virtual void paint(Gfx::IntRect const&, i32) override;
virtual void set_viewport_rect(Gfx::IntRect const&) override;
virtual void mouse_down(Gfx::IntPoint const&, unsigned, unsigned, unsigned) override;
virtual void mouse_move(Gfx::IntPoint const&, unsigned, unsigned, unsigned) override;
virtual void mouse_up(Gfx::IntPoint const&, unsigned, unsigned, unsigned) override;
virtual void mouse_wheel(Gfx::IntPoint const&, unsigned, unsigned, unsigned, i32) override;
virtual void key_down(i32, unsigned, u32) override;
virtual void add_backing_store(i32, Gfx::ShareableBitmap const&) override;
virtual void remove_backing_store(i32) override;
virtual void debug_request(String const&, String const&) override;
virtual void get_source() override;
virtual void jsconsole_initialize() override;
virtual void jsconsole_input(String const&) override;
void flush_pending_paint_requests();

View file

@ -31,25 +31,25 @@ void ClientConnection::die()
Core::EventLoop::current().quit(0);
}
void ClientConnection::handle(const Messages::WebSocketServer::Greet&)
void ClientConnection::greet()
{
}
Messages::WebSocketServer::ConnectResponse ClientConnection::handle(const Messages::WebSocketServer::Connect& message)
Messages::WebSocketServer::ConnectResponse ClientConnection::connect(URL const& url, String const& origin,
Vector<String> const& protocols, Vector<String> const& extensions, IPC::Dictionary const& additional_request_headers)
{
const auto& url = message.url();
if (!url.is_valid()) {
dbgln("WebSocket::Connect: Invalid URL requested: '{}'", url);
return -1;
}
ConnectionInfo connection_info(url);
connection_info.set_origin(message.origin());
connection_info.set_protocols(message.protocols());
connection_info.set_extensions(message.extensions());
connection_info.set_origin(origin);
connection_info.set_protocols(protocols);
connection_info.set_extensions(extensions);
Vector<ConnectionInfo::Header> headers;
for (const auto& header : message.additional_request_headers().entries()) {
for (auto const& header : additional_request_headers.entries()) {
headers.append({ header.key, header.value });
}
connection_info.set_headers(headers);
@ -75,38 +75,39 @@ Messages::WebSocketServer::ConnectResponse ClientConnection::handle(const Messag
return id;
}
Messages::WebSocketServer::ReadyStateResponse ClientConnection::handle(const Messages::WebSocketServer::ReadyState& message)
Messages::WebSocketServer::ReadyStateResponse ClientConnection::ready_state(i32 connection_id)
{
RefPtr<WebSocket> connection = m_connections.get(message.connection_id()).value_or({});
RefPtr<WebSocket> connection = m_connections.get(connection_id).value_or({});
if (connection) {
return (u32)connection->ready_state();
}
return (u32)ReadyState::Closed;
}
void ClientConnection::handle(const Messages::WebSocketServer::Send& message)
void ClientConnection::send(i32 connection_id, bool is_text, ByteBuffer const& data)
{
RefPtr<WebSocket> connection = m_connections.get(message.connection_id()).value_or({});
RefPtr<WebSocket> connection = m_connections.get(connection_id).value_or({});
if (connection && connection->ready_state() == ReadyState::Open) {
Message websocket_message(message.data(), message.is_text());
Message websocket_message(data, is_text);
connection->send(websocket_message);
}
}
void ClientConnection::handle(const Messages::WebSocketServer::Close& message)
void ClientConnection::close(i32 connection_id, u16 code, String const& reason)
{
RefPtr<WebSocket> connection = m_connections.get(message.connection_id()).value_or({});
RefPtr<WebSocket> connection = m_connections.get(connection_id).value_or({});
if (connection && connection->ready_state() == ReadyState::Open)
connection->close(message.code(), message.reason());
connection->close(code, reason);
}
Messages::WebSocketServer::SetCertificateResponse ClientConnection::handle(const Messages::WebSocketServer::SetCertificate& message)
Messages::WebSocketServer::SetCertificateResponse ClientConnection::set_certificate(i32 connection_id,
[[maybe_unused]] String const& certificate, [[maybe_unused]] String const& key)
{
RefPtr<WebSocket> connection = m_connections.get(message.connection_id()).value_or({});
RefPtr<WebSocket> connection = m_connections.get(connection_id).value_or({});
bool success = false;
if (connection) {
// NO OP here
// connection->set_certificate(message.certificate(), message.key());
// connection->set_certificate(certificate, key);
success = true;
}
return success;

View file

@ -26,12 +26,12 @@ public:
virtual void die() override;
private:
virtual void handle(const Messages::WebSocketServer::Greet&) override;
virtual Messages::WebSocketServer::ConnectResponse handle(const Messages::WebSocketServer::Connect&) override;
virtual Messages::WebSocketServer::ReadyStateResponse handle(const Messages::WebSocketServer::ReadyState&) override;
virtual void handle(const Messages::WebSocketServer::Send&) override;
virtual void handle(const Messages::WebSocketServer::Close&) override;
virtual Messages::WebSocketServer::SetCertificateResponse handle(const Messages::WebSocketServer::SetCertificate&) override;
virtual void greet() override;
virtual Messages::WebSocketServer::ConnectResponse connect(URL const&, String const&, Vector<String> const&, Vector<String> const&, IPC::Dictionary const&) override;
virtual Messages::WebSocketServer::ReadyStateResponse ready_state(i32) override;
virtual void send(i32, bool, ByteBuffer const&) override;
virtual void close(i32, u16, String const&) override;
virtual Messages::WebSocketServer::SetCertificateResponse set_certificate(i32, String const&, String const&) override;
void did_connect(i32);
void did_receive_message(i32, Message);

View file

@ -76,12 +76,12 @@ void ClientConnection::die()
});
}
void ClientConnection::notify_about_new_screen_rect(const Gfx::IntRect& rect)
void ClientConnection::notify_about_new_screen_rect(Gfx::IntRect const& rect)
{
post_message(Messages::WindowClient::ScreenRectChanged(rect));
}
Messages::WindowServer::CreateMenubarResponse ClientConnection::handle(const Messages::WindowServer::CreateMenubar&)
Messages::WindowServer::CreateMenubarResponse ClientConnection::create_menubar()
{
int menubar_id = m_next_menubar_id++;
auto menubar = Menubar::create(*this, menubar_id);
@ -89,9 +89,8 @@ Messages::WindowServer::CreateMenubarResponse ClientConnection::handle(const Mes
return menubar_id;
}
void ClientConnection::handle(const Messages::WindowServer::DestroyMenubar& message)
void ClientConnection::destroy_menubar(i32 menubar_id)
{
int menubar_id = message.menubar_id();
auto it = m_menubars.find(menubar_id);
if (it == m_menubars.end()) {
did_misbehave("DestroyMenubar: Bad menubar ID");
@ -100,17 +99,16 @@ void ClientConnection::handle(const Messages::WindowServer::DestroyMenubar& mess
m_menubars.remove(it);
}
Messages::WindowServer::CreateMenuResponse ClientConnection::handle(const Messages::WindowServer::CreateMenu& message)
Messages::WindowServer::CreateMenuResponse ClientConnection::create_menu(String const& menu_title)
{
int menu_id = m_next_menu_id++;
auto menu = Menu::construct(this, menu_id, message.menu_title());
auto menu = Menu::construct(this, menu_id, menu_title);
m_menus.set(menu_id, move(menu));
return menu_id;
}
void ClientConnection::handle(const Messages::WindowServer::DestroyMenu& message)
void ClientConnection::destroy_menu(i32 menu_id)
{
int menu_id = message.menu_id();
auto it = m_menus.find(menu_id);
if (it == m_menus.end()) {
did_misbehave("DestroyMenu: Bad menu ID");
@ -122,11 +120,11 @@ void ClientConnection::handle(const Messages::WindowServer::DestroyMenu& message
remove_child(menu);
}
void ClientConnection::handle(const Messages::WindowServer::SetWindowMenubar& message)
void ClientConnection::set_window_menubar(i32 window_id, i32 menubar_id)
{
RefPtr<Window> window;
{
auto it = m_windows.find(message.window_id());
auto it = m_windows.find(window_id);
if (it == m_windows.end()) {
did_misbehave("SetWindowMenubar: Bad window ID");
return;
@ -134,8 +132,8 @@ void ClientConnection::handle(const Messages::WindowServer::SetWindowMenubar& me
window = it->value;
}
RefPtr<Menubar> menubar;
if (message.menubar_id() != -1) {
auto it = m_menubars.find(message.menubar_id());
if (menubar_id != -1) {
auto it = m_menubars.find(menubar_id);
if (it == m_menubars.end()) {
did_misbehave("SetWindowMenubar: Bad menubar ID");
return;
@ -145,10 +143,8 @@ void ClientConnection::handle(const Messages::WindowServer::SetWindowMenubar& me
window->set_menubar(menubar);
}
void ClientConnection::handle(const Messages::WindowServer::AddMenuToMenubar& message)
void ClientConnection::add_menu_to_menubar(i32 menubar_id, i32 menu_id)
{
int menubar_id = message.menubar_id();
int menu_id = message.menu_id();
auto it = m_menubars.find(menubar_id);
auto jt = m_menus.find(menu_id);
if (it == m_menubars.end()) {
@ -164,29 +160,28 @@ void ClientConnection::handle(const Messages::WindowServer::AddMenuToMenubar& me
menubar.add_menu(menu);
}
void ClientConnection::handle(const Messages::WindowServer::AddMenuItem& message)
void ClientConnection::add_menu_item(i32 menu_id, i32 identifier, i32 submenu_id,
String const& text, bool enabled, bool checkable, bool checked, bool is_default,
String const& shortcut, Gfx::ShareableBitmap const& icon, bool exclusive)
{
int menu_id = message.menu_id();
unsigned identifier = message.identifier();
auto it = m_menus.find(menu_id);
if (it == m_menus.end()) {
dbgln("AddMenuItem: Bad menu ID: {}", menu_id);
return;
}
auto& menu = *(*it).value;
auto menu_item = make<MenuItem>(menu, identifier, message.text(), message.shortcut(), message.enabled(), message.checkable(), message.checked());
if (message.is_default())
auto menu_item = make<MenuItem>(menu, identifier, text, shortcut, enabled, checkable, checked);
if (is_default)
menu_item->set_default(true);
menu_item->set_icon(message.icon().bitmap());
menu_item->set_submenu_id(message.submenu_id());
menu_item->set_exclusive(message.exclusive());
menu_item->set_icon(icon.bitmap());
menu_item->set_submenu_id(submenu_id);
menu_item->set_exclusive(exclusive);
menu.add_item(move(menu_item));
}
void ClientConnection::handle(const Messages::WindowServer::PopupMenu& message)
void ClientConnection::popup_menu(i32 menu_id, Gfx::IntPoint const& screen_position)
{
int menu_id = message.menu_id();
auto position = message.screen_position();
auto position = screen_position;
auto it = m_menus.find(menu_id);
if (it == m_menus.end()) {
did_misbehave("PopupMenu: Bad menu ID");
@ -196,9 +191,8 @@ void ClientConnection::handle(const Messages::WindowServer::PopupMenu& message)
menu.popup(position);
}
void ClientConnection::handle(const Messages::WindowServer::DismissMenu& message)
void ClientConnection::dismiss_menu(i32 menu_id)
{
int menu_id = message.menu_id();
auto it = m_menus.find(menu_id);
if (it == m_menus.end()) {
did_misbehave("DismissMenu: Bad menu ID");
@ -208,32 +202,32 @@ void ClientConnection::handle(const Messages::WindowServer::DismissMenu& message
menu.close();
}
void ClientConnection::handle(const Messages::WindowServer::UpdateMenuItem& message)
void ClientConnection::update_menu_item(i32 menu_id, i32 identifier, [[maybe_unused]] i32 submenu_id,
String const& text, bool enabled, bool checkable, bool checked, bool is_default,
String const& shortcut)
{
int menu_id = message.menu_id();
auto it = m_menus.find(menu_id);
if (it == m_menus.end()) {
did_misbehave("UpdateMenuItem: Bad menu ID");
return;
}
auto& menu = *(*it).value;
auto* menu_item = menu.item_with_identifier(message.identifier());
auto* menu_item = menu.item_with_identifier(identifier);
if (!menu_item) {
did_misbehave("UpdateMenuItem: Bad menu item identifier");
return;
}
menu_item->set_text(message.text());
menu_item->set_shortcut_text(message.shortcut());
menu_item->set_enabled(message.enabled());
menu_item->set_checkable(message.checkable());
menu_item->set_default(message.is_default());
if (message.checkable())
menu_item->set_checked(message.checked());
menu_item->set_text(text);
menu_item->set_shortcut_text(shortcut);
menu_item->set_enabled(enabled);
menu_item->set_checkable(checkable);
menu_item->set_default(is_default);
if (checkable)
menu_item->set_checked(checked);
}
void ClientConnection::handle(const Messages::WindowServer::AddMenuSeparator& message)
void ClientConnection::add_menu_separator(i32 menu_id)
{
int menu_id = message.menu_id();
auto it = m_menus.find(menu_id);
if (it == m_menus.end()) {
did_misbehave("AddMenuSeparator: Bad menu ID");
@ -243,9 +237,9 @@ void ClientConnection::handle(const Messages::WindowServer::AddMenuSeparator& me
menu.add_item(make<MenuItem>(menu, MenuItem::Separator));
}
void ClientConnection::handle(const Messages::WindowServer::MoveWindowToFront& message)
void ClientConnection::move_window_to_front(i32 window_id)
{
auto it = m_windows.find(message.window_id());
auto it = m_windows.find(window_id);
if (it == m_windows.end()) {
did_misbehave("MoveWindowToFront: Bad window ID");
return;
@ -253,77 +247,77 @@ void ClientConnection::handle(const Messages::WindowServer::MoveWindowToFront& m
WindowManager::the().move_to_front_and_make_active(*(*it).value);
}
void ClientConnection::handle(const Messages::WindowServer::SetFullscreen& message)
void ClientConnection::set_fullscreen(i32 window_id, bool fullscreen)
{
auto it = m_windows.find(message.window_id());
auto it = m_windows.find(window_id);
if (it == m_windows.end()) {
did_misbehave("SetFullscreen: Bad window ID");
return;
}
it->value->set_fullscreen(message.fullscreen());
it->value->set_fullscreen(fullscreen);
}
void ClientConnection::handle(const Messages::WindowServer::SetFrameless& message)
void ClientConnection::set_frameless(i32 window_id, bool frameless)
{
auto it = m_windows.find(message.window_id());
auto it = m_windows.find(window_id);
if (it == m_windows.end()) {
did_misbehave("SetFrameless: Bad window ID");
return;
}
it->value->set_frameless(message.frameless());
it->value->set_frameless(frameless);
WindowManager::the().tell_wms_window_state_changed(*it->value);
}
void ClientConnection::handle(const Messages::WindowServer::SetWindowOpacity& message)
void ClientConnection::set_window_opacity(i32 window_id, float opacity)
{
auto it = m_windows.find(message.window_id());
auto it = m_windows.find(window_id);
if (it == m_windows.end()) {
did_misbehave("SetWindowOpacity: Bad window ID");
return;
}
it->value->set_opacity(message.opacity());
it->value->set_opacity(opacity);
}
void ClientConnection::handle(const Messages::WindowServer::AsyncSetWallpaper& message)
void ClientConnection::async_set_wallpaper(String const& path)
{
Compositor::the().set_wallpaper(message.path(), [&](bool success) {
Compositor::the().set_wallpaper(path, [&](bool success) {
post_message(Messages::WindowClient::AsyncSetWallpaperFinished(success));
});
}
void ClientConnection::handle(const Messages::WindowServer::SetBackgroundColor& message)
void ClientConnection::set_background_color(String const& background_color)
{
Compositor::the().set_background_color(message.background_color());
Compositor::the().set_background_color(background_color);
}
void ClientConnection::handle(const Messages::WindowServer::SetWallpaperMode& message)
void ClientConnection::set_wallpaper_mode(String const& mode)
{
Compositor::the().set_wallpaper_mode(message.mode());
Compositor::the().set_wallpaper_mode(mode);
}
Messages::WindowServer::GetWallpaperResponse ClientConnection::handle(const Messages::WindowServer::GetWallpaper&)
Messages::WindowServer::GetWallpaperResponse ClientConnection::get_wallpaper()
{
return Compositor::the().wallpaper_path();
}
Messages::WindowServer::SetResolutionResponse ClientConnection::handle(const Messages::WindowServer::SetResolution& message)
Messages::WindowServer::SetResolutionResponse ClientConnection::set_resolution(Gfx::IntSize const& resolution, int scale_factor)
{
return { WindowManager::the().set_resolution(message.resolution().width(), message.resolution().height(), message.scale_factor()), WindowManager::the().resolution(), WindowManager::the().scale_factor() };
return { WindowManager::the().set_resolution(resolution.width(), resolution.height(), scale_factor), WindowManager::the().resolution(), WindowManager::the().scale_factor() };
}
void ClientConnection::handle(const Messages::WindowServer::SetWindowTitle& message)
void ClientConnection::set_window_title(i32 window_id, String const& title)
{
auto it = m_windows.find(message.window_id());
auto it = m_windows.find(window_id);
if (it == m_windows.end()) {
did_misbehave("SetWindowTitle: Bad window ID");
return;
}
it->value->set_title(message.title());
it->value->set_title(title);
}
Messages::WindowServer::GetWindowTitleResponse ClientConnection::handle(const Messages::WindowServer::GetWindowTitle& message)
Messages::WindowServer::GetWindowTitleResponse ClientConnection::get_window_title(i32 window_id)
{
auto it = m_windows.find(message.window_id());
auto it = m_windows.find(window_id);
if (it == m_windows.end()) {
did_misbehave("GetWindowTitle: Bad window ID");
return nullptr;
@ -331,9 +325,9 @@ Messages::WindowServer::GetWindowTitleResponse ClientConnection::handle(const Me
return it->value->title();
}
Messages::WindowServer::IsMaximizedResponse ClientConnection::handle(const Messages::WindowServer::IsMaximized& message)
Messages::WindowServer::IsMaximizedResponse ClientConnection::is_maximized(i32 window_id)
{
auto it = m_windows.find(message.window_id());
auto it = m_windows.find(window_id);
if (it == m_windows.end()) {
did_misbehave("IsMaximized: Bad window ID");
return nullptr;
@ -341,17 +335,17 @@ Messages::WindowServer::IsMaximizedResponse ClientConnection::handle(const Messa
return it->value->is_maximized();
}
void ClientConnection::handle(const Messages::WindowServer::SetWindowIconBitmap& message)
void ClientConnection::set_window_icon_bitmap(i32 window_id, Gfx::ShareableBitmap const& icon)
{
auto it = m_windows.find(message.window_id());
auto it = m_windows.find(window_id);
if (it == m_windows.end()) {
did_misbehave("SetWindowIconBitmap: Bad window ID");
return;
}
auto& window = *(*it).value;
if (message.icon().is_valid()) {
window.set_icon(*message.icon().bitmap());
if (icon.is_valid()) {
window.set_icon(*icon.bitmap());
} else {
window.set_default_icon();
}
@ -360,9 +354,8 @@ void ClientConnection::handle(const Messages::WindowServer::SetWindowIconBitmap&
WindowManager::the().tell_wms_window_icon_changed(window);
}
Messages::WindowServer::SetWindowRectResponse ClientConnection::handle(const Messages::WindowServer::SetWindowRect& message)
Messages::WindowServer::SetWindowRectResponse ClientConnection::set_window_rect(i32 window_id, Gfx::IntRect const& rect)
{
int window_id = message.window_id();
auto it = m_windows.find(window_id);
if (it == m_windows.end()) {
did_misbehave("SetWindowRect: Bad window ID");
@ -374,20 +367,19 @@ Messages::WindowServer::SetWindowRectResponse ClientConnection::handle(const Mes
return nullptr;
}
if (message.rect().location() != window.rect().location()) {
if (rect.location() != window.rect().location()) {
window.set_default_positioned(false);
}
auto rect = message.rect();
window.apply_minimum_size(rect);
window.set_rect(rect);
auto new_rect = rect;
window.apply_minimum_size(new_rect);
window.set_rect(new_rect);
window.nudge_into_desktop();
window.request_update(window.rect());
return window.rect();
}
Messages::WindowServer::GetWindowRectResponse ClientConnection::handle(const Messages::WindowServer::GetWindowRect& message)
Messages::WindowServer::GetWindowRectResponse ClientConnection::get_window_rect(i32 window_id)
{
int window_id = message.window_id();
auto it = m_windows.find(window_id);
if (it == m_windows.end()) {
did_misbehave("GetWindowRect: Bad window ID");
@ -396,9 +388,8 @@ Messages::WindowServer::GetWindowRectResponse ClientConnection::handle(const Mes
return it->value->rect();
}
void ClientConnection::handle(const Messages::WindowServer::SetWindowMinimumSize& message)
void ClientConnection::set_window_minimum_size(i32 window_id, Gfx::IntSize const& size)
{
int window_id = message.window_id();
auto it = m_windows.find(window_id);
if (it == m_windows.end()) {
did_misbehave("SetWindowMinimumSize: Bad window ID");
@ -410,7 +401,7 @@ void ClientConnection::handle(const Messages::WindowServer::SetWindowMinimumSize
return;
}
window.set_minimum_size(message.size());
window.set_minimum_size(size);
if (window.width() < window.minimum_size().width() || window.height() < window.minimum_size().height()) {
// New minimum size is larger than the current window size, resize accordingly.
@ -425,9 +416,8 @@ void ClientConnection::handle(const Messages::WindowServer::SetWindowMinimumSize
}
}
Messages::WindowServer::GetWindowMinimumSizeResponse ClientConnection::handle(const Messages::WindowServer::GetWindowMinimumSize& message)
Messages::WindowServer::GetWindowMinimumSizeResponse ClientConnection::get_window_minimum_size(i32 window_id)
{
int window_id = message.window_id();
auto it = m_windows.find(window_id);
if (it == m_windows.end()) {
did_misbehave("GetWindowMinimumSize: Bad window ID");
@ -436,9 +426,8 @@ Messages::WindowServer::GetWindowMinimumSizeResponse ClientConnection::handle(co
return it->value->minimum_size();
}
Messages::WindowServer::GetAppletRectOnScreenResponse ClientConnection::handle(const Messages::WindowServer::GetAppletRectOnScreen& message)
Messages::WindowServer::GetAppletRectOnScreenResponse ClientConnection::get_applet_rect_on_screen(i32 window_id)
{
int window_id = message.window_id();
auto it = m_windows.find(window_id);
if (it == m_windows.end()) {
did_misbehave("GetAppletRectOnScreen: Bad window ID");
@ -460,11 +449,15 @@ Window* ClientConnection::window_from_id(i32 window_id)
return it->value.ptr();
}
Messages::WindowServer::CreateWindowResponse ClientConnection::handle(const Messages::WindowServer::CreateWindow& message)
Messages::WindowServer::CreateWindowResponse ClientConnection::create_window(Gfx::IntRect const& rect,
bool auto_position, bool has_alpha_channel, bool modal, bool minimizable, bool resizable,
bool fullscreen, bool frameless, bool accessory, float opacity, float alpha_hit_threshold,
Gfx::IntSize const& base_size, Gfx::IntSize const& size_increment, Gfx::IntSize const& minimum_size,
Optional<Gfx::IntSize> const& resize_aspect_ratio, i32 type, String const& title, i32 parent_window_id)
{
Window* parent_window = nullptr;
if (message.parent_window_id()) {
parent_window = window_from_id(message.parent_window_id());
if (parent_window_id) {
parent_window = window_from_id(parent_window_id);
if (!parent_window) {
did_misbehave("CreateWindow with bad parent_window_id");
return nullptr;
@ -472,19 +465,19 @@ Messages::WindowServer::CreateWindowResponse ClientConnection::handle(const Mess
}
int window_id = m_next_window_id++;
auto window = Window::construct(*this, (WindowType)message.type(), window_id, message.modal(), message.minimizable(), message.frameless(), message.resizable(), message.fullscreen(), message.accessory(), parent_window);
auto window = Window::construct(*this, (WindowType)type, window_id, modal, minimizable, frameless, resizable, fullscreen, accessory, parent_window);
window->set_has_alpha_channel(message.has_alpha_channel());
window->set_title(message.title());
if (!message.fullscreen()) {
auto rect = message.rect();
if (message.auto_position() && window->is_movable()) {
rect = { WindowManager::the().get_recommended_window_position({ 100, 100 }), message.rect().size() };
window->set_has_alpha_channel(has_alpha_channel);
window->set_title(title);
if (!fullscreen) {
Gfx::IntRect new_rect = rect;
if (auto_position && window->is_movable()) {
new_rect = { WindowManager::the().get_recommended_window_position({ 100, 100 }), rect.size() };
window->set_default_positioned(true);
}
window->set_minimum_size(message.minimum_size());
bool did_size_clamp = window->apply_minimum_size(rect);
window->set_rect(rect);
window->set_minimum_size(minimum_size);
bool did_size_clamp = window->apply_minimum_size(new_rect);
window->set_rect(new_rect);
window->nudge_into_desktop();
if (did_size_clamp)
@ -494,11 +487,11 @@ Messages::WindowServer::CreateWindowResponse ClientConnection::handle(const Mess
window->set_rect(WindowManager::the().desktop_rect());
window->recalculate_rect();
}
window->set_opacity(message.opacity());
window->set_alpha_hit_threshold(message.alpha_hit_threshold());
window->set_size_increment(message.size_increment());
window->set_base_size(message.base_size());
window->set_resize_aspect_ratio(message.resize_aspect_ratio());
window->set_opacity(opacity);
window->set_alpha_hit_threshold(alpha_hit_threshold);
window->set_size_increment(size_increment);
window->set_base_size(base_size);
window->set_resize_aspect_ratio(resize_aspect_ratio);
window->invalidate(true, true);
if (window->type() == WindowType::Applet)
AppletManager::the().add_applet(*window);
@ -532,9 +525,9 @@ void ClientConnection::destroy_window(Window& window, Vector<i32>& destroyed_win
m_windows.remove(window.window_id());
}
Messages::WindowServer::DestroyWindowResponse ClientConnection::handle(const Messages::WindowServer::DestroyWindow& message)
Messages::WindowServer::DestroyWindowResponse ClientConnection::destroy_window(i32 window_id)
{
auto it = m_windows.find(message.window_id());
auto it = m_windows.find(window_id);
if (it == m_windows.end()) {
did_misbehave("DestroyWindow: Bad window ID");
return nullptr;
@ -554,28 +547,27 @@ void ClientConnection::post_paint_message(Window& window, bool ignore_occlusion)
post_message(Messages::WindowClient::Paint(window.window_id(), window.size(), rect_set.rects()));
}
void ClientConnection::handle(const Messages::WindowServer::InvalidateRect& message)
void ClientConnection::invalidate_rect(i32 window_id, Vector<Gfx::IntRect> const& rects, bool ignore_occlusion)
{
auto it = m_windows.find(message.window_id());
auto it = m_windows.find(window_id);
if (it == m_windows.end()) {
did_misbehave("InvalidateRect: Bad window ID");
return;
}
auto& window = *(*it).value;
for (size_t i = 0; i < message.rects().size(); ++i)
window.request_update(message.rects()[i].intersected({ {}, window.size() }), message.ignore_occlusion());
for (size_t i = 0; i < rects.size(); ++i)
window.request_update(rects[i].intersected({ {}, window.size() }), ignore_occlusion);
}
void ClientConnection::handle(const Messages::WindowServer::DidFinishPainting& message)
void ClientConnection::did_finish_painting(i32 window_id, Vector<Gfx::IntRect> const& rects)
{
int window_id = message.window_id();
auto it = m_windows.find(window_id);
if (it == m_windows.end()) {
did_misbehave("DidFinishPainting: Bad window ID");
return;
}
auto& window = *(*it).value;
for (auto& rect : message.rects())
for (auto& rect : rects)
window.invalidate(rect);
if (window.has_alpha_channel() && window.alpha_hit_threshold() > 0.0f)
WindowManager::the().reevaluate_hovered_window(&window);
@ -583,102 +575,102 @@ void ClientConnection::handle(const Messages::WindowServer::DidFinishPainting& m
WindowSwitcher::the().refresh_if_needed();
}
void ClientConnection::handle(const Messages::WindowServer::SetWindowBackingStore& message)
void ClientConnection::set_window_backing_store(i32 window_id, [[maybe_unused]] i32 bpp,
[[maybe_unused]] i32 pitch, IPC::File const& anon_file, i32 serial, bool has_alpha_channel,
Gfx::IntSize const& size, bool flush_immediately)
{
int window_id = message.window_id();
auto it = m_windows.find(window_id);
if (it == m_windows.end()) {
did_misbehave("SetWindowBackingStore: Bad window ID");
return;
}
auto& window = *(*it).value;
if (window.last_backing_store() && window.last_backing_store_serial() == message.serial()) {
if (window.last_backing_store() && window.last_backing_store_serial() == serial) {
window.swap_backing_stores();
} else {
// FIXME: Plumb scale factor here eventually.
auto backing_store = Gfx::Bitmap::create_with_anon_fd(
message.has_alpha_channel() ? Gfx::BitmapFormat::BGRA8888 : Gfx::BitmapFormat::BGRx8888,
message.anon_file().take_fd(),
message.size(),
has_alpha_channel ? Gfx::BitmapFormat::BGRA8888 : Gfx::BitmapFormat::BGRx8888,
anon_file.take_fd(),
size,
1,
{},
Gfx::Bitmap::ShouldCloseAnonymousFile::Yes);
window.set_backing_store(move(backing_store), message.serial());
window.set_backing_store(move(backing_store), serial);
}
if (message.flush_immediately())
if (flush_immediately)
window.invalidate(false);
}
void ClientConnection::handle(const Messages::WindowServer::SetGlobalCursorTracking& message)
void ClientConnection::set_global_cursor_tracking(i32 window_id, bool enabled)
{
int window_id = message.window_id();
auto it = m_windows.find(window_id);
if (it == m_windows.end()) {
did_misbehave("SetGlobalCursorTracking: Bad window ID");
return;
}
it->value->set_global_cursor_tracking_enabled(message.enabled());
it->value->set_global_cursor_tracking_enabled(enabled);
}
void ClientConnection::handle(const Messages::WindowServer::SetWindowCursor& message)
void ClientConnection::set_window_cursor(i32 window_id, i32 cursor_type)
{
auto it = m_windows.find(message.window_id());
auto it = m_windows.find(window_id);
if (it == m_windows.end()) {
did_misbehave("SetWindowCursor: Bad window ID");
return;
}
auto& window = *(*it).value;
if (message.cursor_type() < 0 || message.cursor_type() >= (i32)Gfx::StandardCursor::__Count) {
if (cursor_type < 0 || cursor_type >= (i32)Gfx::StandardCursor::__Count) {
did_misbehave("SetWindowCursor: Bad cursor type");
return;
}
window.set_cursor(Cursor::create((Gfx::StandardCursor)message.cursor_type()));
window.set_cursor(Cursor::create((Gfx::StandardCursor)cursor_type));
if (&window == WindowManager::the().hovered_window())
Compositor::the().invalidate_cursor();
}
void ClientConnection::handle(const Messages::WindowServer::SetWindowCustomCursor& message)
void ClientConnection::set_window_custom_cursor(i32 window_id, Gfx::ShareableBitmap const& cursor)
{
auto it = m_windows.find(message.window_id());
auto it = m_windows.find(window_id);
if (it == m_windows.end()) {
did_misbehave("SetWindowCustomCursor: Bad window ID");
return;
}
auto& window = *(*it).value;
if (!message.cursor().is_valid()) {
if (!cursor.is_valid()) {
did_misbehave("SetWindowCustomCursor: Bad cursor");
return;
}
window.set_cursor(Cursor::create(*message.cursor().bitmap()));
window.set_cursor(Cursor::create(*cursor.bitmap()));
Compositor::the().invalidate_cursor();
}
void ClientConnection::handle(const Messages::WindowServer::SetWindowHasAlphaChannel& message)
void ClientConnection::set_window_has_alpha_channel(i32 window_id, bool has_alpha_channel)
{
auto it = m_windows.find(message.window_id());
auto it = m_windows.find(window_id);
if (it == m_windows.end()) {
did_misbehave("SetWindowHasAlphaChannel: Bad window ID");
return;
}
it->value->set_has_alpha_channel(message.has_alpha_channel());
it->value->set_has_alpha_channel(has_alpha_channel);
}
void ClientConnection::handle(const Messages::WindowServer::SetWindowAlphaHitThreshold& message)
void ClientConnection::set_window_alpha_hit_threshold(i32 window_id, float threshold)
{
auto it = m_windows.find(message.window_id());
auto it = m_windows.find(window_id);
if (it == m_windows.end()) {
did_misbehave("SetWindowAlphaHitThreshold: Bad window ID");
return;
}
it->value->set_alpha_hit_threshold(message.threshold());
it->value->set_alpha_hit_threshold(threshold);
}
void ClientConnection::handle(const Messages::WindowServer::StartWindowResize& request)
void ClientConnection::start_window_resize(i32 window_id)
{
auto it = m_windows.find(request.window_id());
auto it = m_windows.find(window_id);
if (it == m_windows.end()) {
did_misbehave("WM_StartWindowResize: Bad window ID");
return;
@ -689,60 +681,60 @@ void ClientConnection::handle(const Messages::WindowServer::StartWindowResize& r
WindowManager::the().start_window_resize(window, Screen::the().cursor_location(), MouseButton::Left);
}
Messages::WindowServer::GreetResponse ClientConnection::handle(const Messages::WindowServer::Greet&)
Messages::WindowServer::GreetResponse ClientConnection::greet()
{
return { Screen::the().rect(), Gfx::current_system_theme_buffer() };
}
Messages::WindowServer::StartDragResponse ClientConnection::handle(const Messages::WindowServer::StartDrag& message)
Messages::WindowServer::StartDragResponse ClientConnection::start_drag(String const& text, HashMap<String, ByteBuffer> const& mime_data, Gfx::ShareableBitmap const& drag_bitmap)
{
auto& wm = WindowManager::the();
if (wm.dnd_client())
return false;
wm.start_dnd_drag(*this, message.text(), message.drag_bitmap().bitmap(), Core::MimeData::construct(message.mime_data()));
wm.start_dnd_drag(*this, text, drag_bitmap.bitmap(), Core::MimeData::construct(mime_data));
return true;
}
Messages::WindowServer::SetSystemThemeResponse ClientConnection::handle(const Messages::WindowServer::SetSystemTheme& message)
Messages::WindowServer::SetSystemThemeResponse ClientConnection::set_system_theme(String const& theme_path, String const& theme_name)
{
bool success = WindowManager::the().update_theme(message.theme_path(), message.theme_name());
bool success = WindowManager::the().update_theme(theme_path, theme_name);
return success;
}
Messages::WindowServer::GetSystemThemeResponse ClientConnection::handle(const Messages::WindowServer::GetSystemTheme&)
Messages::WindowServer::GetSystemThemeResponse ClientConnection::get_system_theme()
{
auto wm_config = Core::ConfigFile::open("/etc/WindowServer.ini");
auto name = wm_config->read_entry("Theme", "Name");
return name;
}
void ClientConnection::handle(const Messages::WindowServer::SetWindowBaseSizeAndSizeIncrement& message)
void ClientConnection::set_window_base_size_and_size_increment(i32 window_id, Gfx::IntSize const& base_size, Gfx::IntSize const& size_increment)
{
auto it = m_windows.find(message.window_id());
auto it = m_windows.find(window_id);
if (it == m_windows.end()) {
did_misbehave("SetWindowBaseSizeAndSizeIncrementResponse: Bad window ID");
return;
}
auto& window = *it->value;
window.set_base_size(message.base_size());
window.set_size_increment(message.size_increment());
window.set_base_size(base_size);
window.set_size_increment(size_increment);
}
void ClientConnection::handle(const Messages::WindowServer::SetWindowResizeAspectRatio& message)
void ClientConnection::set_window_resize_aspect_ratio(i32 window_id, Optional<Gfx::IntSize> const& resize_aspect_ratio)
{
auto it = m_windows.find(message.window_id());
auto it = m_windows.find(window_id);
if (it == m_windows.end()) {
did_misbehave("SetWindowResizeAspectRatioResponse: Bad window ID");
return;
}
auto& window = *it->value;
window.set_resize_aspect_ratio(message.resize_aspect_ratio());
window.set_resize_aspect_ratio(resize_aspect_ratio);
}
void ClientConnection::handle(const Messages::WindowServer::EnableDisplayLink&)
void ClientConnection::enable_display_link()
{
if (m_has_display_link)
return;
@ -750,7 +742,7 @@ void ClientConnection::handle(const Messages::WindowServer::EnableDisplayLink&)
Compositor::the().increment_display_link_count({});
}
void ClientConnection::handle(const Messages::WindowServer::DisableDisplayLink&)
void ClientConnection::disable_display_link()
{
if (!m_has_display_link)
return;
@ -766,72 +758,72 @@ void ClientConnection::notify_display_link(Badge<Compositor>)
post_message(Messages::WindowClient::DisplayLinkNotification());
}
void ClientConnection::handle(const Messages::WindowServer::SetWindowProgress& message)
void ClientConnection::set_window_progress(i32 window_id, Optional<i32> const& progress)
{
auto it = m_windows.find(message.window_id());
auto it = m_windows.find(window_id);
if (it == m_windows.end()) {
did_misbehave("SetWindowProgress with bad window ID");
return;
}
it->value->set_progress(message.progress());
it->value->set_progress(progress);
}
void ClientConnection::handle(const Messages::WindowServer::RefreshSystemTheme&)
void ClientConnection::refresh_system_theme()
{
// Post the client an UpdateSystemTheme message to refresh its theme.
post_message(Messages::WindowClient::UpdateSystemTheme(Gfx::current_system_theme_buffer()));
}
void ClientConnection::handle(const Messages::WindowServer::Pong&)
void ClientConnection::pong()
{
m_ping_timer = nullptr;
set_unresponsive(false);
}
Messages::WindowServer::GetGlobalCursorPositionResponse ClientConnection::handle(const Messages::WindowServer::GetGlobalCursorPosition&)
Messages::WindowServer::GetGlobalCursorPositionResponse ClientConnection::get_global_cursor_position()
{
return Screen::the().cursor_location();
}
void ClientConnection::handle(const Messages::WindowServer::SetMouseAcceleration& message)
void ClientConnection::set_mouse_acceleration(float factor)
{
double factor = message.factor();
if (factor < mouse_accel_min || factor > mouse_accel_max) {
double dbl_factor = (double)factor;
if (dbl_factor < mouse_accel_min || dbl_factor > mouse_accel_max) {
did_misbehave("SetMouseAcceleration with bad acceleration factor");
return;
}
WindowManager::the().set_acceleration_factor(factor);
WindowManager::the().set_acceleration_factor(dbl_factor);
}
Messages::WindowServer::GetMouseAccelerationResponse ClientConnection::handle(const Messages::WindowServer::GetMouseAcceleration&)
Messages::WindowServer::GetMouseAccelerationResponse ClientConnection::get_mouse_acceleration()
{
return Screen::the().acceleration_factor();
}
void ClientConnection::handle(const Messages::WindowServer::SetScrollStepSize& message)
void ClientConnection::set_scroll_step_size(u32 step_size)
{
if (message.step_size() < scroll_step_size_min) {
if (step_size < scroll_step_size_min) {
did_misbehave("SetScrollStepSize with bad scroll step size");
return;
}
WindowManager::the().set_scroll_step_size(message.step_size());
WindowManager::the().set_scroll_step_size(step_size);
}
Messages::WindowServer::GetScrollStepSizeResponse ClientConnection::handle(const Messages::WindowServer::GetScrollStepSize&)
Messages::WindowServer::GetScrollStepSizeResponse ClientConnection::get_scroll_step_size()
{
return Screen::the().scroll_step_size();
}
void ClientConnection::handle(const Messages::WindowServer::SetDoubleClickSpeed& message)
void ClientConnection::set_double_click_speed(i32 speed)
{
if (message.speed() < double_click_speed_min || message.speed() > double_click_speed_max) {
if (speed < double_click_speed_min || speed > double_click_speed_max) {
did_misbehave("SetDoubleClickSpeed with bad speed");
return;
}
WindowManager::the().set_double_click_speed(message.speed());
WindowManager::the().set_double_click_speed(speed);
}
Messages::WindowServer::GetDoubleClickSpeedResponse ClientConnection::handle(const Messages::WindowServer::GetDoubleClickSpeed&)
Messages::WindowServer::GetDoubleClickSpeedResponse ClientConnection::get_double_click_speed()
{
return WindowManager::the().double_click_speed();
}
@ -867,15 +859,15 @@ void ClientConnection::did_become_responsive()
set_unresponsive(false);
}
Messages::WindowServer::GetScreenBitmapResponse ClientConnection::handle(const Messages::WindowServer::GetScreenBitmap&)
Messages::WindowServer::GetScreenBitmapResponse ClientConnection::get_screen_bitmap()
{
auto& bitmap = Compositor::the().front_bitmap_for_screenshot({});
return bitmap.to_shareable_bitmap();
}
Messages::WindowServer::IsWindowModifiedResponse ClientConnection::handle(Messages::WindowServer::IsWindowModified const& message)
Messages::WindowServer::IsWindowModifiedResponse ClientConnection::is_window_modified(i32 window_id)
{
auto it = m_windows.find(message.window_id());
auto it = m_windows.find(window_id);
if (it == m_windows.end()) {
did_misbehave("IsWindowModified: Bad window ID");
return nullptr;
@ -884,15 +876,15 @@ Messages::WindowServer::IsWindowModifiedResponse ClientConnection::handle(Messag
return window.is_modified();
}
void ClientConnection::handle(Messages::WindowServer::SetWindowModified const& message)
void ClientConnection::set_window_modified(i32 window_id, bool modified)
{
auto it = m_windows.find(message.window_id());
auto it = m_windows.find(window_id);
if (it == m_windows.end()) {
did_misbehave("SetWindowModified: Bad window ID");
return;
}
auto& window = *it->value;
window.set_modified(message.modified());
window.set_modified(modified);
}
}

View file

@ -87,67 +87,69 @@ private:
void set_unresponsive(bool);
void destroy_window(Window&, Vector<i32>& destroyed_window_ids);
virtual Messages::WindowServer::GreetResponse handle(const Messages::WindowServer::Greet&) override;
virtual Messages::WindowServer::CreateMenubarResponse handle(const Messages::WindowServer::CreateMenubar&) override;
virtual void handle(const Messages::WindowServer::DestroyMenubar&) override;
virtual Messages::WindowServer::CreateMenuResponse handle(const Messages::WindowServer::CreateMenu&) override;
virtual void handle(const Messages::WindowServer::DestroyMenu&) override;
virtual void handle(const Messages::WindowServer::AddMenuToMenubar&) override;
virtual void handle(const Messages::WindowServer::SetWindowMenubar&) override;
virtual void handle(const Messages::WindowServer::AddMenuItem&) override;
virtual void handle(const Messages::WindowServer::AddMenuSeparator&) override;
virtual void handle(const Messages::WindowServer::UpdateMenuItem&) override;
virtual Messages::WindowServer::CreateWindowResponse handle(const Messages::WindowServer::CreateWindow&) override;
virtual Messages::WindowServer::DestroyWindowResponse handle(const Messages::WindowServer::DestroyWindow&) override;
virtual void handle(const Messages::WindowServer::SetWindowTitle&) override;
virtual Messages::WindowServer::GetWindowTitleResponse handle(const Messages::WindowServer::GetWindowTitle&) override;
virtual Messages::WindowServer::IsMaximizedResponse handle(const Messages::WindowServer::IsMaximized&) override;
virtual void handle(const Messages::WindowServer::StartWindowResize&) override;
virtual Messages::WindowServer::SetWindowRectResponse handle(const Messages::WindowServer::SetWindowRect&) override;
virtual Messages::WindowServer::GetWindowRectResponse handle(const Messages::WindowServer::GetWindowRect&) override;
virtual void handle(const Messages::WindowServer::SetWindowMinimumSize&) override;
virtual Messages::WindowServer::GetWindowMinimumSizeResponse handle(const Messages::WindowServer::GetWindowMinimumSize&) override;
virtual Messages::WindowServer::GetAppletRectOnScreenResponse handle(const Messages::WindowServer::GetAppletRectOnScreen&) override;
virtual void handle(const Messages::WindowServer::InvalidateRect&) override;
virtual void handle(const Messages::WindowServer::DidFinishPainting&) override;
virtual void handle(const Messages::WindowServer::SetGlobalCursorTracking&) override;
virtual void handle(const Messages::WindowServer::SetWindowOpacity&) override;
virtual void handle(const Messages::WindowServer::SetWindowBackingStore&) override;
virtual void handle(const Messages::WindowServer::SetWindowHasAlphaChannel&) override;
virtual void handle(const Messages::WindowServer::SetWindowAlphaHitThreshold&) override;
virtual void handle(const Messages::WindowServer::MoveWindowToFront&) override;
virtual void handle(const Messages::WindowServer::SetFullscreen&) override;
virtual void handle(const Messages::WindowServer::SetFrameless&) override;
virtual void handle(const Messages::WindowServer::AsyncSetWallpaper&) override;
virtual void handle(const Messages::WindowServer::SetBackgroundColor&) override;
virtual void handle(const Messages::WindowServer::SetWallpaperMode&) override;
virtual Messages::WindowServer::GetWallpaperResponse handle(const Messages::WindowServer::GetWallpaper&) override;
virtual Messages::WindowServer::SetResolutionResponse handle(const Messages::WindowServer::SetResolution&) override;
virtual void handle(const Messages::WindowServer::SetWindowCursor&) override;
virtual void handle(const Messages::WindowServer::SetWindowCustomCursor&) override;
virtual void handle(const Messages::WindowServer::PopupMenu&) override;
virtual void handle(const Messages::WindowServer::DismissMenu&) override;
virtual void handle(const Messages::WindowServer::SetWindowIconBitmap&) override;
virtual Messages::WindowServer::StartDragResponse handle(const Messages::WindowServer::StartDrag&) override;
virtual Messages::WindowServer::SetSystemThemeResponse handle(const Messages::WindowServer::SetSystemTheme&) override;
virtual Messages::WindowServer::GetSystemThemeResponse handle(const Messages::WindowServer::GetSystemTheme&) override;
virtual void handle(const Messages::WindowServer::SetWindowBaseSizeAndSizeIncrement&) override;
virtual void handle(const Messages::WindowServer::SetWindowResizeAspectRatio&) override;
virtual void handle(const Messages::WindowServer::EnableDisplayLink&) override;
virtual void handle(const Messages::WindowServer::DisableDisplayLink&) override;
virtual void handle(const Messages::WindowServer::SetWindowProgress&) override;
virtual void handle(const Messages::WindowServer::RefreshSystemTheme&) override;
virtual void handle(const Messages::WindowServer::Pong&) override;
virtual Messages::WindowServer::GetGlobalCursorPositionResponse handle(const Messages::WindowServer::GetGlobalCursorPosition&) override;
virtual void handle(const Messages::WindowServer::SetMouseAcceleration&) override;
virtual Messages::WindowServer::GetMouseAccelerationResponse handle(const Messages::WindowServer::GetMouseAcceleration&) override;
virtual void handle(const Messages::WindowServer::SetScrollStepSize&) override;
virtual Messages::WindowServer::GetScrollStepSizeResponse handle(const Messages::WindowServer::GetScrollStepSize&) override;
virtual Messages::WindowServer::GetScreenBitmapResponse handle(const Messages::WindowServer::GetScreenBitmap&) override;
virtual void handle(const Messages::WindowServer::SetDoubleClickSpeed&) override;
virtual Messages::WindowServer::GetDoubleClickSpeedResponse handle(const Messages::WindowServer::GetDoubleClickSpeed&) override;
virtual void handle(Messages::WindowServer::SetWindowModified const&) override;
virtual Messages::WindowServer::IsWindowModifiedResponse handle(Messages::WindowServer::IsWindowModified const&) override;
virtual Messages::WindowServer::GreetResponse greet() override;
virtual Messages::WindowServer::CreateMenubarResponse create_menubar() override;
virtual void destroy_menubar(i32) override;
virtual Messages::WindowServer::CreateMenuResponse create_menu(String const&) override;
virtual void destroy_menu(i32) override;
virtual void add_menu_to_menubar(i32, i32) override;
virtual void set_window_menubar(i32, i32) override;
virtual void add_menu_item(i32, i32, i32, String const&, bool, bool, bool, bool, String const&, Gfx::ShareableBitmap const&, bool) override;
virtual void add_menu_separator(i32) override;
virtual void update_menu_item(i32, i32, i32, String const&, bool, bool, bool, bool, String const&) override;
virtual Messages::WindowServer::CreateWindowResponse create_window(Gfx::IntRect const&, bool, bool, bool,
bool, bool, bool, bool, bool, float, float, Gfx::IntSize const&, Gfx::IntSize const&, Gfx::IntSize const&,
Optional<Gfx::IntSize> const&, i32, String const&, i32) override;
virtual Messages::WindowServer::DestroyWindowResponse destroy_window(i32) override;
virtual void set_window_title(i32, String const&) override;
virtual Messages::WindowServer::GetWindowTitleResponse get_window_title(i32) override;
virtual Messages::WindowServer::IsMaximizedResponse is_maximized(i32) override;
virtual void start_window_resize(i32) override;
virtual Messages::WindowServer::SetWindowRectResponse set_window_rect(i32, Gfx::IntRect const&) override;
virtual Messages::WindowServer::GetWindowRectResponse get_window_rect(i32) override;
virtual void set_window_minimum_size(i32, Gfx::IntSize const&) override;
virtual Messages::WindowServer::GetWindowMinimumSizeResponse get_window_minimum_size(i32) override;
virtual Messages::WindowServer::GetAppletRectOnScreenResponse get_applet_rect_on_screen(i32) override;
virtual void invalidate_rect(i32, Vector<Gfx::IntRect> const&, bool) override;
virtual void did_finish_painting(i32, Vector<Gfx::IntRect> const&) override;
virtual void set_global_cursor_tracking(i32, bool) override;
virtual void set_window_opacity(i32, float) override;
virtual void set_window_backing_store(i32, i32, i32, IPC::File const&, i32, bool, Gfx::IntSize const&, bool) override;
virtual void set_window_has_alpha_channel(i32, bool) override;
virtual void set_window_alpha_hit_threshold(i32, float) override;
virtual void move_window_to_front(i32) override;
virtual void set_fullscreen(i32, bool) override;
virtual void set_frameless(i32, bool) override;
virtual void async_set_wallpaper(String const&) override;
virtual void set_background_color(String const&) override;
virtual void set_wallpaper_mode(String const&) override;
virtual Messages::WindowServer::GetWallpaperResponse get_wallpaper() override;
virtual Messages::WindowServer::SetResolutionResponse set_resolution(Gfx::IntSize const&, int) override;
virtual void set_window_cursor(i32, i32) override;
virtual void set_window_custom_cursor(i32, Gfx::ShareableBitmap const&) override;
virtual void popup_menu(i32, Gfx::IntPoint const&) override;
virtual void dismiss_menu(i32) override;
virtual void set_window_icon_bitmap(i32, Gfx::ShareableBitmap const&) override;
virtual Messages::WindowServer::StartDragResponse start_drag(String const&, HashMap<String, ByteBuffer> const&, Gfx::ShareableBitmap const&) override;
virtual Messages::WindowServer::SetSystemThemeResponse set_system_theme(String const&, String const&) override;
virtual Messages::WindowServer::GetSystemThemeResponse get_system_theme() override;
virtual void set_window_base_size_and_size_increment(i32, Gfx::IntSize const&, Gfx::IntSize const&) override;
virtual void set_window_resize_aspect_ratio(i32, Optional<Gfx::IntSize> const&) override;
virtual void enable_display_link() override;
virtual void disable_display_link() override;
virtual void set_window_progress(i32, Optional<i32> const&) override;
virtual void refresh_system_theme() override;
virtual void pong() override;
virtual Messages::WindowServer::GetGlobalCursorPositionResponse get_global_cursor_position() override;
virtual void set_mouse_acceleration(float) override;
virtual Messages::WindowServer::GetMouseAccelerationResponse get_mouse_acceleration() override;
virtual void set_scroll_step_size(u32) override;
virtual Messages::WindowServer::GetScrollStepSizeResponse get_scroll_step_size() override;
virtual Messages::WindowServer::GetScreenBitmapResponse get_screen_bitmap() override;
virtual void set_double_click_speed(i32) override;
virtual Messages::WindowServer::GetDoubleClickSpeedResponse get_double_click_speed() override;
virtual void set_window_modified(i32, bool) override;
virtual Messages::WindowServer::IsWindowModifiedResponse is_window_modified(i32) override;
Window* window_from_id(i32 window_id);

View file

@ -33,7 +33,7 @@ void WMClientConnection::die()
});
}
void WMClientConnection::handle(const Messages::WindowManagerServer::SetAppletAreaPosition& message)
void WMClientConnection::set_applet_area_position(Gfx::IntPoint const& position)
{
if (m_window_id < 0) {
did_misbehave("SetAppletAreaPosition: WM didn't assign window as manager yet");
@ -41,17 +41,17 @@ void WMClientConnection::handle(const Messages::WindowManagerServer::SetAppletAr
return;
}
AppletManager::the().set_position(message.position());
AppletManager::the().set_position(position);
}
void WMClientConnection::handle(const Messages::WindowManagerServer::SetActiveWindow& message)
void WMClientConnection::set_active_window(i32 client_id, i32 window_id)
{
auto* client = WindowServer::ClientConnection::from_client_id(message.client_id());
auto* client = WindowServer::ClientConnection::from_client_id(client_id);
if (!client) {
did_misbehave("SetActiveWindow: Bad client ID");
return;
}
auto it = client->m_windows.find(message.window_id());
auto it = client->m_windows.find(window_id);
if (it == client->m_windows.end()) {
did_misbehave("SetActiveWindow: Bad window ID");
return;
@ -61,34 +61,34 @@ void WMClientConnection::handle(const Messages::WindowManagerServer::SetActiveWi
WindowManager::the().move_to_front_and_make_active(window);
}
void WMClientConnection::handle(const Messages::WindowManagerServer::PopupWindowMenu& message)
void WMClientConnection::popup_window_menu(i32 client_id, i32 window_id, Gfx::IntPoint const& screen_position)
{
auto* client = WindowServer::ClientConnection::from_client_id(message.client_id());
auto* client = WindowServer::ClientConnection::from_client_id(client_id);
if (!client) {
did_misbehave("PopupWindowMenu: Bad client ID");
return;
}
auto it = client->m_windows.find(message.window_id());
auto it = client->m_windows.find(window_id);
if (it == client->m_windows.end()) {
did_misbehave("PopupWindowMenu: Bad window ID");
return;
}
auto& window = *(*it).value;
if (auto* modal_window = window.blocking_modal_window()) {
modal_window->popup_window_menu(message.screen_position(), WindowMenuDefaultAction::BasedOnWindowState);
modal_window->popup_window_menu(screen_position, WindowMenuDefaultAction::BasedOnWindowState);
} else {
window.popup_window_menu(message.screen_position(), WindowMenuDefaultAction::BasedOnWindowState);
window.popup_window_menu(screen_position, WindowMenuDefaultAction::BasedOnWindowState);
}
}
void WMClientConnection::handle(const Messages::WindowManagerServer::StartWindowResize& request)
void WMClientConnection::start_window_resize(i32 client_id, i32 window_id)
{
auto* client = WindowServer::ClientConnection::from_client_id(request.client_id());
auto* client = WindowServer::ClientConnection::from_client_id(client_id);
if (!client) {
did_misbehave("WM_StartWindowResize: Bad client ID");
return;
}
auto it = client->m_windows.find(request.window_id());
auto it = client->m_windows.find(window_id);
if (it == client->m_windows.end()) {
did_misbehave("WM_StartWindowResize: Bad window ID");
return;
@ -99,52 +99,52 @@ void WMClientConnection::handle(const Messages::WindowManagerServer::StartWindow
WindowManager::the().start_window_resize(window, Screen::the().cursor_location(), MouseButton::Left);
}
void WMClientConnection::handle(const Messages::WindowManagerServer::SetWindowMinimized& message)
void WMClientConnection::set_window_minimized(i32 client_id, i32 window_id, bool minimized)
{
auto* client = WindowServer::ClientConnection::from_client_id(message.client_id());
auto* client = WindowServer::ClientConnection::from_client_id(client_id);
if (!client) {
did_misbehave("WM_SetWindowMinimized: Bad client ID");
return;
}
auto it = client->m_windows.find(message.window_id());
auto it = client->m_windows.find(window_id);
if (it == client->m_windows.end()) {
did_misbehave("WM_SetWindowMinimized: Bad window ID");
return;
}
auto& window = *(*it).value;
WindowManager::the().minimize_windows(window, message.minimized());
WindowManager::the().minimize_windows(window, minimized);
}
void WMClientConnection::handle(const Messages::WindowManagerServer::SetEventMask& message)
void WMClientConnection::set_event_mask(u32 event_mask)
{
m_event_mask = message.event_mask();
m_event_mask = event_mask;
}
void WMClientConnection::handle(const Messages::WindowManagerServer::SetManagerWindow& message)
void WMClientConnection::set_manager_window(i32 window_id)
{
m_window_id = message.window_id();
m_window_id = window_id;
// Let the window manager know that we obtained a manager window, and should
// receive information about other windows.
WindowManager::the().greet_window_manager(*this);
}
void WMClientConnection::handle(const Messages::WindowManagerServer::SetWindowTaskbarRect& message)
void WMClientConnection::set_window_taskbar_rect(i32 client_id, i32 window_id, Gfx::IntRect const& rect)
{
// Because the Taskbar (which should be the only user of this API) does not own the
// window or the client id, there is a possibility that it may send this message for
// a window or client that may have been destroyed already. This is not an error,
// and we should not call did_misbehave() for either.
auto* client = WindowServer::ClientConnection::from_client_id(message.client_id());
auto* client = WindowServer::ClientConnection::from_client_id(client_id);
if (!client)
return;
auto it = client->m_windows.find(message.window_id());
auto it = client->m_windows.find(window_id);
if (it == client->m_windows.end())
return;
auto& window = *(*it).value;
window.set_taskbar_rect(message.rect());
window.set_taskbar_rect(rect);
}
}

View file

@ -22,14 +22,14 @@ class WMClientConnection final
public:
~WMClientConnection() override;
virtual void handle(const Messages::WindowManagerServer::SetActiveWindow&) override;
virtual void handle(const Messages::WindowManagerServer::SetWindowMinimized&) override;
virtual void handle(const Messages::WindowManagerServer::StartWindowResize&) override;
virtual void handle(const Messages::WindowManagerServer::PopupWindowMenu&) override;
virtual void handle(const Messages::WindowManagerServer::SetWindowTaskbarRect&) override;
virtual void handle(const Messages::WindowManagerServer::SetAppletAreaPosition&) override;
virtual void handle(const Messages::WindowManagerServer::SetEventMask&) override;
virtual void handle(const Messages::WindowManagerServer::SetManagerWindow&) override;
virtual void set_active_window(i32, i32) override;
virtual void set_window_minimized(i32, i32, bool) override;
virtual void start_window_resize(i32, i32) override;
virtual void popup_window_menu(i32, i32, Gfx::IntPoint const&) override;
virtual void set_window_taskbar_rect(i32, i32, Gfx::IntRect const&) override;
virtual void set_applet_area_position(Gfx::IntPoint const&) override;
virtual void set_event_mask(u32) override;
virtual void set_manager_window(i32) override;
unsigned event_mask() const { return m_event_mask; }
int window_id() const { return m_window_id; }