mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 22:57:34 +00:00
WindowServer+LibGUI: Add data_type and data fields to drag operations
These fields are intended to carry the real meat of a drag operation, and the "text" is just for what we show on screen (alongside the cursor during the actual drag.) The data field is just a String for now, but in the future we should make it something more flexible.
This commit is contained in:
parent
af7cb7ce1b
commit
cfcb38dff1
13 changed files with 50 additions and 15 deletions
|
@ -651,6 +651,6 @@ OwnPtr<WindowServer::StartDragResponse> WSClientConnection::handle(const WindowS
|
|||
bitmap = GraphicsBitmap::create_with_shared_buffer(GraphicsBitmap::Format::RGBA32, *shared_buffer, message.bitmap_size());
|
||||
}
|
||||
|
||||
wm.start_dnd_drag(*this, message.text(), bitmap);
|
||||
wm.start_dnd_drag(*this, message.text(), bitmap, message.data_type(), message.data());
|
||||
return make<WindowServer::StartDragResponse>(true);
|
||||
}
|
||||
|
|
|
@ -649,7 +649,7 @@ bool WSWindowManager::process_ongoing_drag(WSMouseEvent& event, WSWindow*& hover
|
|||
m_dnd_client->post_message(WindowClient::DragAccepted());
|
||||
if (hovered_window->client()) {
|
||||
auto translated_event = event.translated(-hovered_window->position());
|
||||
hovered_window->client()->post_message(WindowClient::DragDropped(hovered_window->window_id(), translated_event.position(), m_dnd_text));
|
||||
hovered_window->client()->post_message(WindowClient::DragDropped(hovered_window->window_id(), translated_event.position(), m_dnd_text, m_dnd_data_type, m_dnd_data));
|
||||
}
|
||||
} else {
|
||||
m_dnd_client->post_message(WindowClient::DragCancelled());
|
||||
|
@ -1190,12 +1190,14 @@ WSMenu* WSWindowManager::find_internal_menu_by_id(int menu_id)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void WSWindowManager::start_dnd_drag(WSClientConnection& client, const String& text, GraphicsBitmap* bitmap)
|
||||
void WSWindowManager::start_dnd_drag(WSClientConnection& client, const String& text, GraphicsBitmap* bitmap, const String& data_type, const String& data)
|
||||
{
|
||||
ASSERT(!m_dnd_client);
|
||||
m_dnd_client = client.make_weak_ptr();
|
||||
m_dnd_text = text;
|
||||
m_dnd_bitmap = bitmap;
|
||||
m_dnd_data_type = data_type;
|
||||
m_dnd_data = data;
|
||||
WSCompositor::the().invalidate_cursor();
|
||||
}
|
||||
|
||||
|
|
|
@ -68,10 +68,12 @@ public:
|
|||
|
||||
WSClientConnection* dnd_client() { return m_dnd_client.ptr(); }
|
||||
const String& dnd_text() const { return m_dnd_text; }
|
||||
const String& dnd_data_type() const { return m_dnd_data_type; }
|
||||
const String& dnd_data() const { return m_dnd_data; }
|
||||
const GraphicsBitmap* dnd_bitmap() const { return m_dnd_bitmap; }
|
||||
Rect dnd_rect() const;
|
||||
|
||||
void start_dnd_drag(WSClientConnection&, const String& text, GraphicsBitmap*);
|
||||
void start_dnd_drag(WSClientConnection&, const String& text, GraphicsBitmap*, const String& data_type, const String& data);
|
||||
void end_dnd_drag();
|
||||
|
||||
WSWindow* active_window() { return m_active_window.ptr(); }
|
||||
|
@ -283,6 +285,8 @@ private:
|
|||
|
||||
WeakPtr<WSClientConnection> m_dnd_client;
|
||||
String m_dnd_text;
|
||||
String m_dnd_data_type;
|
||||
String m_dnd_data;
|
||||
RefPtr<GraphicsBitmap> m_dnd_bitmap;
|
||||
};
|
||||
|
||||
|
|
|
@ -31,5 +31,5 @@ endpoint WindowClient = 4
|
|||
DragAccepted() =|
|
||||
DragCancelled() =|
|
||||
|
||||
DragDropped(i32 window_id, Point mouse_position, String text) =|
|
||||
DragDropped(i32 window_id, Point mouse_position, String text, String data_type, String data) =|
|
||||
}
|
||||
|
|
|
@ -67,5 +67,5 @@ endpoint WindowServer = 2
|
|||
GetWallpaper() => (String path)
|
||||
SetWindowOverrideCursor(i32 window_id, i32 cursor_type) => ()
|
||||
|
||||
StartDrag(String text, i32 bitmap_id, Size bitmap_size) => (bool started)
|
||||
StartDrag(String text, String data_type, String data, i32 bitmap_id, Size bitmap_size) => (bool started)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue