1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:07:35 +00:00

LibGUI+WindowServer: Separate window manager IPC from regular IPC

With this patch the window manager related functionality is split out
onto a new endpoint pair named WindowManagerServer/Client.  This allows
window manager functionality to be potentially privilege separated in
the future.  To this end, a new client named WMConnectionClient
is used to maintain a window manager connection.  When a process
connects to the endpoint and greets the WindowServer as a window manager
(via Window::make_window_manager(int)), they're subscribed to the events
they requested via the WM event mask.

This patch also removes the hardcoding of the Taskbar WindowType to
receive WM events automatically.  However, being a window manager still
requires having an active window, at the moment.
This commit is contained in:
sin-ack 2021-04-14 21:38:53 +00:00 committed by Andreas Kling
parent 139c04a6e5
commit aa56f9a1e0
24 changed files with 522 additions and 230 deletions

View file

@ -33,6 +33,7 @@
#include <WindowServer/Event.h>
#include <WindowServer/EventLoop.h>
#include <WindowServer/Screen.h>
#include <WindowServer/WMClientConnection.h>
#include <WindowServer/WindowManager.h>
#include <errno.h>
#include <fcntl.h>
@ -46,16 +47,19 @@
namespace WindowServer {
EventLoop::EventLoop()
: m_server(Core::LocalServer::construct())
: m_window_server(Core::LocalServer::construct())
, m_wm_server(Core::LocalServer::construct())
{
m_keyboard_fd = open("/dev/keyboard", O_RDONLY | O_NONBLOCK | O_CLOEXEC);
m_mouse_fd = open("/dev/mouse", O_RDONLY | O_NONBLOCK | O_CLOEXEC);
bool ok = m_server->take_over_from_system_server();
bool ok = m_window_server->take_over_from_system_server("/tmp/portal/window");
VERIFY(ok);
ok = m_wm_server->take_over_from_system_server("/tmp/portal/wm");
VERIFY(ok);
m_server->on_ready_to_accept = [this] {
auto client_socket = m_server->accept();
m_window_server->on_ready_to_accept = [this] {
auto client_socket = m_window_server->accept();
if (!client_socket) {
dbgln("WindowServer: accept failed.");
return;
@ -65,6 +69,17 @@ EventLoop::EventLoop()
IPC::new_client_connection<ClientConnection>(client_socket.release_nonnull(), client_id);
};
m_wm_server->on_ready_to_accept = [this] {
auto client_socket = m_wm_server->accept();
if (!client_socket) {
dbgln("WindowServer: WM accept failed.");
return;
}
static int s_next_wm_id = 0;
int wm_id = ++s_next_wm_id;
IPC::new_client_connection<WMClientConnection>(client_socket.release_nonnull(), wm_id);
};
if (m_keyboard_fd >= 0) {
m_keyboard_notifier = Core::Notifier::construct(m_keyboard_fd, Core::Notifier::Read);
m_keyboard_notifier->on_ready_to_read = [this] { drain_keyboard(); };