summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI/ConnectionToWindowMangerServer.cpp
blob: e5b8e482d926f862c540bc5d78a55a1f4d9a03b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
 * Copyright (c) 2021, the SerenityOS developers.
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#include <LibGUI/ConnectionToWindowMangerServer.h>
#include <LibGUI/Event.h>
#include <LibGUI/Window.h>

namespace GUI {

ConnectionToWindowMangerServer& ConnectionToWindowMangerServer::the()
{
    static RefPtr<ConnectionToWindowMangerServer> s_connection = nullptr;
    if (!s_connection)
        s_connection = ConnectionToWindowMangerServer::try_create().release_value_but_fixme_should_propagate_errors();
    return *s_connection;
}

void ConnectionToWindowMangerServer::window_state_changed(i32 wm_id, i32 client_id, i32 window_id,
    i32 parent_client_id, i32 parent_window_id, u32 workspace_row, u32 workspace_column,
    bool is_active, bool is_minimized, bool is_modal, bool is_frameless, i32 window_type,
    String const& title, Gfx::IntRect const& rect, Optional<i32> const& progress)
{
    if (auto* window = Window::from_window_id(wm_id))
        Core::EventLoop::current().post_event(*window, make<WMWindowStateChangedEvent>(client_id, window_id, parent_client_id, parent_window_id, title, rect, workspace_row, workspace_column, is_active, is_modal, static_cast<WindowType>(window_type), is_minimized, is_frameless, progress));
}

void ConnectionToWindowMangerServer::applet_area_size_changed(i32 wm_id, Gfx::IntSize const& size)
{
    if (auto* window = Window::from_window_id(wm_id))
        Core::EventLoop::current().post_event(*window, make<WMAppletAreaSizeChangedEvent>(size));
}

void ConnectionToWindowMangerServer::window_rect_changed(i32 wm_id, i32 client_id, i32 window_id, Gfx::IntRect const& rect)
{
    if (auto* window = Window::from_window_id(wm_id))
        Core::EventLoop::current().post_event(*window, make<WMWindowRectChangedEvent>(client_id, window_id, rect));
}

void ConnectionToWindowMangerServer::window_icon_bitmap_changed(i32 wm_id, i32 client_id, i32 window_id, Gfx::ShareableBitmap const& bitmap)
{
    if (auto* window = Window::from_window_id(wm_id)) {
        Core::EventLoop::current().post_event(*window, make<WMWindowIconBitmapChangedEvent>(client_id, window_id, bitmap.bitmap()));
    }
}

void ConnectionToWindowMangerServer::window_removed(i32 wm_id, i32 client_id, i32 window_id)
{
    if (auto* window = Window::from_window_id(wm_id))
        Core::EventLoop::current().post_event(*window, make<WMWindowRemovedEvent>(client_id, window_id));
}

void ConnectionToWindowMangerServer::super_key_pressed(i32 wm_id)
{
    if (auto* window = Window::from_window_id(wm_id))
        Core::EventLoop::current().post_event(*window, make<WMSuperKeyPressedEvent>(wm_id));
}

void ConnectionToWindowMangerServer::super_space_key_pressed(i32 wm_id)
{
    if (auto* window = Window::from_window_id(wm_id))
        Core::EventLoop::current().post_event(*window, make<WMSuperSpaceKeyPressedEvent>(wm_id));
}

void ConnectionToWindowMangerServer::super_digit_key_pressed(i32 wm_id, u8 digit)
{
    if (auto* window = Window::from_window_id(wm_id))
        Core::EventLoop::current().post_event(*window, make<WMSuperDigitKeyPressedEvent>(wm_id, digit));
}

void ConnectionToWindowMangerServer::workspace_changed(i32 wm_id, u32 row, u32 column)
{
    if (auto* window = Window::from_window_id(wm_id))
        Core::EventLoop::current().post_event(*window, make<WMWorkspaceChangedEvent>(wm_id, row, column));
}

void ConnectionToWindowMangerServer::keymap_changed(i32 wm_id, String const& keymap)
{
    if (auto* window = Window::from_window_id(wm_id))
        Core::EventLoop::current().post_event(*window, make<WMKeymapChangedEvent>(wm_id, keymap));
}

}