[PATCH wayland 1/2] client: add wl_data_offer_finish() and wl_data_source_dropped()

Giulio Camuffo giuliocamuffo at gmail.com
Wed Mar 13 03:21:18 PDT 2013


Please discard this, I've sent a better one.

Giulio

2013/3/9 Giulio Camuffo <giuliocamuffo at gmail.com>:
> wl_data_offer_finish() must be called by the receiver client when the drop
> operation is done. It wants a uint argument which must be a
> wl_data_offer_dnd_action value, which are: ignore, copy, move, link.
> This action value is passed to the wl_data_source_dropped() event
> so that the source client can free the wl_data_source and do other
> things that are necessary depending on the action value.
> ---
>  protocol/wayland.xml | 33 +++++++++++++++++++++++++++++++--
>  src/data-device.c    | 20 ++++++++++++++++++++
>  src/wayland-server.h |  2 ++
>  3 files changed, 53 insertions(+), 2 deletions(-)
>
> diff --git a/protocol/wayland.xml b/protocol/wayland.xml
> index 0ce68ef..58931fb 100644
> --- a/protocol/wayland.xml
> +++ b/protocol/wayland.xml
> @@ -296,7 +296,7 @@
>    </interface>
>
>
> -  <interface name="wl_data_offer" version="1">
> +  <interface name="wl_data_offer" version="2">
>      <description summary="offer to transfer data">
>        A wl_data_offer represents a piece of data offered for transfer
>        by another client (the source client).  It is used by the
> @@ -341,9 +341,26 @@
>
>        <arg name="type" type="string"/>
>      </event>
> +
> +    <!-- Version 2 additions -->
> +
> +    <enum name="dnd_action">
> +      <entry name="ignore" value="0"/>
> +      <entry name="copy" value="1"/>
> +      <entry name="move" value="2"/>
> +      <entry name="link" value="4"/>
> +    </enum>
> +
> +    <request name="finish">
> +      <description summary="notify that the transfer operation is finished">
> +       The client must issue this request when the data transfer operation
> +       has finished. The source wl_data_source will be notified.
> +      </description>
> +      <arg name="action" type="uint"/>
> +    </request>
>    </interface>
>
> -  <interface name="wl_data_source" version="1">
> +  <interface name="wl_data_source" version="2">
>      <description summary="offer to transfer data">
>        The wl_data_source object is the source side of a wl_data_offer.
>        It is created by the source client in a data transfer and
> @@ -392,6 +409,18 @@
>        </description>
>      </event>
>
> +    <!-- Version 2 additions -->
> +
> +    <event name="dropped">
> +      <description summary="the data has been dropped">
> +       This event notifies the source client that the receiver client
> +       has received the data and thaat the transfer operation has finished
> +       succesfully. It passes the dnd action that the receiver has
> +       requested.
> +      </description>
> +      <arg name="action" type="uint"/>
> +    </event>
> +
>    </interface>
>
>    <interface name="wl_data_device" version="1">
> diff --git a/src/data-device.c b/src/data-device.c
> index 4255c13..da3fe95 100644
> --- a/src/data-device.c
> +++ b/src/data-device.c
> @@ -55,6 +55,17 @@ data_offer_receive(struct wl_client *client, struct wl_resource *resource,
>  }
>
>  static void
> +data_offer_finish(struct wl_client *client, struct wl_resource *resource,
> +                       uint32_t action)
> +{
> +    printf("DONE\n");
> +       struct wl_data_offer *offer = resource->data;
> +
> +       if (offer->source)
> +               offer->source->dropped(offer->source, action);
> +}
> +
> +static void
>  data_offer_destroy(struct wl_client *client, struct wl_resource *resource)
>  {
>         wl_resource_destroy(resource);
> @@ -64,6 +75,7 @@ static const struct wl_data_offer_interface data_offer_interface = {
>         data_offer_accept,
>         data_offer_receive,
>         data_offer_destroy,
> +       data_offer_finish,
>  };
>
>  static void
> @@ -427,6 +439,13 @@ destroy_data_source(struct wl_resource *resource)
>  }
>
>  static void
> +client_source_dropped(struct wl_data_source *source,
> +                       uint32_t action)
> +{
> +    wl_data_source_send_dropped(&source->resource, action);
> +}
> +
> +static void
>  client_source_accept(struct wl_data_source *source,
>                      uint32_t time, const char *mime_type)
>  {
> @@ -467,6 +486,7 @@ create_data_source(struct wl_client *client,
>         source->resource.data = source;
>         wl_signal_init(&source->resource.destroy_signal);
>
> +       source->dropped = client_source_dropped;
>         source->accept = client_source_accept;
>         source->send = client_source_send;
>         source->cancel = client_source_cancel;
> diff --git a/src/wayland-server.h b/src/wayland-server.h
> index c7369eb..5c834e2 100644
> --- a/src/wayland-server.h
> +++ b/src/wayland-server.h
> @@ -275,6 +275,8 @@ struct wl_data_source {
>         void (*send)(struct wl_data_source *source,
>                      const char *mime_type, int32_t fd);
>         void (*cancel)(struct wl_data_source *source);
> +       void (*dropped)(struct wl_data_source *source,
> +                                uint32_t action);
>  };
>
>  struct wl_pointer {
> --
> 1.8.1.5
>


More information about the wayland-devel mailing list