From 88e6d18a61b94a296329137c26e878d67e7b39d4 Mon Sep 17 00:00:00 2001 From: Timothy Date: Tue, 13 Jul 2021 00:35:46 +1000 Subject: [PATCH] WindowServer: Add WindowServer::async_set_window_parent_from_client() This allows a client to set the parent for one of its local windows where the parent window is in another client. --- .../Services/WindowServer/ClientConnection.cpp | 17 +++++++++++++++++ .../Services/WindowServer/ClientConnection.h | 1 + Userland/Services/WindowServer/WindowServer.ipc | 2 ++ 3 files changed, 20 insertions(+) diff --git a/Userland/Services/WindowServer/ClientConnection.cpp b/Userland/Services/WindowServer/ClientConnection.cpp index 040776a4a1..8a3fc0d7c0 100644 --- a/Userland/Services/WindowServer/ClientConnection.cpp +++ b/Userland/Services/WindowServer/ClientConnection.cpp @@ -1115,4 +1115,21 @@ void ClientConnection::set_flash_flush(bool enabled) Compositor::the().set_flash_flush(enabled); } +void ClientConnection::set_window_parent_from_client(i32 client_id, i32 parent_id, i32 child_id) +{ + auto child_window = window_from_id(child_id); + if (!child_window) + did_misbehave("SetWindowParentFromClient: Bad child window ID"); + + auto client_connection = from_client_id(client_id); + if (!client_connection) + did_misbehave("SetWindowParentFromClient: Bad client ID"); + + auto parent_window = client_connection->window_from_id(parent_id); + if (!parent_window) + did_misbehave("SetWindowParentFromClient: Bad parent window ID"); + + child_window->set_parent_window(*parent_window); +} + } diff --git a/Userland/Services/WindowServer/ClientConnection.h b/Userland/Services/WindowServer/ClientConnection.h index 7ad4ae04e3..67c558b57c 100644 --- a/Userland/Services/WindowServer/ClientConnection.h +++ b/Userland/Services/WindowServer/ClientConnection.h @@ -164,6 +164,7 @@ private: virtual Messages::WindowServer::IsWindowModifiedResponse is_window_modified(i32) override; virtual Messages::WindowServer::GetDesktopDisplayScaleResponse get_desktop_display_scale(u32) override; virtual void set_flash_flush(bool) override; + virtual void set_window_parent_from_client(i32, i32, i32) override; Window* window_from_id(i32 window_id); diff --git a/Userland/Services/WindowServer/WindowServer.ipc b/Userland/Services/WindowServer/WindowServer.ipc index a4e784cbed..f0deb6845c 100644 --- a/Userland/Services/WindowServer/WindowServer.ipc +++ b/Userland/Services/WindowServer/WindowServer.ipc @@ -147,4 +147,6 @@ endpoint WindowServer get_desktop_display_scale(u32 screen_index) => (int desktop_display_scale) set_flash_flush(bool enabled) =| + + set_window_parent_from_client(i32 client_id, i32 parent_id, i32 child_id) =| }