summaryrefslogtreecommitdiff
path: root/Servers/WindowServer/WSWindowManager.h
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-12-08 16:50:23 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-12-08 16:50:23 +0100
commita7f414bba7f4fa306af30cdf52df6df85278ed62 (patch)
tree0a7e483b275e01421ca2945a6276c5f95ea5ba12 /Servers/WindowServer/WSWindowManager.h
parente09a02ad3f95c9622be803d4074b85a55b91c2fa (diff)
downloadserenity-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.h13
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>