|
@@ -11,6 +11,7 @@
|
|
|
#include <LibGUI/Action.h>
|
|
|
#include <LibGUI/Application.h>
|
|
|
#include <LibGUI/CommandPalette.h>
|
|
|
+#include <LibGUI/ConnectionToWindowServer.h>
|
|
|
#include <LibGUI/Desktop.h>
|
|
|
#include <LibGUI/DisplayLink.h>
|
|
|
#include <LibGUI/DragOperation.h>
|
|
@@ -19,7 +20,6 @@
|
|
|
#include <LibGUI/Menu.h>
|
|
|
#include <LibGUI/MouseTracker.h>
|
|
|
#include <LibGUI/Window.h>
|
|
|
-#include <LibGUI/WindowServerConnection.h>
|
|
|
#include <LibGfx/Bitmap.h>
|
|
|
#include <LibGfx/FontDatabase.h>
|
|
|
#include <LibGfx/Palette.h>
|
|
@@ -27,11 +27,11 @@
|
|
|
|
|
|
namespace GUI {
|
|
|
|
|
|
-WindowServerConnection& WindowServerConnection::the()
|
|
|
+ConnectionToWindowServer& ConnectionToWindowServer::the()
|
|
|
{
|
|
|
- static RefPtr<WindowServerConnection> s_connection = nullptr;
|
|
|
+ static RefPtr<ConnectionToWindowServer> s_connection = nullptr;
|
|
|
if (!s_connection)
|
|
|
- s_connection = WindowServerConnection::try_create().release_value_but_fixme_should_propagate_errors();
|
|
|
+ s_connection = ConnectionToWindowServer::try_create().release_value_but_fixme_should_propagate_errors();
|
|
|
return *s_connection;
|
|
|
}
|
|
|
|
|
@@ -41,7 +41,7 @@ static void set_system_theme_from_anonymous_buffer(Core::AnonymousBuffer buffer)
|
|
|
Application::the()->set_system_palette(buffer);
|
|
|
}
|
|
|
|
|
|
-WindowServerConnection::WindowServerConnection(NonnullOwnPtr<Core::Stream::LocalSocket> socket)
|
|
|
+ConnectionToWindowServer::ConnectionToWindowServer(NonnullOwnPtr<Core::Stream::LocalSocket> socket)
|
|
|
: IPC::ConnectionToServer<WindowClientEndpoint, WindowServerEndpoint>(*this, move(socket))
|
|
|
{
|
|
|
// NOTE: WindowServer automatically sends a "fast_greet" message to us when we connect.
|
|
@@ -54,12 +54,12 @@ WindowServerConnection::WindowServerConnection(NonnullOwnPtr<Core::Stream::Local
|
|
|
m_client_id = message->client_id();
|
|
|
}
|
|
|
|
|
|
-void WindowServerConnection::fast_greet(Vector<Gfx::IntRect> const&, u32, u32, u32, Core::AnonymousBuffer const&, String const&, String const&, i32)
|
|
|
+void ConnectionToWindowServer::fast_greet(Vector<Gfx::IntRect> const&, u32, u32, u32, Core::AnonymousBuffer const&, String const&, String const&, i32)
|
|
|
{
|
|
|
// NOTE: This message is handled in the constructor.
|
|
|
}
|
|
|
|
|
|
-void WindowServerConnection::update_system_theme(Core::AnonymousBuffer const& theme_buffer)
|
|
|
+void ConnectionToWindowServer::update_system_theme(Core::AnonymousBuffer const& theme_buffer)
|
|
|
{
|
|
|
set_system_theme_from_anonymous_buffer(theme_buffer);
|
|
|
Window::update_all_windows({});
|
|
@@ -68,7 +68,7 @@ void WindowServerConnection::update_system_theme(Core::AnonymousBuffer const& th
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-void WindowServerConnection::update_system_fonts(const String& default_font_query, const String& fixed_width_font_query)
|
|
|
+void ConnectionToWindowServer::update_system_fonts(const String& default_font_query, const String& fixed_width_font_query)
|
|
|
{
|
|
|
Gfx::FontDatabase::set_default_font_query(default_font_query);
|
|
|
Gfx::FontDatabase::set_fixed_width_font_query(fixed_width_font_query);
|
|
@@ -78,56 +78,56 @@ void WindowServerConnection::update_system_fonts(const String& default_font_quer
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-void WindowServerConnection::paint(i32 window_id, Gfx::IntSize const& window_size, Vector<Gfx::IntRect> const& rects)
|
|
|
+void ConnectionToWindowServer::paint(i32 window_id, Gfx::IntSize const& window_size, Vector<Gfx::IntRect> const& rects)
|
|
|
{
|
|
|
if (auto* window = Window::from_window_id(window_id))
|
|
|
Core::EventLoop::current().post_event(*window, make<MultiPaintEvent>(rects, window_size));
|
|
|
}
|
|
|
|
|
|
-void WindowServerConnection::window_resized(i32 window_id, Gfx::IntRect const& new_rect)
|
|
|
+void ConnectionToWindowServer::window_resized(i32 window_id, Gfx::IntRect const& new_rect)
|
|
|
{
|
|
|
if (auto* window = Window::from_window_id(window_id)) {
|
|
|
Core::EventLoop::current().post_event(*window, make<ResizeEvent>(new_rect.size()));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void WindowServerConnection::window_activated(i32 window_id)
|
|
|
+void ConnectionToWindowServer::window_activated(i32 window_id)
|
|
|
{
|
|
|
if (auto* window = Window::from_window_id(window_id))
|
|
|
Core::EventLoop::current().post_event(*window, make<Event>(Event::WindowBecameActive));
|
|
|
}
|
|
|
|
|
|
-void WindowServerConnection::window_deactivated(i32 window_id)
|
|
|
+void ConnectionToWindowServer::window_deactivated(i32 window_id)
|
|
|
{
|
|
|
if (auto* window = Window::from_window_id(window_id))
|
|
|
Core::EventLoop::current().post_event(*window, make<Event>(Event::WindowBecameInactive));
|
|
|
}
|
|
|
|
|
|
-void WindowServerConnection::window_input_entered(i32 window_id)
|
|
|
+void ConnectionToWindowServer::window_input_entered(i32 window_id)
|
|
|
{
|
|
|
if (auto* window = Window::from_window_id(window_id))
|
|
|
Core::EventLoop::current().post_event(*window, make<Event>(Event::WindowInputEntered));
|
|
|
}
|
|
|
|
|
|
-void WindowServerConnection::window_input_left(i32 window_id)
|
|
|
+void ConnectionToWindowServer::window_input_left(i32 window_id)
|
|
|
{
|
|
|
if (auto* window = Window::from_window_id(window_id))
|
|
|
Core::EventLoop::current().post_event(*window, make<Event>(Event::WindowInputLeft));
|
|
|
}
|
|
|
|
|
|
-void WindowServerConnection::window_close_request(i32 window_id)
|
|
|
+void ConnectionToWindowServer::window_close_request(i32 window_id)
|
|
|
{
|
|
|
if (auto* window = Window::from_window_id(window_id))
|
|
|
Core::EventLoop::current().post_event(*window, make<Event>(Event::WindowCloseRequest));
|
|
|
}
|
|
|
|
|
|
-void WindowServerConnection::window_entered(i32 window_id)
|
|
|
+void ConnectionToWindowServer::window_entered(i32 window_id)
|
|
|
{
|
|
|
if (auto* window = Window::from_window_id(window_id))
|
|
|
Core::EventLoop::current().post_event(*window, make<Event>(Event::WindowEntered));
|
|
|
}
|
|
|
|
|
|
-void WindowServerConnection::window_left(i32 window_id)
|
|
|
+void ConnectionToWindowServer::window_left(i32 window_id)
|
|
|
{
|
|
|
if (auto* window = Window::from_window_id(window_id))
|
|
|
Core::EventLoop::current().post_event(*window, make<Event>(Event::WindowLeft));
|
|
@@ -163,7 +163,7 @@ static Action* action_for_key_event(Window& window, KeyEvent const& event)
|
|
|
return nullptr;
|
|
|
}
|
|
|
|
|
|
-void WindowServerConnection::key_down(i32 window_id, u32 code_point, u32 key, u32 modifiers, u32 scancode)
|
|
|
+void ConnectionToWindowServer::key_down(i32 window_id, u32 code_point, u32 key, u32 modifiers, u32 scancode)
|
|
|
{
|
|
|
auto* window = Window::from_window_id(window_id);
|
|
|
if (!window)
|
|
@@ -215,7 +215,7 @@ void WindowServerConnection::key_down(i32 window_id, u32 code_point, u32 key, u3
|
|
|
Core::EventLoop::current().post_event(*window, move(key_event));
|
|
|
}
|
|
|
|
|
|
-void WindowServerConnection::key_up(i32 window_id, u32 code_point, u32 key, u32 modifiers, u32 scancode)
|
|
|
+void ConnectionToWindowServer::key_up(i32 window_id, u32 code_point, u32 key, u32 modifiers, u32 scancode)
|
|
|
{
|
|
|
auto* window = Window::from_window_id(window_id);
|
|
|
if (!window)
|
|
@@ -246,19 +246,19 @@ static MouseButton to_mouse_button(u32 button)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void WindowServerConnection::mouse_down(i32 window_id, Gfx::IntPoint const& mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta_x, i32 wheel_delta_y)
|
|
|
+void ConnectionToWindowServer::mouse_down(i32 window_id, Gfx::IntPoint const& mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta_x, i32 wheel_delta_y)
|
|
|
{
|
|
|
if (auto* window = Window::from_window_id(window_id))
|
|
|
Core::EventLoop::current().post_event(*window, make<MouseEvent>(Event::MouseDown, mouse_position, buttons, to_mouse_button(button), modifiers, wheel_delta_x, wheel_delta_y));
|
|
|
}
|
|
|
|
|
|
-void WindowServerConnection::mouse_up(i32 window_id, Gfx::IntPoint const& mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta_x, i32 wheel_delta_y)
|
|
|
+void ConnectionToWindowServer::mouse_up(i32 window_id, Gfx::IntPoint const& mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta_x, i32 wheel_delta_y)
|
|
|
{
|
|
|
if (auto* window = Window::from_window_id(window_id))
|
|
|
Core::EventLoop::current().post_event(*window, make<MouseEvent>(Event::MouseUp, mouse_position, buttons, to_mouse_button(button), modifiers, wheel_delta_x, wheel_delta_y));
|
|
|
}
|
|
|
|
|
|
-void WindowServerConnection::mouse_move(i32 window_id, Gfx::IntPoint const& mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta_x, i32 wheel_delta_y, bool is_drag, Vector<String> const& mime_types)
|
|
|
+void ConnectionToWindowServer::mouse_move(i32 window_id, Gfx::IntPoint const& mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta_x, i32 wheel_delta_y, bool is_drag, Vector<String> const& mime_types)
|
|
|
{
|
|
|
if (auto* window = Window::from_window_id(window_id)) {
|
|
|
if (is_drag)
|
|
@@ -268,19 +268,19 @@ void WindowServerConnection::mouse_move(i32 window_id, Gfx::IntPoint const& mous
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void WindowServerConnection::mouse_double_click(i32 window_id, Gfx::IntPoint const& mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta_x, i32 wheel_delta_y)
|
|
|
+void ConnectionToWindowServer::mouse_double_click(i32 window_id, Gfx::IntPoint const& mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta_x, i32 wheel_delta_y)
|
|
|
{
|
|
|
if (auto* window = Window::from_window_id(window_id))
|
|
|
Core::EventLoop::current().post_event(*window, make<MouseEvent>(Event::MouseDoubleClick, mouse_position, buttons, to_mouse_button(button), modifiers, wheel_delta_x, wheel_delta_y));
|
|
|
}
|
|
|
|
|
|
-void WindowServerConnection::mouse_wheel(i32 window_id, Gfx::IntPoint const& mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta_x, i32 wheel_delta_y)
|
|
|
+void ConnectionToWindowServer::mouse_wheel(i32 window_id, Gfx::IntPoint const& mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta_x, i32 wheel_delta_y)
|
|
|
{
|
|
|
if (auto* window = Window::from_window_id(window_id))
|
|
|
Core::EventLoop::current().post_event(*window, make<MouseEvent>(Event::MouseWheel, mouse_position, buttons, to_mouse_button(button), modifiers, wheel_delta_x, wheel_delta_y));
|
|
|
}
|
|
|
|
|
|
-void WindowServerConnection::menu_visibility_did_change(i32 menu_id, bool visible)
|
|
|
+void ConnectionToWindowServer::menu_visibility_did_change(i32 menu_id, bool visible)
|
|
|
{
|
|
|
auto* menu = Menu::from_menu_id(menu_id);
|
|
|
if (!menu) {
|
|
@@ -290,7 +290,7 @@ void WindowServerConnection::menu_visibility_did_change(i32 menu_id, bool visibl
|
|
|
menu->visibility_did_change({}, visible);
|
|
|
}
|
|
|
|
|
|
-void WindowServerConnection::menu_item_activated(i32 menu_id, u32 identifier)
|
|
|
+void ConnectionToWindowServer::menu_item_activated(i32 menu_id, u32 identifier)
|
|
|
{
|
|
|
auto* menu = Menu::from_menu_id(menu_id);
|
|
|
if (!menu) {
|
|
@@ -301,11 +301,11 @@ void WindowServerConnection::menu_item_activated(i32 menu_id, u32 identifier)
|
|
|
action->activate(menu);
|
|
|
}
|
|
|
|
|
|
-void WindowServerConnection::menu_item_entered(i32 menu_id, u32 identifier)
|
|
|
+void ConnectionToWindowServer::menu_item_entered(i32 menu_id, u32 identifier)
|
|
|
{
|
|
|
auto* menu = Menu::from_menu_id(menu_id);
|
|
|
if (!menu) {
|
|
|
- dbgln("WindowServerConnection received MenuItemEntered for invalid menu ID {}", menu_id);
|
|
|
+ dbgln("ConnectionToWindowServer received MenuItemEntered for invalid menu ID {}", menu_id);
|
|
|
return;
|
|
|
}
|
|
|
auto* action = menu->action_at(identifier);
|
|
@@ -317,11 +317,11 @@ void WindowServerConnection::menu_item_entered(i32 menu_id, u32 identifier)
|
|
|
Core::EventLoop::current().post_event(*app, make<ActionEvent>(GUI::Event::ActionEnter, *action));
|
|
|
}
|
|
|
|
|
|
-void WindowServerConnection::menu_item_left(i32 menu_id, u32 identifier)
|
|
|
+void ConnectionToWindowServer::menu_item_left(i32 menu_id, u32 identifier)
|
|
|
{
|
|
|
auto* menu = Menu::from_menu_id(menu_id);
|
|
|
if (!menu) {
|
|
|
- dbgln("WindowServerConnection received MenuItemLeft for invalid menu ID {}", menu_id);
|
|
|
+ dbgln("ConnectionToWindowServer received MenuItemLeft for invalid menu ID {}", menu_id);
|
|
|
return;
|
|
|
}
|
|
|
auto* action = menu->action_at(identifier);
|
|
@@ -333,7 +333,7 @@ void WindowServerConnection::menu_item_left(i32 menu_id, u32 identifier)
|
|
|
Core::EventLoop::current().post_event(*app, make<ActionEvent>(GUI::Event::ActionLeave, *action));
|
|
|
}
|
|
|
|
|
|
-void WindowServerConnection::screen_rects_changed(Vector<Gfx::IntRect> const& rects, u32 main_screen_index, u32 workspace_rows, u32 workspace_columns)
|
|
|
+void ConnectionToWindowServer::screen_rects_changed(Vector<Gfx::IntRect> const& rects, u32 main_screen_index, u32 workspace_rows, u32 workspace_columns)
|
|
|
{
|
|
|
Desktop::the().did_receive_screen_rects({}, rects, main_screen_index, workspace_rows, workspace_columns);
|
|
|
Window::for_each_window({}, [&](auto& window) {
|
|
@@ -341,19 +341,19 @@ void WindowServerConnection::screen_rects_changed(Vector<Gfx::IntRect> const& re
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-void WindowServerConnection::applet_area_rect_changed(Gfx::IntRect const& rect)
|
|
|
+void ConnectionToWindowServer::applet_area_rect_changed(Gfx::IntRect const& rect)
|
|
|
{
|
|
|
Window::for_each_window({}, [&](auto& window) {
|
|
|
Core::EventLoop::current().post_event(window, make<AppletAreaRectChangeEvent>(rect));
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-void WindowServerConnection::set_wallpaper_finished(bool)
|
|
|
+void ConnectionToWindowServer::set_wallpaper_finished(bool)
|
|
|
{
|
|
|
// This is handled manually by Desktop::set_wallpaper().
|
|
|
}
|
|
|
|
|
|
-void WindowServerConnection::drag_dropped(i32 window_id, Gfx::IntPoint const& mouse_position, String const& text, HashMap<String, ByteBuffer> const& mime_data)
|
|
|
+void ConnectionToWindowServer::drag_dropped(i32 window_id, Gfx::IntPoint const& mouse_position, String const& text, HashMap<String, ByteBuffer> const& mime_data)
|
|
|
{
|
|
|
if (auto* window = Window::from_window_id(window_id)) {
|
|
|
auto mime_data_obj = Core::MimeData::construct(mime_data);
|
|
@@ -361,24 +361,24 @@ void WindowServerConnection::drag_dropped(i32 window_id, Gfx::IntPoint const& mo
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void WindowServerConnection::drag_accepted()
|
|
|
+void ConnectionToWindowServer::drag_accepted()
|
|
|
{
|
|
|
DragOperation::notify_accepted({});
|
|
|
}
|
|
|
|
|
|
-void WindowServerConnection::drag_cancelled()
|
|
|
+void ConnectionToWindowServer::drag_cancelled()
|
|
|
{
|
|
|
DragOperation::notify_cancelled({});
|
|
|
Application::the()->notify_drag_cancelled({});
|
|
|
}
|
|
|
|
|
|
-void WindowServerConnection::window_state_changed(i32 window_id, bool minimized, bool occluded)
|
|
|
+void ConnectionToWindowServer::window_state_changed(i32 window_id, bool minimized, bool occluded)
|
|
|
{
|
|
|
if (auto* window = Window::from_window_id(window_id))
|
|
|
window->notify_state_changed({}, minimized, occluded);
|
|
|
}
|
|
|
|
|
|
-void WindowServerConnection::display_link_notification()
|
|
|
+void ConnectionToWindowServer::display_link_notification()
|
|
|
{
|
|
|
if (m_display_link_notification_pending)
|
|
|
return;
|
|
@@ -390,12 +390,12 @@ void WindowServerConnection::display_link_notification()
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-void WindowServerConnection::track_mouse_move(Gfx::IntPoint const& mouse_position)
|
|
|
+void ConnectionToWindowServer::track_mouse_move(Gfx::IntPoint const& mouse_position)
|
|
|
{
|
|
|
MouseTracker::track_mouse_move({}, mouse_position);
|
|
|
}
|
|
|
|
|
|
-void WindowServerConnection::ping()
|
|
|
+void ConnectionToWindowServer::ping()
|
|
|
{
|
|
|
async_pong();
|
|
|
}
|