diff options
author | Andreas Kling <kling@serenityos.org> | 2021-03-26 19:53:49 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-03-26 20:33:23 +0100 |
commit | d9f8f6a2d0e703b346b72694bc0437ad911feee0 (patch) | |
tree | fdc1fc69df99d7ede9995fceaeefe1373eec3fa7 /Userland/Services | |
parent | 557927f25b9d0b9b3f5e4596b4640524050b9ca7 (diff) | |
download | serenity-d9f8f6a2d0e703b346b72694bc0437ad911feee0.zip |
WindowServer: Add an IPC call for taking a screenshot
This patch adds Messages::WindowServer::GetScreenBitmap. It returns the
currently displayed on-screen bitmap as-is, as a Gfx::ShareableBitmap.
Diffstat (limited to 'Userland/Services')
4 files changed, 11 insertions, 0 deletions
diff --git a/Userland/Services/WindowServer/ClientConnection.cpp b/Userland/Services/WindowServer/ClientConnection.cpp index aa1c756fa3..8975e76ccc 100644 --- a/Userland/Services/WindowServer/ClientConnection.cpp +++ b/Userland/Services/WindowServer/ClientConnection.cpp @@ -987,4 +987,10 @@ void ClientConnection::did_become_responsive() set_unresponsive(false); } +OwnPtr<Messages::WindowServer::GetScreenBitmapResponse> ClientConnection::handle(const Messages::WindowServer::GetScreenBitmap&) +{ + auto& bitmap = Compositor::the().front_bitmap_for_screenshot({}); + return make<Messages::WindowServer::GetScreenBitmapResponse>(bitmap.to_shareable_bitmap()); +} + } diff --git a/Userland/Services/WindowServer/ClientConnection.h b/Userland/Services/WindowServer/ClientConnection.h index 6ee7fe7456..51b84e7b82 100644 --- a/Userland/Services/WindowServer/ClientConnection.h +++ b/Userland/Services/WindowServer/ClientConnection.h @@ -167,6 +167,7 @@ private: virtual OwnPtr<Messages::WindowServer::GetMouseAccelerationResponse> handle(const Messages::WindowServer::GetMouseAcceleration&) override; virtual OwnPtr<Messages::WindowServer::SetScrollStepSizeResponse> handle(const Messages::WindowServer::SetScrollStepSize&) override; virtual OwnPtr<Messages::WindowServer::GetScrollStepSizeResponse> handle(const Messages::WindowServer::GetScrollStepSize&) override; + virtual OwnPtr<Messages::WindowServer::GetScreenBitmapResponse> handle(const Messages::WindowServer::GetScreenBitmap&) override; Window* window_from_id(i32 window_id); diff --git a/Userland/Services/WindowServer/Compositor.h b/Userland/Services/WindowServer/Compositor.h index 01fb0e7b8e..01a1ac2612 100644 --- a/Userland/Services/WindowServer/Compositor.h +++ b/Userland/Services/WindowServer/Compositor.h @@ -76,6 +76,8 @@ public: void did_construct_window_manager(Badge<WindowManager>); + const Gfx::Bitmap& front_bitmap_for_screenshot(Badge<ClientConnection>) const { return *m_front_bitmap; } + private: Compositor(); void init_bitmaps(); diff --git a/Userland/Services/WindowServer/WindowServer.ipc b/Userland/Services/WindowServer/WindowServer.ipc index 0e1b1cb89d..c621cd5488 100644 --- a/Userland/Services/WindowServer/WindowServer.ipc +++ b/Userland/Services/WindowServer/WindowServer.ipc @@ -123,5 +123,7 @@ endpoint WindowServer = 2 SetScrollStepSize(u32 step_size) => () GetScrollStepSize() => (u32 step_size) + GetScreenBitmap() => (Gfx::ShareableBitmap bitmap) + Pong() =| } |