mirror of
https://github.com/RGBCube/serenity
synced 2025-07-29 07:37:46 +00:00
Userland: Change IPC funcs to use plain arguments instead of a struct
Instead of having a single overloaded handle method each method gets its own unique method name now.
This commit is contained in:
parent
d47f15ab8b
commit
065040872f
50 changed files with 897 additions and 839 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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() };
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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() };
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue