1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:48:11 +00:00

WindowServer+LibGUI: Pass drag&drop bitmaps via Gfx::ShareableBitmap

This makes them backed by anonymous files instead of shbufs and also
simplifies the code significantly on both client and server side.
This commit is contained in:
Andreas Kling 2021-01-16 10:06:27 +01:00
parent 60e580fa3e
commit ab0dad5ea2
5 changed files with 7 additions and 23 deletions

View file

@ -747,18 +747,7 @@ OwnPtr<Messages::WindowServer::StartDragResponse> ClientConnection::handle(const
if (wm.dnd_client())
return make<Messages::WindowServer::StartDragResponse>(false);
RefPtr<Gfx::Bitmap> bitmap;
if (message.bitmap_id() != -1) {
auto shared_buffer = SharedBuffer::create_from_shbuf_id(message.bitmap_id());
ssize_t size_in_bytes = message.bitmap_size().area() * sizeof(Gfx::RGBA32);
if (size_in_bytes > shared_buffer->size()) {
did_misbehave("SetAppletBackingStore: Shared buffer is too small for applet size");
return {};
}
bitmap = Gfx::Bitmap::create_with_shared_buffer(Gfx::BitmapFormat::RGBA32, *shared_buffer, message.bitmap_size());
}
wm.start_dnd_drag(*this, message.text(), bitmap, Core::MimeData::construct(message.mime_data()));
wm.start_dnd_drag(*this, message.text(), message.drag_bitmap().bitmap(), Core::MimeData::construct(message.mime_data()));
return make<Messages::WindowServer::StartDragResponse>(true);
}