mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:07:34 +00:00
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. :^)
This commit is contained in:
parent
e09a02ad3f
commit
a7f414bba7
19 changed files with 318 additions and 3 deletions
|
@ -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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue