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

LibGUI+WindowServer: Make DragOperation hold a MimeData instance

...instead of maybe bitmap + a single mime type and its corresponding data.
This allows drag&drop operations to hold multiple different kinds of
data, and the views/applications to choose between those.
For instance, Spreadsheet can keep the structure of the dragged cells,
and still provide text-only data to be passed to different unrelated editors.
This commit is contained in:
AnotherTest 2020-11-07 23:14:21 +03:30 committed by Andreas Kling
parent c930e02624
commit 6d1e47e7dd
15 changed files with 98 additions and 59 deletions

View file

@ -705,7 +705,7 @@ bool WindowManager::process_ongoing_drag(MouseEvent& event, Window*& hovered_win
hovered_window = &window;
auto translated_event = event.translated(-window.position());
translated_event.set_drag(true);
translated_event.set_drag_data_type(m_dnd_data_type);
translated_event.set_mime_data(*m_dnd_mime_data);
deliver_mouse_event(window, translated_event);
return IterationDecision::Break;
});
@ -727,7 +727,7 @@ bool WindowManager::process_ongoing_drag(MouseEvent& event, Window*& hovered_win
m_dnd_client->post_message(Messages::WindowClient::DragAccepted());
if (hovered_window->client()) {
auto translated_event = event.translated(-hovered_window->position());
hovered_window->client()->post_message(Messages::WindowClient::DragDropped(hovered_window->window_id(), translated_event.position(), m_dnd_text, m_dnd_data_type, m_dnd_data));
hovered_window->client()->post_message(Messages::WindowClient::DragDropped(hovered_window->window_id(), translated_event.position(), m_dnd_text, m_dnd_mime_data->all_data()));
}
} else {
m_dnd_client->post_message(Messages::WindowClient::DragCancelled());
@ -1355,14 +1355,13 @@ 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 String& data_type, const String& data)
void WindowManager::start_dnd_drag(ClientConnection& client, const String& text, Gfx::Bitmap* bitmap, const Core::MimeData& mime_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;
m_dnd_mime_data = mime_data;
Compositor::the().invalidate_cursor();
m_active_input_tracking_window = nullptr;
}