From b77b631571087e8fb1e1f40d7efd87eb7126b713 Mon Sep 17 00:00:00 2001 From: Timothy Date: Sat, 17 Jul 2021 19:36:51 +1000 Subject: [PATCH] WindowServer: Add WindowServer::get_window_rect_from_client() This allows a client to get the rect of a window in another client. --- Userland/Services/WindowServer/ClientConnection.cpp | 13 +++++++++++++ Userland/Services/WindowServer/ClientConnection.h | 1 + Userland/Services/WindowServer/WindowServer.ipc | 1 + 3 files changed, 15 insertions(+) diff --git a/Userland/Services/WindowServer/ClientConnection.cpp b/Userland/Services/WindowServer/ClientConnection.cpp index 8a3fc0d7c0c..b6edb95a5b7 100644 --- a/Userland/Services/WindowServer/ClientConnection.cpp +++ b/Userland/Services/WindowServer/ClientConnection.cpp @@ -1132,4 +1132,17 @@ void ClientConnection::set_window_parent_from_client(i32 client_id, i32 parent_i child_window->set_parent_window(*parent_window); } +Messages::WindowServer::GetWindowRectFromClientResponse ClientConnection::get_window_rect_from_client(i32 client_id, i32 window_id) +{ + auto client_connection = from_client_id(client_id); + if (!client_connection) + did_misbehave("GetWindowRectFromClient: Bad client ID"); + + auto window = client_connection->window_from_id(window_id); + if (!window) + did_misbehave("GetWindowRectFromClient: Bad window ID"); + + return window->rect(); +} + } diff --git a/Userland/Services/WindowServer/ClientConnection.h b/Userland/Services/WindowServer/ClientConnection.h index 67c558b57c3..8967d41ef9f 100644 --- a/Userland/Services/WindowServer/ClientConnection.h +++ b/Userland/Services/WindowServer/ClientConnection.h @@ -165,6 +165,7 @@ private: 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; + virtual Messages::WindowServer::GetWindowRectFromClientResponse get_window_rect_from_client(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 f0deb6845c9..7a24f47d2a1 100644 --- a/Userland/Services/WindowServer/WindowServer.ipc +++ b/Userland/Services/WindowServer/WindowServer.ipc @@ -149,4 +149,5 @@ endpoint WindowServer set_flash_flush(bool enabled) =| set_window_parent_from_client(i32 client_id, i32 parent_id, i32 child_id) =| + get_window_rect_from_client(i32 client_id, i32 window_id) => (Gfx::IntRect rect) }