2021-04-14 18:38:53 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2021, the SerenityOS developers.
|
|
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-04-14 18:38:53 -03:00
|
|
|
*/
|
|
|
|
|
|
2022-06-01 08:41:34 -03:00
|
|
|
#include <LibGUI/ConnectionToWindowManagerServer.h>
|
2021-04-14 18:38:53 -03:00
|
|
|
#include <LibGUI/Event.h>
|
|
|
|
|
#include <LibGUI/Window.h>
|
|
|
|
|
|
|
|
|
|
namespace GUI {
|
|
|
|
|
|
2022-06-01 08:41:34 -03:00
|
|
|
ConnectionToWindowManagerServer& ConnectionToWindowManagerServer::the()
|
2021-04-14 18:38:53 -03:00
|
|
|
{
|
2022-06-01 08:41:34 -03:00
|
|
|
static RefPtr<ConnectionToWindowManagerServer> s_connection = nullptr;
|
2021-04-14 18:38:53 -03:00
|
|
|
if (!s_connection)
|
2022-06-01 08:41:34 -03:00
|
|
|
s_connection = ConnectionToWindowManagerServer::try_create().release_value_but_fixme_should_propagate_errors();
|
2021-04-14 18:38:53 -03:00
|
|
|
return *s_connection;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-01 08:41:34 -03:00
|
|
|
void ConnectionToWindowManagerServer::window_state_changed(i32 wm_id, i32 client_id, i32 window_id,
|
2022-08-25 15:03:49 -03:00
|
|
|
u32 workspace_row, u32 workspace_column, bool is_active, bool is_blocked, bool is_minimized, bool is_frameless,
|
2022-08-23 17:42:00 -03:00
|
|
|
i32 window_type, String const& title, Gfx::IntRect const& rect, Optional<i32> const& progress)
|
2021-04-14 18:38:53 -03:00
|
|
|
{
|
2021-05-02 14:54:34 -03:00
|
|
|
if (auto* window = Window::from_window_id(wm_id))
|
2022-08-25 15:03:49 -03: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 18:38:53 -03:00
|
|
|
}
|
|
|
|
|
|
2022-06-01 08:41:34 -03:00
|
|
|
void ConnectionToWindowManagerServer::applet_area_size_changed(i32 wm_id, Gfx::IntSize const& size)
|
2021-04-14 18:38:53 -03:00
|
|
|
{
|
2021-05-02 14:54:34 -03:00
|
|
|
if (auto* window = Window::from_window_id(wm_id))
|
|
|
|
|
Core::EventLoop::current().post_event(*window, make<WMAppletAreaSizeChangedEvent>(size));
|
2021-04-14 18:38:53 -03:00
|
|
|
}
|
|
|
|
|
|
2022-06-01 08:41:34 -03:00
|
|
|
void ConnectionToWindowManagerServer::window_rect_changed(i32 wm_id, i32 client_id, i32 window_id, Gfx::IntRect const& rect)
|
2021-04-14 18:38:53 -03:00
|
|
|
{
|
2021-05-02 14:54:34 -03: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 18:38:53 -03:00
|
|
|
}
|
|
|
|
|
|
2022-06-01 08:41:34 -03:00
|
|
|
void ConnectionToWindowManagerServer::window_icon_bitmap_changed(i32 wm_id, i32 client_id, i32 window_id, Gfx::ShareableBitmap const& bitmap)
|
2021-04-14 18:38:53 -03:00
|
|
|
{
|
2021-05-02 14:54:34 -03: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 18:38:53 -03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-01 08:41:34 -03:00
|
|
|
void ConnectionToWindowManagerServer::window_removed(i32 wm_id, i32 client_id, i32 window_id)
|
2021-04-14 18:38:53 -03:00
|
|
|
{
|
2021-05-02 14:54:34 -03: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 18:38:53 -03:00
|
|
|
}
|
2021-04-17 19:21:24 -03:00
|
|
|
|
2022-06-01 08:41:34 -03:00
|
|
|
void ConnectionToWindowManagerServer::super_key_pressed(i32 wm_id)
|
2021-04-17 19:21:24 -03:00
|
|
|
{
|
2021-05-02 14:54:34 -03:00
|
|
|
if (auto* window = Window::from_window_id(wm_id))
|
|
|
|
|
Core::EventLoop::current().post_event(*window, make<WMSuperKeyPressedEvent>(wm_id));
|
2021-04-17 19:21:24 -03:00
|
|
|
}
|
2021-06-21 20:32:46 -03:00
|
|
|
|
2022-06-01 08:41:34 -03:00
|
|
|
void ConnectionToWindowManagerServer::super_space_key_pressed(i32 wm_id)
|
2021-06-21 20:32:46 -03:00
|
|
|
{
|
|
|
|
|
if (auto* window = Window::from_window_id(wm_id))
|
|
|
|
|
Core::EventLoop::current().post_event(*window, make<WMSuperSpaceKeyPressedEvent>(wm_id));
|
|
|
|
|
}
|
2021-06-30 22:12:02 -03:00
|
|
|
|
2022-06-01 08:40:43 -03: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 08:41:34 -03:00
|
|
|
void ConnectionToWindowManagerServer::super_digit_key_pressed(i32 wm_id, u8 digit)
|
2022-02-23 17:43:50 -03:00
|
|
|
{
|
|
|
|
|
if (auto* window = Window::from_window_id(wm_id))
|
|
|
|
|
Core::EventLoop::current().post_event(*window, make<WMSuperDigitKeyPressedEvent>(wm_id, digit));
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-01 08:41:34 -03:00
|
|
|
void ConnectionToWindowManagerServer::workspace_changed(i32 wm_id, u32 row, u32 column)
|
2021-06-30 22:12:02 -03:00
|
|
|
{
|
|
|
|
|
if (auto* window = Window::from_window_id(wm_id))
|
2021-11-13 08:11:35 -03:00
|
|
|
Core::EventLoop::current().post_event(*window, make<WMWorkspaceChangedEvent>(wm_id, row, column));
|
2021-06-30 22:12:02 -03:00
|
|
|
}
|
|
|
|
|
|
2022-06-01 08:41:34 -03:00
|
|
|
void ConnectionToWindowManagerServer::keymap_changed(i32 wm_id, String const& keymap)
|
2022-01-19 08:44:56 -03:00
|
|
|
{
|
|
|
|
|
if (auto* window = Window::from_window_id(wm_id))
|
|
|
|
|
Core::EventLoop::current().post_event(*window, make<WMKeymapChangedEvent>(wm_id, keymap));
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-14 18:38:53 -03:00
|
|
|
}
|