selection: implement support for drag-and-drop

We accept COPY and MOVE actions, for text/plain;charset=utf-8
mime-types.

To implement DnD, we need to track the current DnD data offer *and*
the terminal instance it is (currently) targeting.

To do this, a seat has a new member, ‘dnd_term’. On a DnD enter event,
we lookup the corresponding terminal instance and point ‘dnd_term’ to
it.

On a DnD leave event, ‘dnd_term’ is reset.

The DnD data offer is tracked in the terminal’s wayland window
instance. It is reset, along with the seat’s ‘dnd_term’ on a DnD leave
event.

On a drop event, we immediately clear the seat’s ‘dnd_term’, to ensure
we don’t reset it, or destroy the offer before the drop has been
completed.

The drop’s ‘done()’ callback takes care of destroying and resetting
the DnD offer in the terminal’s wayland window instance.

Closes #175
This commit is contained in:
Daniel Eklöf 2020-10-26 21:02:53 +01:00
parent af3b604d8e
commit 8e23b5b70d
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
3 changed files with 98 additions and 5 deletions

View file

@ -205,6 +205,9 @@ struct seat {
struct wl_clipboard clipboard;
struct wl_primary primary;
/* Drag n drop */
struct terminal *dnd_term;
};
enum csd_surface {
@ -309,6 +312,8 @@ struct wl_window {
struct wl_callback *frame_callback;
struct wl_data_offer *dnd_offer;
tll(const struct monitor *) on_outputs; /* Outputs we're mapped on */
bool is_configured;