
This change unfortunately cannot be atomically made without a single commit changing everything. Most of the important changes are in LibIPC/Connection.cpp, LibIPC/ServerConnection.cpp and LibCore/LocalServer.cpp. The notable changes are: - IPCCompiler now generates the decode and decode_message functions such that they take a Core::Stream::LocalSocket instead of the socket fd. - IPC::Decoder now uses the receive_fd method of LocalSocket instead of doing system calls directly on the fd. - IPC::ConnectionBase and related classes now use the Stream API functions. - IPC::ServerConnection no longer constructs the socket itself; instead, a convenience macro, IPC_CLIENT_CONNECTION, is used in place of C_OBJECT and will generate a static try_create factory function for the ServerConnection subclass. The subclass is now responsible for passing the socket constructed in this function to its ServerConnection base; the socket is passed as the first argument to the constructor (as a NonnullOwnPtr<Core::Stream::LocalServer>) before any other arguments. - The functionality regarding taking over sockets from SystemServer has been moved to LibIPC/SystemServerTakeover.cpp. The Core::LocalSocket implementation of this functionality hasn't been deleted due to my intention of removing this class in the near future and to reduce noise on this (already quite noisy) PR.
73 lines
3 KiB
C++
73 lines
3 KiB
C++
/*
|
|
* Copyright (c) 2021, the SerenityOS developers.
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibGUI/Event.h>
|
|
#include <LibGUI/Window.h>
|
|
#include <LibGUI/WindowManagerServerConnection.h>
|
|
|
|
namespace GUI {
|
|
|
|
WindowManagerServerConnection& WindowManagerServerConnection::the()
|
|
{
|
|
static RefPtr<WindowManagerServerConnection> s_connection = nullptr;
|
|
if (!s_connection)
|
|
s_connection = WindowManagerServerConnection::try_create().release_value_but_fixme_should_propagate_errors();
|
|
return *s_connection;
|
|
}
|
|
|
|
void WindowManagerServerConnection::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 WindowManagerServerConnection::applet_area_size_changed(i32 wm_id, const Gfx::IntSize& size)
|
|
{
|
|
if (auto* window = Window::from_window_id(wm_id))
|
|
Core::EventLoop::current().post_event(*window, make<WMAppletAreaSizeChangedEvent>(size));
|
|
}
|
|
|
|
void WindowManagerServerConnection::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 WindowManagerServerConnection::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 WindowManagerServerConnection::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 WindowManagerServerConnection::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 WindowManagerServerConnection::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 WindowManagerServerConnection::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));
|
|
}
|
|
|
|
}
|