From d44bc8b8eef470780fd5cbd8737b5cc1a4226b39 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20H=C3=B8gsberg?= Date: Tue, 30 Nov 2010 15:10:26 -0500 Subject: [PATCH] Add reject round trip to dnd protocol This lets a drag target reject a drop. --- clients/dnd.c | 14 +++++++++----- compositor/compositor.c | 12 +++++++++++- protocol/wayland.xml | 5 +++++ 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/clients/dnd.c b/clients/dnd.c index d0f2081..d5594ff 100644 --- a/clients/dnd.c +++ b/clients/dnd.c @@ -271,9 +271,16 @@ drag_finish(void *data, struct wl_drag *drag, int fd) free(dnd_drag); } +static void +drag_reject(void *data, struct wl_drag *drag) +{ + fprintf(stderr, "drop rejected\n"); +} + static const struct wl_drag_listener drag_listener = { drag_target, - drag_finish + drag_finish, + drag_reject }; static void @@ -379,10 +386,7 @@ drag_offer_drop(void *data, struct wl_drag_offer *offer) if (!dnd_offer->drag_type) { fprintf(stderr, "got 'drop', but no target\n"); - /* FIXME: Should send response so compositor and - * source knows it's over. Can't send -1 to indicate - * 'no target' though becauses of the way fd passing - * currently works. */ + wl_drag_offer_reject(offer); return; } diff --git a/compositor/compositor.c b/compositor/compositor.c index cbb0b6b..f993bf6 100644 --- a/compositor/compositor.c +++ b/compositor/compositor.c @@ -1137,9 +1137,19 @@ drag_offer_receive(struct wl_client *client, close(fd); } +static void +drag_offer_reject(struct wl_client *client, struct wl_drag_offer *offer) +{ + struct wl_drag *drag = container_of(offer, struct wl_drag, drag_offer); + + wl_client_post_event(drag->source->client, &drag->resource.base, + WL_DRAG_REJECT); +} + static const struct wl_drag_offer_interface drag_offer_interface = { drag_offer_accept, - drag_offer_receive + drag_offer_receive, + drag_offer_reject }; static void diff --git a/protocol/wayland.xml b/protocol/wayland.xml index 24c53c2..77ff8f8 100644 --- a/protocol/wayland.xml +++ b/protocol/wayland.xml @@ -209,6 +209,8 @@ + + @@ -226,6 +228,9 @@ + + + -- 2.7.4