2020-01-18 11:38:21 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
|
|
* list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
|
* and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
|
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2021-01-16 17:51:56 +03:00
|
|
|
#include <AK/Debug.h>
|
2020-06-11 21:31:53 +03:00
|
|
|
#include <AK/StringBuilder.h>
|
2020-02-16 11:17:49 +03:00
|
|
|
#include <LibCore/EventLoop.h>
|
2020-02-14 15:18:34 +03:00
|
|
|
#include <LibCore/MimeData.h>
|
2020-02-06 22:33:02 +03:00
|
|
|
#include <LibGUI/Action.h>
|
|
|
|
#include <LibGUI/Application.h>
|
|
|
|
#include <LibGUI/Clipboard.h>
|
|
|
|
#include <LibGUI/Desktop.h>
|
2020-03-22 23:13:23 +03:00
|
|
|
#include <LibGUI/DisplayLink.h>
|
2020-02-06 22:33:02 +03:00
|
|
|
#include <LibGUI/DragOperation.h>
|
2020-05-17 22:49:54 +03:00
|
|
|
#include <LibGUI/EmojiInputDialog.h>
|
2020-02-06 22:33:02 +03:00
|
|
|
#include <LibGUI/Event.h>
|
|
|
|
#include <LibGUI/Menu.h>
|
|
|
|
#include <LibGUI/Widget.h>
|
|
|
|
#include <LibGUI/Window.h>
|
|
|
|
#include <LibGUI/WindowServerConnection.h>
|
2020-02-15 01:02:47 +03:00
|
|
|
#include <LibGfx/Bitmap.h>
|
2020-02-13 23:43:32 +03:00
|
|
|
#include <LibGfx/Palette.h>
|
|
|
|
#include <LibGfx/SystemTheme.h>
|
2018-10-10 16:12:38 +03:00
|
|
|
|
2020-02-02 17:07:41 +03:00
|
|
|
namespace GUI {
|
|
|
|
|
|
|
|
WindowServerConnection& WindowServerConnection::the()
|
2019-07-17 21:57:27 +03:00
|
|
|
{
|
2020-02-02 17:07:41 +03:00
|
|
|
static WindowServerConnection* s_connection = nullptr;
|
2019-12-02 11:33:37 +03:00
|
|
|
if (!s_connection)
|
2020-02-02 17:07:41 +03:00
|
|
|
s_connection = new WindowServerConnection;
|
2019-07-17 21:57:27 +03:00
|
|
|
return *s_connection;
|
|
|
|
}
|
|
|
|
|
2021-01-16 19:20:53 +03:00
|
|
|
static void set_system_theme_from_anonymous_buffer(Core::AnonymousBuffer buffer)
|
2019-12-23 22:24:26 +03:00
|
|
|
{
|
2021-01-16 19:20:53 +03:00
|
|
|
Gfx::set_system_theme(buffer);
|
|
|
|
Application::the()->set_system_palette(buffer);
|
2019-12-23 22:24:26 +03:00
|
|
|
}
|
|
|
|
|
2020-02-02 17:07:41 +03:00
|
|
|
void WindowServerConnection::handshake()
|
2018-10-10 16:12:38 +03:00
|
|
|
{
|
2020-02-06 22:20:44 +03:00
|
|
|
auto response = send_sync<Messages::WindowServer::Greet>();
|
2019-12-02 11:33:37 +03:00
|
|
|
set_my_client_id(response->client_id());
|
2021-01-16 19:20:53 +03:00
|
|
|
set_system_theme_from_anonymous_buffer(response->theme_buffer());
|
2020-02-02 17:07:41 +03:00
|
|
|
Desktop::the().did_receive_screen_rect({}, response->screen_rect());
|
2019-03-09 19:34:09 +03:00
|
|
|
}
|
|
|
|
|
2020-02-06 22:20:44 +03:00
|
|
|
void WindowServerConnection::handle(const Messages::WindowClient::UpdateSystemTheme& message)
|
2019-12-23 22:24:26 +03:00
|
|
|
{
|
2021-01-16 19:20:53 +03:00
|
|
|
set_system_theme_from_anonymous_buffer(message.theme_buffer());
|
2020-02-02 17:07:41 +03:00
|
|
|
Window::update_all_windows({});
|
2020-03-16 14:36:21 +03:00
|
|
|
Window::for_each_window({}, [](auto& window) {
|
|
|
|
Core::EventLoop::current().post_event(window, make<ThemeChangeEvent>());
|
|
|
|
});
|
2019-12-23 22:24:26 +03:00
|
|
|
}
|
|
|
|
|
2020-02-06 22:20:44 +03:00
|
|
|
void WindowServerConnection::handle(const Messages::WindowClient::Paint& message)
|
2019-01-20 07:48:43 +03:00
|
|
|
{
|
2020-02-02 17:07:41 +03:00
|
|
|
if (auto* window = Window::from_window_id(message.window_id()))
|
|
|
|
Core::EventLoop::current().post_event(*window, make<MultiPaintEvent>(message.rects(), message.window_size()));
|
2019-01-20 07:48:43 +03:00
|
|
|
}
|
|
|
|
|
2020-02-06 22:20:44 +03:00
|
|
|
void WindowServerConnection::handle(const Messages::WindowClient::WindowResized& message)
|
2019-02-20 17:34:55 +03:00
|
|
|
{
|
2020-02-02 17:07:41 +03:00
|
|
|
if (auto* window = Window::from_window_id(message.window_id())) {
|
2020-08-22 14:10:35 +03:00
|
|
|
Core::EventLoop::current().post_event(*window, make<ResizeEvent>(message.new_rect().size()));
|
2019-12-02 11:33:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-06 22:20:44 +03:00
|
|
|
void WindowServerConnection::handle(const Messages::WindowClient::WindowActivated& message)
|
2019-12-02 11:33:37 +03:00
|
|
|
{
|
2020-02-02 17:07:41 +03:00
|
|
|
if (auto* window = Window::from_window_id(message.window_id()))
|
|
|
|
Core::EventLoop::current().post_event(*window, make<Event>(Event::WindowBecameActive));
|
2019-02-20 17:34:55 +03:00
|
|
|
}
|
|
|
|
|
2020-02-06 22:20:44 +03:00
|
|
|
void WindowServerConnection::handle(const Messages::WindowClient::WindowDeactivated& message)
|
2019-01-26 23:58:43 +03:00
|
|
|
{
|
2020-02-02 17:07:41 +03:00
|
|
|
if (auto* window = Window::from_window_id(message.window_id()))
|
|
|
|
Core::EventLoop::current().post_event(*window, make<Event>(Event::WindowBecameInactive));
|
2019-12-02 11:33:37 +03:00
|
|
|
}
|
|
|
|
|
2020-07-15 04:17:00 +03:00
|
|
|
void WindowServerConnection::handle(const Messages::WindowClient::WindowInputEntered& message)
|
|
|
|
{
|
|
|
|
if (auto* window = Window::from_window_id(message.window_id()))
|
|
|
|
Core::EventLoop::current().post_event(*window, make<Event>(Event::WindowInputEntered));
|
|
|
|
}
|
|
|
|
|
|
|
|
void WindowServerConnection::handle(const Messages::WindowClient::WindowInputLeft& message)
|
|
|
|
{
|
|
|
|
if (auto* window = Window::from_window_id(message.window_id()))
|
|
|
|
Core::EventLoop::current().post_event(*window, make<Event>(Event::WindowInputLeft));
|
|
|
|
}
|
|
|
|
|
2020-02-06 22:20:44 +03:00
|
|
|
void WindowServerConnection::handle(const Messages::WindowClient::WindowCloseRequest& message)
|
2019-12-02 11:33:37 +03:00
|
|
|
{
|
2020-02-02 17:07:41 +03:00
|
|
|
if (auto* window = Window::from_window_id(message.window_id()))
|
|
|
|
Core::EventLoop::current().post_event(*window, make<Event>(Event::WindowCloseRequest));
|
2019-01-26 23:58:43 +03:00
|
|
|
}
|
|
|
|
|
2020-02-06 22:20:44 +03:00
|
|
|
void WindowServerConnection::handle(const Messages::WindowClient::WindowEntered& message)
|
2019-02-05 12:31:37 +03:00
|
|
|
{
|
2020-02-02 17:07:41 +03:00
|
|
|
if (auto* window = Window::from_window_id(message.window_id()))
|
|
|
|
Core::EventLoop::current().post_event(*window, make<Event>(Event::WindowEntered));
|
2019-02-05 12:31:37 +03:00
|
|
|
}
|
|
|
|
|
2020-02-06 22:20:44 +03:00
|
|
|
void WindowServerConnection::handle(const Messages::WindowClient::WindowLeft& message)
|
2019-02-20 12:12:19 +03:00
|
|
|
{
|
2020-02-02 17:07:41 +03:00
|
|
|
if (auto* window = Window::from_window_id(message.window_id()))
|
|
|
|
Core::EventLoop::current().post_event(*window, make<Event>(Event::WindowLeft));
|
2019-02-20 12:12:19 +03:00
|
|
|
}
|
|
|
|
|
2020-02-06 22:20:44 +03:00
|
|
|
void WindowServerConnection::handle(const Messages::WindowClient::KeyDown& message)
|
2019-01-26 08:39:13 +03:00
|
|
|
{
|
2020-02-02 17:07:41 +03:00
|
|
|
auto* window = Window::from_window_id(message.window_id());
|
2019-12-02 11:33:37 +03:00
|
|
|
if (!window)
|
|
|
|
return;
|
2019-04-20 22:56:56 +03:00
|
|
|
|
2020-06-11 21:31:53 +03:00
|
|
|
auto key_event = make<KeyEvent>(Event::KeyDown, (KeyCode)message.key(), message.modifiers(), message.code_point(), message.scancode());
|
2020-02-02 17:07:41 +03:00
|
|
|
Action* action = nullptr;
|
2020-02-02 03:57:57 +03:00
|
|
|
|
2021-01-16 17:51:56 +03:00
|
|
|
dbgln<debug_keyboard_shortcuts>("Looking up action for {}", key_event->to_string());
|
2020-05-12 18:05:00 +03:00
|
|
|
|
2020-04-24 15:14:10 +03:00
|
|
|
if (auto* focused_widget = window->focused_widget()) {
|
2020-05-12 18:05:00 +03:00
|
|
|
for (auto* widget = focused_widget; widget && !action; widget = widget->parent_widget()) {
|
|
|
|
action = widget->action_for_key_event(*key_event);
|
2021-01-16 17:51:56 +03:00
|
|
|
|
|
|
|
dbgln<debug_keyboard_shortcuts>(" > Focused widget {} gave action: {}", *widget, action);
|
2020-05-12 18:05:00 +03:00
|
|
|
}
|
2020-04-24 15:14:10 +03:00
|
|
|
}
|
2020-02-02 03:57:57 +03:00
|
|
|
|
2020-05-12 18:05:00 +03:00
|
|
|
if (!action) {
|
2020-02-02 03:57:57 +03:00
|
|
|
action = window->action_for_key_event(*key_event);
|
2021-01-16 17:51:56 +03:00
|
|
|
dbgln<debug_keyboard_shortcuts>(" > Asked window {}, got action: {}", *window, action);
|
2020-05-12 18:05:00 +03:00
|
|
|
}
|
2019-12-02 11:33:37 +03:00
|
|
|
|
2020-11-10 21:40:40 +03:00
|
|
|
// NOTE: Application-global shortcuts are ignored while a modal window is up.
|
|
|
|
if (!action && !window->is_modal()) {
|
2020-07-04 17:52:01 +03:00
|
|
|
action = Application::the()->action_for_key_event(*key_event);
|
2021-01-16 17:51:56 +03:00
|
|
|
dbgln<debug_keyboard_shortcuts>(" > Asked application, got action: {}", action);
|
2020-05-12 18:05:00 +03:00
|
|
|
}
|
2020-02-02 03:57:57 +03:00
|
|
|
|
2020-12-06 23:53:29 +03:00
|
|
|
if (action) {
|
|
|
|
if (action->is_enabled()) {
|
|
|
|
action->activate();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (action->swallow_key_event_when_disabled())
|
|
|
|
return;
|
2019-12-02 11:33:37 +03:00
|
|
|
}
|
2020-05-17 22:49:54 +03:00
|
|
|
|
|
|
|
bool focused_widget_accepts_emoji_input = window->focused_widget() && window->focused_widget()->accepts_emoji_input();
|
|
|
|
if (focused_widget_accepts_emoji_input && (message.modifiers() == (Mod_Ctrl | Mod_Alt)) && message.key() == Key_Space) {
|
|
|
|
auto emoji_input_dialog = EmojiInputDialog::construct(window);
|
|
|
|
if (emoji_input_dialog->exec() != EmojiInputDialog::ExecOK)
|
|
|
|
return;
|
|
|
|
key_event->m_key = Key_Invalid;
|
|
|
|
key_event->m_modifiers = 0;
|
2020-06-11 21:31:53 +03:00
|
|
|
|
|
|
|
AK::Utf8View m_utf8_view(emoji_input_dialog->selected_emoji_text().characters());
|
|
|
|
u32 code_point = *m_utf8_view.begin();
|
|
|
|
|
|
|
|
key_event->m_code_point = code_point;
|
2020-05-17 22:49:54 +03:00
|
|
|
}
|
|
|
|
|
2020-02-02 14:34:39 +03:00
|
|
|
Core::EventLoop::current().post_event(*window, move(key_event));
|
2019-01-26 08:39:13 +03:00
|
|
|
}
|
|
|
|
|
2020-02-06 22:20:44 +03:00
|
|
|
void WindowServerConnection::handle(const Messages::WindowClient::KeyUp& message)
|
2019-01-20 07:48:43 +03:00
|
|
|
{
|
2020-02-02 17:07:41 +03:00
|
|
|
auto* window = Window::from_window_id(message.window_id());
|
2019-12-02 11:33:37 +03:00
|
|
|
if (!window)
|
|
|
|
return;
|
|
|
|
|
2020-06-11 21:31:53 +03:00
|
|
|
auto key_event = make<KeyEvent>(Event::KeyUp, (KeyCode)message.key(), message.modifiers(), message.code_point(), message.scancode());
|
2020-02-02 14:34:39 +03:00
|
|
|
Core::EventLoop::current().post_event(*window, move(key_event));
|
2019-12-02 11:33:37 +03:00
|
|
|
}
|
|
|
|
|
2020-08-11 01:09:59 +03:00
|
|
|
static MouseButton to_gmousebutton(u32 button)
|
2019-12-02 11:33:37 +03:00
|
|
|
{
|
|
|
|
switch (button) {
|
|
|
|
case 0:
|
2020-02-02 17:07:41 +03:00
|
|
|
return MouseButton::None;
|
2019-12-02 11:33:37 +03:00
|
|
|
case 1:
|
2020-02-02 17:07:41 +03:00
|
|
|
return MouseButton::Left;
|
2019-12-02 11:33:37 +03:00
|
|
|
case 2:
|
2020-02-02 17:07:41 +03:00
|
|
|
return MouseButton::Right;
|
2019-12-02 11:33:37 +03:00
|
|
|
case 4:
|
2020-02-02 17:07:41 +03:00
|
|
|
return MouseButton::Middle;
|
2020-05-02 23:07:43 +03:00
|
|
|
case 8:
|
|
|
|
return MouseButton::Back;
|
|
|
|
case 16:
|
|
|
|
return MouseButton::Forward;
|
2019-06-07 12:46:02 +03:00
|
|
|
default:
|
|
|
|
ASSERT_NOT_REACHED();
|
|
|
|
break;
|
2019-01-20 07:48:43 +03:00
|
|
|
}
|
2019-01-11 01:19:29 +03:00
|
|
|
}
|
|
|
|
|
2020-02-06 22:20:44 +03:00
|
|
|
void WindowServerConnection::handle(const Messages::WindowClient::MouseDown& message)
|
2019-02-12 12:08:35 +03:00
|
|
|
{
|
2020-02-02 17:07:41 +03:00
|
|
|
if (auto* window = Window::from_window_id(message.window_id()))
|
|
|
|
Core::EventLoop::current().post_event(*window, make<MouseEvent>(Event::MouseDown, message.mouse_position(), message.buttons(), to_gmousebutton(message.button()), message.modifiers(), message.wheel_delta()));
|
2019-02-12 12:08:35 +03:00
|
|
|
}
|
|
|
|
|
2020-02-06 22:20:44 +03:00
|
|
|
void WindowServerConnection::handle(const Messages::WindowClient::MouseUp& message)
|
2019-04-04 02:44:35 +03:00
|
|
|
{
|
2020-02-02 17:07:41 +03:00
|
|
|
if (auto* window = Window::from_window_id(message.window_id()))
|
|
|
|
Core::EventLoop::current().post_event(*window, make<MouseEvent>(Event::MouseUp, message.mouse_position(), message.buttons(), to_gmousebutton(message.button()), message.modifiers(), message.wheel_delta()));
|
2019-04-04 02:44:35 +03:00
|
|
|
}
|
|
|
|
|
2020-02-06 22:20:44 +03:00
|
|
|
void WindowServerConnection::handle(const Messages::WindowClient::MouseMove& message)
|
2019-02-20 23:59:13 +03:00
|
|
|
{
|
2020-02-13 23:43:32 +03:00
|
|
|
if (auto* window = Window::from_window_id(message.window_id())) {
|
|
|
|
if (message.is_drag())
|
2021-01-09 13:01:41 +03:00
|
|
|
Core::EventLoop::current().post_event(*window, make<DragEvent>(Event::DragMove, message.mouse_position(), message.mime_types()));
|
2020-02-13 23:43:32 +03:00
|
|
|
else
|
|
|
|
Core::EventLoop::current().post_event(*window, make<MouseEvent>(Event::MouseMove, message.mouse_position(), message.buttons(), to_gmousebutton(message.button()), message.modifiers(), message.wheel_delta()));
|
|
|
|
}
|
2019-12-02 11:33:37 +03:00
|
|
|
}
|
2019-04-03 18:22:14 +03:00
|
|
|
|
2020-02-06 22:20:44 +03:00
|
|
|
void WindowServerConnection::handle(const Messages::WindowClient::MouseDoubleClick& message)
|
2019-12-02 11:33:37 +03:00
|
|
|
{
|
2020-02-02 17:07:41 +03:00
|
|
|
if (auto* window = Window::from_window_id(message.window_id()))
|
|
|
|
Core::EventLoop::current().post_event(*window, make<MouseEvent>(Event::MouseDoubleClick, message.mouse_position(), message.buttons(), to_gmousebutton(message.button()), message.modifiers(), message.wheel_delta()));
|
2019-12-02 11:33:37 +03:00
|
|
|
}
|
2019-09-14 10:19:05 +03:00
|
|
|
|
2020-02-06 22:20:44 +03:00
|
|
|
void WindowServerConnection::handle(const Messages::WindowClient::MouseWheel& message)
|
2019-12-02 11:33:37 +03:00
|
|
|
{
|
2020-02-02 17:07:41 +03:00
|
|
|
if (auto* window = Window::from_window_id(message.window_id()))
|
|
|
|
Core::EventLoop::current().post_event(*window, make<MouseEvent>(Event::MouseWheel, message.mouse_position(), message.buttons(), to_gmousebutton(message.button()), message.modifiers(), message.wheel_delta()));
|
2019-12-02 11:33:37 +03:00
|
|
|
}
|
2019-02-12 12:08:35 +03:00
|
|
|
|
2020-02-06 22:20:44 +03:00
|
|
|
void WindowServerConnection::handle(const Messages::WindowClient::MenuItemActivated& message)
|
2019-12-02 11:33:37 +03:00
|
|
|
{
|
2020-02-02 17:07:41 +03:00
|
|
|
auto* menu = Menu::from_menu_id(message.menu_id());
|
2019-12-02 11:33:37 +03:00
|
|
|
if (!menu) {
|
2020-02-02 17:07:41 +03:00
|
|
|
dbgprintf("EventLoop received event for invalid menu ID %d\n", message.menu_id());
|
2019-12-02 11:33:37 +03:00
|
|
|
return;
|
2019-01-20 07:48:43 +03:00
|
|
|
}
|
2019-12-02 11:33:37 +03:00
|
|
|
if (auto* action = menu->action_at(message.identifier()))
|
2019-12-09 23:25:48 +03:00
|
|
|
action->activate(menu);
|
2019-12-02 11:33:37 +03:00
|
|
|
}
|
2019-02-20 23:59:13 +03:00
|
|
|
|
2020-02-06 22:20:44 +03:00
|
|
|
void WindowServerConnection::handle(const Messages::WindowClient::WM_WindowStateChanged& message)
|
2019-12-02 11:33:37 +03:00
|
|
|
{
|
2020-02-02 17:07:41 +03:00
|
|
|
if (auto* window = Window::from_window_id(message.wm_id()))
|
2020-07-16 02:40:52 +03:00
|
|
|
Core::EventLoop::current().post_event(*window, make<WMWindowStateChangedEvent>(message.client_id(), message.window_id(), message.parent_client_id(), message.parent_window_id(), message.title(), message.rect(), message.is_active(), message.is_modal(), static_cast<WindowType>(message.window_type()), message.is_minimized(), message.is_frameless(), message.progress()));
|
2019-12-02 11:33:37 +03:00
|
|
|
}
|
|
|
|
|
2020-02-06 22:20:44 +03:00
|
|
|
void WindowServerConnection::handle(const Messages::WindowClient::WM_WindowRectChanged& message)
|
2019-12-02 11:33:37 +03:00
|
|
|
{
|
2020-02-02 17:07:41 +03:00
|
|
|
if (auto* window = Window::from_window_id(message.wm_id()))
|
|
|
|
Core::EventLoop::current().post_event(*window, make<WMWindowRectChangedEvent>(message.client_id(), message.window_id(), message.rect()));
|
2019-12-02 11:33:37 +03:00
|
|
|
}
|
|
|
|
|
2020-02-06 22:20:44 +03:00
|
|
|
void WindowServerConnection::handle(const Messages::WindowClient::WM_WindowIconBitmapChanged& message)
|
2019-12-02 11:33:37 +03:00
|
|
|
{
|
2021-01-16 01:13:24 +03:00
|
|
|
if (auto* window = Window::from_window_id(message.wm_id())) {
|
|
|
|
Core::EventLoop::current().post_event(*window, make<WMWindowIconBitmapChangedEvent>(message.client_id(), message.window_id(), message.bitmap().bitmap()));
|
|
|
|
}
|
2019-12-02 11:33:37 +03:00
|
|
|
}
|
|
|
|
|
2020-02-06 22:20:44 +03:00
|
|
|
void WindowServerConnection::handle(const Messages::WindowClient::WM_WindowRemoved& message)
|
2019-12-02 11:33:37 +03:00
|
|
|
{
|
2020-02-02 17:07:41 +03:00
|
|
|
if (auto* window = Window::from_window_id(message.wm_id()))
|
|
|
|
Core::EventLoop::current().post_event(*window, make<WMWindowRemovedEvent>(message.client_id(), message.window_id()));
|
2019-12-02 11:33:37 +03:00
|
|
|
}
|
|
|
|
|
2020-02-06 22:20:44 +03:00
|
|
|
void WindowServerConnection::handle(const Messages::WindowClient::ScreenRectChanged& message)
|
2019-12-02 11:33:37 +03:00
|
|
|
{
|
2020-02-02 17:07:41 +03:00
|
|
|
Desktop::the().did_receive_screen_rect({}, message.rect());
|
2019-12-02 11:33:37 +03:00
|
|
|
}
|
|
|
|
|
2020-02-06 22:20:44 +03:00
|
|
|
void WindowServerConnection::handle(const Messages::WindowClient::AsyncSetWallpaperFinished&)
|
2019-05-03 02:38:24 +03:00
|
|
|
{
|
2020-02-02 17:07:41 +03:00
|
|
|
// This is handled manually by Desktop::set_wallpaper().
|
2019-05-03 02:38:24 +03:00
|
|
|
}
|
2019-12-08 18:50:23 +03:00
|
|
|
|
2020-02-06 22:20:44 +03:00
|
|
|
void WindowServerConnection::handle(const Messages::WindowClient::DragDropped& message)
|
2019-12-08 18:50:23 +03:00
|
|
|
{
|
2020-02-14 15:18:34 +03:00
|
|
|
if (auto* window = Window::from_window_id(message.window_id())) {
|
2020-11-07 22:44:21 +03:00
|
|
|
auto mime_data = Core::MimeData::construct(message.mime_data());
|
2020-02-14 15:18:34 +03:00
|
|
|
Core::EventLoop::current().post_event(*window, make<DropEvent>(message.mouse_position(), message.text(), mime_data));
|
|
|
|
}
|
2019-12-08 18:50:23 +03:00
|
|
|
}
|
|
|
|
|
2020-02-06 22:20:44 +03:00
|
|
|
void WindowServerConnection::handle(const Messages::WindowClient::DragAccepted&)
|
2019-12-08 18:50:23 +03:00
|
|
|
{
|
2020-02-02 17:07:41 +03:00
|
|
|
DragOperation::notify_accepted({});
|
2019-12-08 18:50:23 +03:00
|
|
|
}
|
|
|
|
|
2020-02-06 22:20:44 +03:00
|
|
|
void WindowServerConnection::handle(const Messages::WindowClient::DragCancelled&)
|
2019-12-08 18:50:23 +03:00
|
|
|
{
|
2020-02-02 17:07:41 +03:00
|
|
|
DragOperation::notify_cancelled({});
|
2021-01-09 00:23:06 +03:00
|
|
|
Application::the()->notify_drag_cancelled({});
|
2019-12-08 18:50:23 +03:00
|
|
|
}
|
2019-12-26 14:06:07 +03:00
|
|
|
|
2020-02-06 22:20:44 +03:00
|
|
|
void WindowServerConnection::handle(const Messages::WindowClient::WindowStateChanged& message)
|
2019-12-26 14:06:07 +03:00
|
|
|
{
|
2020-02-02 17:07:41 +03:00
|
|
|
if (auto* window = Window::from_window_id(message.window_id()))
|
2019-12-27 13:34:40 +03:00
|
|
|
window->notify_state_changed({}, message.minimized(), message.occluded());
|
2019-12-26 14:06:07 +03:00
|
|
|
}
|
2020-02-02 17:07:41 +03:00
|
|
|
|
2020-03-22 23:13:23 +03:00
|
|
|
void WindowServerConnection::handle(const Messages::WindowClient::DisplayLinkNotification&)
|
|
|
|
{
|
2020-04-22 01:07:48 +03:00
|
|
|
if (m_display_link_notification_pending)
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_display_link_notification_pending = true;
|
|
|
|
deferred_invoke([this](auto&) {
|
|
|
|
DisplayLink::notify({});
|
|
|
|
m_display_link_notification_pending = false;
|
|
|
|
});
|
2020-03-22 23:13:23 +03:00
|
|
|
}
|
|
|
|
|
2020-06-11 23:46:49 +03:00
|
|
|
void WindowServerConnection::handle(const Messages::WindowClient::Ping&)
|
|
|
|
{
|
|
|
|
post_message(Messages::WindowServer::Pong());
|
|
|
|
}
|
|
|
|
|
2020-02-02 17:07:41 +03:00
|
|
|
}
|