diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-12-08 16:50:23 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-12-08 16:50:23 +0100 |
commit | a7f414bba7f4fa306af30cdf52df6df85278ed62 (patch) | |
tree | 0a7e483b275e01421ca2945a6276c5f95ea5ba12 /Servers/WindowServer/WSWindowManager.h | |
parent | e09a02ad3f95c9622be803d4074b85a55b91c2fa (diff) | |
download | serenity-a7f414bba7f4fa306af30cdf52df6df85278ed62.zip |
LibGUI+WindowServer: Start fleshing out drag&drop functionality
This patch enables basic drag&drop between applications.
You initiate a drag by creating a GDragOperation object and calling
exec() on it. This creates a nested event loop in the calling program
that only returns once the drag operation has ended.
On the receiving side, you get a call to GWidget::drop_event() with
a GDropEvent containing information about the dropped data.
The only data passed right now is a piece of text that's also used
to visually indicate that a drag is happening (by showing the text in
a little box that follows the mouse cursor around.)
There are things to fix here, but we're off to a nice start. :^)
Diffstat (limited to 'Servers/WindowServer/WSWindowManager.h')
-rw-r--r-- | Servers/WindowServer/WSWindowManager.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Servers/WindowServer/WSWindowManager.h b/Servers/WindowServer/WSWindowManager.h index b0ef9fcbf8..eba7e8a44b 100644 --- a/Servers/WindowServer/WSWindowManager.h +++ b/Servers/WindowServer/WSWindowManager.h @@ -66,6 +66,14 @@ public: Rect maximized_window_rect(const WSWindow&) const; + WSClientConnection* dnd_client() { return m_dnd_client.ptr(); } + const String& dnd_text() const { return m_dnd_text; } + const GraphicsBitmap* dnd_bitmap() const { return m_dnd_bitmap; } + Rect dnd_rect() const; + + void start_dnd_drag(WSClientConnection&, const String& text, GraphicsBitmap*); + void end_dnd_drag(); + WSWindow* active_window() { return m_active_window.ptr(); } const WSClientConnection* active_client() const; bool active_window_is_modal() const { return m_active_window && m_active_window->is_modal(); } @@ -156,6 +164,7 @@ private: void deliver_mouse_event(WSWindow& window, WSMouseEvent& event); bool process_ongoing_window_resize(const WSMouseEvent&, WSWindow*& hovered_window); bool process_ongoing_window_drag(WSMouseEvent&, WSWindow*& hovered_window); + bool process_ongoing_drag(WSMouseEvent&, WSWindow*& hovered_window); void start_window_drag(WSWindow&, const WSMouseEvent&); void set_hovered_window(WSWindow*); template<typename Callback> @@ -268,6 +277,10 @@ private: }; Vector<AppMetadata> m_apps; HashMap<String, NonnullRefPtr<WSMenu>> m_app_category_menus; + + WeakPtr<WSClientConnection> m_dnd_client; + String m_dnd_text; + RefPtr<GraphicsBitmap> m_dnd_bitmap; }; template<typename Callback> |