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.
This commit is contained in:
Andreas Kling 2021-03-26 19:53:49 +01:00
parent 557927f25b
commit d9f8f6a2d0
Notes: sideshowbarker 2024-07-18 21:04:13 +09:00
4 changed files with 11 additions and 0 deletions

View File

@ -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());
}
}

View File

@ -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);

View File

@ -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();

View File

@ -123,5 +123,7 @@ endpoint WindowServer = 2
SetScrollStepSize(u32 step_size) => ()
GetScrollStepSize() => (u32 step_size)
GetScreenBitmap() => (Gfx::ShareableBitmap bitmap)
Pong() =|
}