mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 18:55:07 +00:00
LibGUI+WindowServer: Allow specifying an optional drag bitmap
This bitmap is displayed alongside the dragged text underneath the mouse cursor while dragging. This will be a perfect fit for dragging e.g files around. :^)
This commit is contained in:
parent
183ee5847c
commit
f5dfb29607
5 changed files with 36 additions and 6 deletions
|
@ -1,3 +1,4 @@
|
|||
#include <LibDraw/GraphicsBitmap.h>
|
||||
#include <LibGUI/GDragOperation.h>
|
||||
#include <LibGUI/GWindowServerConnection.h>
|
||||
|
||||
|
@ -17,7 +18,17 @@ GDragOperation::Outcome GDragOperation::exec()
|
|||
ASSERT(!s_current_drag_operation);
|
||||
ASSERT(!m_event_loop);
|
||||
|
||||
auto response = GWindowServerConnection::the().send_sync<WindowServer::StartDrag>(m_text, -1, Size());
|
||||
int bitmap_id = -1;
|
||||
Size bitmap_size;
|
||||
RefPtr<GraphicsBitmap> shared_bitmap;
|
||||
if (m_bitmap) {
|
||||
shared_bitmap = m_bitmap->to_shareable_bitmap();
|
||||
shared_bitmap->shared_buffer()->share_with(GWindowServerConnection::the().server_pid());
|
||||
bitmap_id = shared_bitmap->shared_buffer_id();
|
||||
bitmap_size = shared_bitmap->size();
|
||||
}
|
||||
|
||||
auto response = GWindowServerConnection::the().send_sync<WindowServer::StartDrag>(m_text, bitmap_id, bitmap_size);
|
||||
if (!response->started()) {
|
||||
m_outcome = Outcome::Cancelled;
|
||||
return m_outcome;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue