summaryrefslogtreecommitdiff
path: root/Services
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-01-09 11:01:41 +0100
committerAndreas Kling <kling@serenityos.org>2021-01-09 12:02:07 +0100
commit67b91d51a75eb5231584f9ff74524942ec0f38ed (patch)
tree9ce32542a17e4b7d930f8741d371168a54c2ee2c /Services
parent3b94af2c07ea07e0c8b2b315ba63f6c8c2619daf (diff)
downloadserenity-67b91d51a75eb5231584f9ff74524942ec0f38ed.zip
WindowServer+LibGUI: Pass the set of mime types being dragged to client
Previously the client would only learn the mime type of what was being dropped on it once the drop occurred. To enable more sophisticated filtering of drag & drop, we now pass along the list of mime types being dragged to the client with each MouseMove event. (Note that MouseMove is translated to the various Drag* events in LibGUI on the client side.)
Diffstat (limited to 'Services')
-rw-r--r--Services/WindowServer/Event.h9
-rw-r--r--Services/WindowServer/Screen.cpp2
-rw-r--r--Services/WindowServer/Window.cpp2
-rw-r--r--Services/WindowServer/WindowClient.ipc2
4 files changed, 11 insertions, 4 deletions
diff --git a/Services/WindowServer/Event.h b/Services/WindowServer/Event.h
index 3e9adf8830..e82df2d4c9 100644
--- a/Services/WindowServer/Event.h
+++ b/Services/WindowServer/Event.h
@@ -126,7 +126,13 @@ public:
unsigned modifiers() const { return m_modifiers; }
int wheel_delta() const { return m_wheel_delta; }
bool is_drag() const { return m_drag; }
- const String& drag_data_type() const { return m_drag_data_type; }
+
+ Vector<String> mime_types() const
+ {
+ if (!m_mime_data)
+ return {};
+ return m_mime_data->formats();
+ }
void set_drag(bool b) { m_drag = b; }
void set_mime_data(const Core::MimeData& mime_data) { m_mime_data = mime_data; }
@@ -140,7 +146,6 @@ private:
unsigned m_modifiers { 0 };
int m_wheel_delta { 0 };
bool m_drag { false };
- String m_drag_data_type;
RefPtr<const Core::MimeData> m_mime_data;
};
diff --git a/Services/WindowServer/Screen.cpp b/Services/WindowServer/Screen.cpp
index f929586c50..2d68c4890e 100644
--- a/Services/WindowServer/Screen.cpp
+++ b/Services/WindowServer/Screen.cpp
@@ -162,6 +162,8 @@ void Screen::on_receive_mouse_data(const MousePacket& packet)
post_mousedown_or_mouseup_if_needed(MouseButton::Forward);
if (m_cursor_location != prev_location) {
auto message = make<MouseEvent>(Event::MouseMove, m_cursor_location, buttons, MouseButton::None, m_modifiers);
+ if (WindowManager::the().dnd_client())
+ message->set_mime_data(WindowManager::the().dnd_mime_data());
Core::EventLoop::current().post_event(WindowManager::the(), move(message));
}
diff --git a/Services/WindowServer/Window.cpp b/Services/WindowServer/Window.cpp
index b79684e79e..1d0497c1c6 100644
--- a/Services/WindowServer/Window.cpp
+++ b/Services/WindowServer/Window.cpp
@@ -182,7 +182,7 @@ void Window::handle_mouse_event(const MouseEvent& event)
switch (event.type()) {
case Event::MouseMove:
- m_client->post_message(Messages::WindowClient::MouseMove(m_window_id, event.position(), (u32)event.button(), event.buttons(), event.modifiers(), event.wheel_delta(), event.is_drag(), event.drag_data_type()));
+ m_client->post_message(Messages::WindowClient::MouseMove(m_window_id, event.position(), (u32)event.button(), event.buttons(), event.modifiers(), event.wheel_delta(), event.is_drag(), event.mime_types()));
break;
case Event::MouseDown:
m_client->post_message(Messages::WindowClient::MouseDown(m_window_id, event.position(), (u32)event.button(), event.buttons(), event.modifiers(), event.wheel_delta()));
diff --git a/Services/WindowServer/WindowClient.ipc b/Services/WindowServer/WindowClient.ipc
index a1ce1413a3..c6ac17b022 100644
--- a/Services/WindowServer/WindowClient.ipc
+++ b/Services/WindowServer/WindowClient.ipc
@@ -1,7 +1,7 @@
endpoint WindowClient = 4
{
Paint(i32 window_id, Gfx::IntSize window_size, Vector<Gfx::IntRect> rects) =|
- MouseMove(i32 window_id, Gfx::IntPoint mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta, bool is_drag, String drag_data_type) =|
+ MouseMove(i32 window_id, Gfx::IntPoint mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta, bool is_drag, Vector<String> mime_types) =|
MouseDown(i32 window_id, Gfx::IntPoint mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta) =|
MouseDoubleClick(i32 window_id, Gfx::IntPoint mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta) =|
MouseUp(i32 window_id, Gfx::IntPoint mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta) =|