mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:17:35 +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:
parent
60e580fa3e
commit
ab0dad5ea2
5 changed files with 7 additions and 23 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -1383,7 +1383,7 @@ Gfx::IntRect WindowManager::maximized_window_rect(const Window& window) const
|
|||
return rect;
|
||||
}
|
||||
|
||||
void WindowManager::start_dnd_drag(ClientConnection& client, const String& text, Gfx::Bitmap* bitmap, const Core::MimeData& mime_data)
|
||||
void WindowManager::start_dnd_drag(ClientConnection& client, const String& text, const Gfx::Bitmap* bitmap, const Core::MimeData& mime_data)
|
||||
{
|
||||
ASSERT(!m_dnd_client);
|
||||
m_dnd_client = client;
|
||||
|
|
|
@ -104,7 +104,7 @@ public:
|
|||
const Gfx::Bitmap* dnd_bitmap() const { return m_dnd_bitmap; }
|
||||
Gfx::IntRect dnd_rect() const;
|
||||
|
||||
void start_dnd_drag(ClientConnection&, const String& text, Gfx::Bitmap*, const Core::MimeData&);
|
||||
void start_dnd_drag(ClientConnection&, const String& text, const Gfx::Bitmap*, const Core::MimeData&);
|
||||
void end_dnd_drag();
|
||||
|
||||
Window* active_window() { return m_active_window.ptr(); }
|
||||
|
|
|
@ -94,7 +94,7 @@ endpoint WindowServer = 2
|
|||
SetWindowCursor(i32 window_id, i32 cursor_type) => ()
|
||||
SetWindowCustomCursor(i32 window_id, Gfx::ShareableBitmap cursor) => ()
|
||||
|
||||
StartDrag([UTF8] String text, HashMap<String,ByteBuffer> mime_data, i32 bitmap_id, Gfx::IntSize bitmap_size) => (bool started)
|
||||
StartDrag([UTF8] String text, HashMap<String,ByteBuffer> mime_data, Gfx::ShareableBitmap drag_bitmap) => (bool started)
|
||||
|
||||
SetSystemTheme(String theme_path, [UTF8] String theme_name) => (bool success)
|
||||
GetSystemTheme() => ([UTF8] String theme_name)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue