2021-04-14 21:38:53 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2021, the SerenityOS developers.
|
2023-11-04 19:58:14 +01:00
|
|
|
* Copyright (c) 2023, David Ganz <david.g.ganz@gmail.com>
|
2021-04-14 21:38:53 +00:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-04-14 21:38:53 +00:00
|
|
|
*/
|
|
|
|
|
|
2022-06-01 13:41:34 +02:00
|
|
|
#include <LibGUI/ConnectionToWindowManagerServer.h>
|
2021-04-14 21:38:53 +00:00
|
|
|
#include <LibGUI/Event.h>
|
|
|
|
|
#include <LibGUI/Window.h>
|
|
|
|
|
|
|
|
|
|
namespace GUI {
|
|
|
|
|
|
2022-06-01 13:41:34 +02:00
|
|
|
ConnectionToWindowManagerServer& ConnectionToWindowManagerServer::the()
|
2021-04-14 21:38:53 +00:00
|
|
|
{
|
2022-06-01 13:41:34 +02:00
|
|
|
static RefPtr<ConnectionToWindowManagerServer> s_connection = nullptr;
|
2021-04-14 21:38:53 +00:00
|
|
|
if (!s_connection)
|
2022-06-01 13:41:34 +02:00
|
|
|
s_connection = ConnectionToWindowManagerServer::try_create().release_value_but_fixme_should_propagate_errors();
|
2021-04-14 21:38:53 +00:00
|
|
|
return *s_connection;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-01 13:41:34 +02:00
|
|
|
void ConnectionToWindowManagerServer::window_state_changed(i32 wm_id, i32 client_id, i32 window_id,
|
2022-08-25 14:03:49 -04:00
|
|
|
u32 workspace_row, u32 workspace_column, bool is_active, bool is_blocked, bool is_minimized, bool is_frameless,
|
2023-12-16 17:49:34 +03:30
|
|
|
i32 window_type, ByteString const& title, Gfx::IntRect const& rect, Optional<i32> const& progress)
|
2021-04-14 21:38:53 +00:00
|
|
|
{
|
2021-05-02 19:54:34 +02:00
|
|
|
if (auto* window = Window::from_window_id(wm_id))
|
2022-08-25 14:03:49 -04:00
|
|
|
Core::EventLoop::current().post_event(*window, make<WMWindowStateChangedEvent>(client_id, window_id, title, rect, workspace_row, workspace_column, is_active, is_blocked, static_cast<WindowType>(window_type), is_minimized, is_frameless, progress));
|
2021-04-14 21:38:53 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-06 21:35:32 +00:00
|
|
|
void ConnectionToWindowManagerServer::applet_area_size_changed(i32 wm_id, Gfx::IntSize size)
|
2021-04-14 21:38:53 +00:00
|
|
|
{
|
2021-05-02 19:54:34 +02:00
|
|
|
if (auto* window = Window::from_window_id(wm_id))
|
|
|
|
|
Core::EventLoop::current().post_event(*window, make<WMAppletAreaSizeChangedEvent>(size));
|
2021-04-14 21:38:53 +00:00
|
|
|
}
|
|
|
|
|
|
2022-06-01 13:41:34 +02:00
|
|
|
void ConnectionToWindowManagerServer::window_rect_changed(i32 wm_id, i32 client_id, i32 window_id, Gfx::IntRect const& rect)
|
2021-04-14 21:38:53 +00:00
|
|
|
{
|
2021-05-02 19:54:34 +02:00
|
|
|
if (auto* window = Window::from_window_id(wm_id))
|
|
|
|
|
Core::EventLoop::current().post_event(*window, make<WMWindowRectChangedEvent>(client_id, window_id, rect));
|
2021-04-14 21:38:53 +00:00
|
|
|
}
|
|
|
|
|
|
2022-06-01 13:41:34 +02:00
|
|
|
void ConnectionToWindowManagerServer::window_icon_bitmap_changed(i32 wm_id, i32 client_id, i32 window_id, Gfx::ShareableBitmap const& bitmap)
|
2021-04-14 21:38:53 +00:00
|
|
|
{
|
2021-05-02 19:54:34 +02:00
|
|
|
if (auto* window = Window::from_window_id(wm_id)) {
|
|
|
|
|
Core::EventLoop::current().post_event(*window, make<WMWindowIconBitmapChangedEvent>(client_id, window_id, bitmap.bitmap()));
|
2021-04-14 21:38:53 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-01 13:41:34 +02:00
|
|
|
void ConnectionToWindowManagerServer::window_removed(i32 wm_id, i32 client_id, i32 window_id)
|
2021-04-14 21:38:53 +00:00
|
|
|
{
|
2021-05-02 19:54:34 +02:00
|
|
|
if (auto* window = Window::from_window_id(wm_id))
|
|
|
|
|
Core::EventLoop::current().post_event(*window, make<WMWindowRemovedEvent>(client_id, window_id));
|
2021-04-14 21:38:53 +00:00
|
|
|
}
|
2021-04-17 23:21:24 +01:00
|
|
|
|
2022-06-01 13:41:34 +02:00
|
|
|
void ConnectionToWindowManagerServer::super_key_pressed(i32 wm_id)
|
2021-04-17 23:21:24 +01:00
|
|
|
{
|
2021-05-02 19:54:34 +02:00
|
|
|
if (auto* window = Window::from_window_id(wm_id))
|
|
|
|
|
Core::EventLoop::current().post_event(*window, make<WMSuperKeyPressedEvent>(wm_id));
|
2021-04-17 23:21:24 +01:00
|
|
|
}
|
2021-06-21 19:32:46 -04:00
|
|
|
|
2022-06-01 13:41:34 +02:00
|
|
|
void ConnectionToWindowManagerServer::super_space_key_pressed(i32 wm_id)
|
2021-06-21 19:32:46 -04:00
|
|
|
{
|
|
|
|
|
if (auto* window = Window::from_window_id(wm_id))
|
|
|
|
|
Core::EventLoop::current().post_event(*window, make<WMSuperSpaceKeyPressedEvent>(wm_id));
|
|
|
|
|
}
|
2021-06-30 19:12:02 -06:00
|
|
|
|
2022-06-01 13:40:43 +02:00
|
|
|
void ConnectionToWindowManagerServer::super_d_key_pressed(i32 wm_id)
|
|
|
|
|
{
|
|
|
|
|
if (auto* window = Window::from_window_id(wm_id))
|
|
|
|
|
Core::EventLoop::current().post_event(*window, make<WMSuperDKeyPressedEvent>(wm_id));
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-01 13:41:34 +02:00
|
|
|
void ConnectionToWindowManagerServer::super_digit_key_pressed(i32 wm_id, u8 digit)
|
2022-02-23 21:43:50 +01:00
|
|
|
{
|
|
|
|
|
if (auto* window = Window::from_window_id(wm_id))
|
|
|
|
|
Core::EventLoop::current().post_event(*window, make<WMSuperDigitKeyPressedEvent>(wm_id, digit));
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-01 13:41:34 +02:00
|
|
|
void ConnectionToWindowManagerServer::workspace_changed(i32 wm_id, u32 row, u32 column)
|
2021-06-30 19:12:02 -06:00
|
|
|
{
|
|
|
|
|
if (auto* window = Window::from_window_id(wm_id))
|
2021-11-13 12:11:35 +01:00
|
|
|
Core::EventLoop::current().post_event(*window, make<WMWorkspaceChangedEvent>(wm_id, row, column));
|
2021-06-30 19:12:02 -06:00
|
|
|
}
|
|
|
|
|
|
2023-12-16 17:49:34 +03:30
|
|
|
void ConnectionToWindowManagerServer::keymap_changed(i32 wm_id, ByteString const& keymap)
|
2022-01-19 14:44:56 +03:00
|
|
|
{
|
|
|
|
|
if (auto* window = Window::from_window_id(wm_id))
|
|
|
|
|
Core::EventLoop::current().post_event(*window, make<WMKeymapChangedEvent>(wm_id, keymap));
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-04 19:58:14 +01:00
|
|
|
void ConnectionToWindowManagerServer::add_to_quick_launch(i32 wm_id, pid_t pid)
|
|
|
|
|
{
|
|
|
|
|
if (auto* window = Window::from_window_id(wm_id))
|
|
|
|
|
Core::EventLoop::current().post_event(*window, make<WMAddToQuickLaunchEvent>(wm_id, pid));
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-14 21:38:53 +00:00
|
|
|
}
|