---
name: "wayland_data_offer_t"
section: "3"
platform: "linux"
package: "waylandpp-dev"
version: "1.0.0-6+b2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/wayland_data_offer_t"
---

# wayland\_data\_offer\_t(3)

offer to transfer data

## NAME

wayland::data\_offer\_t - offer to transfer data

## SYNOPSIS

`#include <wayland-client-protocol.hpp>`

Inherits **wayland::proxy\_t**.

### Public Types

enum class **wrapper\_type** { **standard**, **display**, **foreign**, **proxy\_wrapper** }\

### Public Member Functions

void **accept** (uint32\_t serial, std::string const &mime\_type)\
 accept one of the offered mime types  void **receive** (std::string const &mime\_type, int fd)\
 request that the data is transferred  void **finish** ()\
 the offer will no longer be used  bool **can\_finish** () const\
 Check whether the **finish** function is available with the currently bound version of the protocol.  void **set\_actions** (**data\_device\_manager\_dnd\_action** const &dnd\_actions, **data\_device\_manager\_dnd\_action** const &preferred\_action)\
 set the available/preferred drag-and-drop actions  bool **can\_set\_actions** () const\
 Check whether the **set\_actions** function is available with the currently bound version of the protocol.  std::function\< void(std::string)\> & **on\_offer** ()\
 advertise offered mime type  std::function\< void(**data\_device\_manager\_dnd\_action**)\> & **on\_source\_actions** ()\
 notify the source-side available actions  std::function\< void(**data\_device\_manager\_dnd\_action**)\> & **on\_action** ()\
 notify the selected action  uint32\_t **get\_id** () const\
 Get the id of a proxy object.  std::string **get\_class** () const\
 Get the interface name (class) of a proxy object.  uint32\_t **get\_version** () const\
 Get the protocol object version of a proxy object.  **wrapper\_type** **get\_wrapper\_type** () const\
 Get the type of a proxy object.  void **set\_queue** (**event\_queue\_t** queue)\
 Assign a proxy to an event queue.  wl\_proxy \* **c\_ptr** () const\
 Get a pointer to the underlying C struct.  bool **proxy\_has\_object** () const\
 Check whether this wrapper actually wraps an object.  **operator bool** () const\
 Check whether this wrapper actually wraps an object.  bool **operator==** (const **proxy\_t** &right) const\
 Check whether two wrappers refer to the same object.  bool **operator!=** (const **proxy\_t** &right) const\
 Check whether two wrappers refer to different objects.  void **proxy\_release** ()\
 Release the wrapped object (if any), making this an empty wrapper.

### Static Public Attributes

static constexpr std::uint32\_t **accept\_since\_version** = 1\
 Minimum protocol version required for the **accept** function.  static constexpr std::uint32\_t **receive\_since\_version** = 1\
 Minimum protocol version required for the **receive** function.  static constexpr std::uint32\_t **finish\_since\_version** = 3\
 Minimum protocol version required for the **finish** function.  static constexpr std::uint32\_t **set\_actions\_since\_version** = 3\
 Minimum protocol version required for the **set\_actions** function.

## Detailed Description

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 copy-and-paste and drag-and-drop mechanisms. The offer describes the different mime types that the data can be converted to and provides the mechanism for transferring the data directly from the source client.

Definition at line **759** of file **wayland-client-protocol.hpp**.

## Member Enumeration Documentation

### enum class wayland::proxy\_t::wrapper\_type` [strong]`, ` [inherited]`

Underlying wl\_proxy type and properties of a **proxy\_t** that affect construction, destruction, and event handling

**Enumerator**

- *standard*

  *C pointer is a standard type compatible with wl\_proxy\*. Events are dispatched and it is destructed when the* **proxy\_t** *is destructed. User data is set.*

- *display*

  *C pointer is a wl\_display\*. No events are dispatched, wl\_display\_disconnect is called when the* **proxy\_t** *is destructed. User data is set.*

- *foreign*

  *C pointer is a standard type compatible with wl\_proxy\*, but another library owns it and it should not be touched in a way that could affect the operation of the other library. No events are dispatched, wl\_proxy\_destroy is not called when the* **proxy\_t** *is destructed, user data is not touched. Consequently, there is no reference counting for the* **proxy\_t***. Lifetime of such wrappers should preferably be short to minimize the chance that the owning library decides to destroy the wl\_proxy.*

- *proxy\_wrapper*

  *C pointer is a wl\_proxy\* that was constructed with wl\_proxy\_create\_wrapper. No events are dispatched, wl\_proxy\_wrapper\_destroy is called when the* **proxy\_t** *is destroyed. Reference counting is active. A reference to the* **proxy\_t** *creating this proxy wrapper is held to extend its lifetime until after the proxy wrapper is destroyed.*

*Definition at line* **116** *of file* **wayland-client.hpp***.*

## Member Function Documentation

### void data\_offer\_t::accept (uint32\_t serial, std::string const & mime\_type)

*accept one of the offered mime types*

**Parameters**

*serial serial number of the accept request* \
 *mime\_type mime type accepted by the client*

*Indicate that the client can accept the given mime type, or NULL for not accepted.*

*For objects of version 2 or older, this request is used by the client to give feedback whether the client can receive the given mime type, or NULL if none is accepted; the feedback does not determine whether the drag-and-drop operation succeeds or not.*

*For objects of version 3 or newer, this request determines the final result of the drag-and-drop operation. If the end result is that no mime types were accepted, the drag-and-drop operation will be cancelled and the corresponding drag source will receive wl\_data\_source.cancelled. Clients may still use this event in conjunction with wl\_data\_source.action for feedback.*

*Definition at line* **2028** *of file* **wayland-client-protocol.cpp***.*

### wl\_proxy \* wayland::proxy\_t::c\_ptr () const` [inherited]`

*Get a pointer to the underlying C struct.*

**Returns**

*The underlying wl\_proxy wrapped by this* **proxy\_t** *if it exists, otherwise an exception is thrown*

### bool data\_offer\_t::can\_finish () const

*Check whether the* **finish** *function is available with the currently bound version of the protocol.*

*Definition at line* **2045** *of file* **wayland-client-protocol.cpp***.*

### bool data\_offer\_t::can\_set\_actions () const

*Check whether the* **set\_actions** *function is available with the currently bound version of the protocol.*

*Definition at line* **2056** *of file* **wayland-client-protocol.cpp***.*

### void data\_offer\_t::finish ()

*the offer will no longer be used Notifies the compositor that the drag destination successfully finished the drag-and-drop operation.*

*Upon receiving this request, the compositor will emit wl\_data\_source.dnd\_finished on the drag source client.*

*It is a client error to perform other requests than wl\_data\_offer.destroy after this one. It is also an error to perform this request after a NULL mime type has been set in wl\_data\_offer.accept or no action was received through wl\_data\_offer.action.*

*If wl\_data\_offer.finish request is received for a non drag and drop operation, the invalid\_finish protocol error is raised.*

*Definition at line* **2040** *of file* **wayland-client-protocol.cpp***.*

### std::string wayland::proxy\_t::get\_class () const` [inherited]`

*Get the interface name (class) of a proxy object.*

**Returns**

*The interface name of the object associated with the proxy*

### uint32\_t wayland::proxy\_t::get\_id () const` [inherited]`

*Get the id of a proxy object.*

**Returns**

*The id the object associated with the proxy*

### uint32\_t wayland::proxy\_t::get\_version () const` [inherited]`

*Get the protocol object version of a proxy object. Gets the protocol object version of a proxy object, or 0 if the proxy was created with unversioned API.*

*A returned value of 0 means that no version information is available, so the caller must make safe assumptions about the object's real version.*

**display\_t** *will always return version 0.*

**Returns**

*The protocol object version of the proxy or 0*

### wrapper\_type wayland::proxy\_t::get\_wrapper\_type () const` [inline]`, ` [inherited]`

*Get the type of a proxy object.*

*Definition at line* **302** *of file* **wayland-client.hpp***.*

### std::function\< void(data\_device\_manager\_dnd\_action)\> & data\_offer\_t::on\_action ()

*notify the selected action*

**Parameters**

*dnd\_action action selected by the compositor*

*This event indicates the action selected by the compositor after matching the source/destination side actions. Only one action (or none) will be offered here.*

*This event can be emitted multiple times during the drag-and-drop operation in response to destination side action changes through wl\_data\_offer.set\_actions.*

*This event will no longer be emitted after wl\_data\_device.drop happened on the drag-and-drop destination, the client must honor the last action received, or the last preferred one set through wl\_data\_offer.set\_actions when handling an 'ask' action.*

*Compositors may also change the selected action on the fly, mainly in response to keyboard modifier changes during the drag-and-drop operation.*

*The most recent action received is always the valid one. Prior to receiving wl\_data\_device.drop, the chosen action may change (e.g. due to keyboard modifiers being pressed). At the time of receiving wl\_data\_device.drop the drag-and-drop destination must honor the last action received.*

*Action changes may still happen after wl\_data\_device.drop, especially on 'ask' actions, where the drag-and-drop destination may choose another action afterwards. Action changes happening at this stage are always the result of inter-client negotiation, the compositor shall no longer be able to induce a different action.*

*Upon 'ask' actions, it is expected that the drag-and-drop destination may potentially choose a different action and/or mime type, based on wl\_data\_offer.source\_actions and finally chosen by the user (e.g. popping up a menu with the available options). The final wl\_data\_offer.set\_actions and wl\_data\_offer.accept requests must happen before the call to wl\_data\_offer.finish.*

*Definition at line* **2072** *of file* **wayland-client-protocol.cpp***.*

### std::function\< void(std::string)\> & data\_offer\_t::on\_offer ()

*advertise offered mime type*

**Parameters**

*mime\_type offered mime type*

*Sent immediately after creating the wl\_data\_offer object. One event per offered mime type.*

*Definition at line* **2062** *of file* **wayland-client-protocol.cpp***.*

### std::function\< void(data\_device\_manager\_dnd\_action)\> & data\_offer\_t::on\_source\_actions ()

*notify the source-side available actions*

**Parameters**

*source\_actions actions offered by the data source*

*This event indicates the actions offered by the data source. It will be sent right after wl\_data\_device.enter, or anytime the source side changes its offered actions through wl\_data\_source.set\_actions.*

*Definition at line* **2067** *of file* **wayland-client-protocol.cpp***.*

### wayland::proxy\_t::operator bool () const` [inherited]`

*Check whether this wrapper actually wraps an object.*

**Returns**

*true if there is an underlying object, false if this wrapper is empty*

### bool wayland::proxy\_t::operator!= (const proxy\_t & right) const` [inherited]`

*Check whether two wrappers refer to different objects.*

### bool wayland::proxy\_t::operator== (const proxy\_t & right) const` [inherited]`

*Check whether two wrappers refer to the same object.*

### bool wayland::proxy\_t::proxy\_has\_object () const` [inherited]`

*Check whether this wrapper actually wraps an object.*

**Returns**

*true if there is an underlying object, false if this wrapper is empty*

### void wayland::proxy\_t::proxy\_release ()` [inherited]`

*Release the wrapped object (if any), making this an empty wrapper. Note that* **display\_t** *instances cannot be released this way. Attempts to do so are ignored.*

**Examples** **foreign\_display.cpp***.*

### void data\_offer\_t::receive (std::string const & mime\_type, int fd)

*request that the data is transferred*

**Parameters**

*mime\_type mime type desired by receiver* \
 *fd file descriptor for data transfer*

*To transfer the offered data, the client issues this request and indicates the mime type it wants to receive. The transfer happens through the passed file descriptor (typically created with the pipe system call). The source client writes the data in the mime type representation requested and then closes the file descriptor.*

*The receiving client reads from the read end of the pipe until EOF and then closes its end, at which point the transfer is complete.*

*This request may happen multiple times for different mime types, both before and after wl\_data\_device.drop. Drag-and-drop destination clients may preemptively fetch data or examine it more closely to determine acceptance.*

*Definition at line* **2034** *of file* **wayland-client-protocol.cpp***.*

### void data\_offer\_t::set\_actions (data\_device\_manager\_dnd\_action const & dnd\_actions, data\_device\_manager\_dnd\_action const & preferred\_action)

*set the available/preferred drag-and-drop actions*

**Parameters**

*dnd\_actions actions supported by the destination client* \
 *preferred\_action action preferred by the destination client*

*Sets the actions that the destination side client supports for this operation. This request may trigger the emission of wl\_data\_source.action and wl\_data\_offer.action events if the compositor needs to change the selected action.*

*This request can be called multiple times throughout the drag-and-drop operation, typically in response to wl\_data\_device.enter or wl\_data\_device.motion events.*

*This request determines the final result of the drag-and-drop operation. If the end result is that no action is accepted, the drag source will receive wl\_data\_source.cancelled.*

*The dnd\_actions argument must contain only values expressed in the wl\_data\_device\_manager.dnd\_actions enum, and the preferred\_action argument must only contain one of those values set, otherwise it will result in a protocol error.*

*While managing an 'ask' action, the destination drag-and-drop client may perform further wl\_data\_offer.receive requests, and is expected to perform one last wl\_data\_offer.set\_actions request with a preferred action other than 'ask' (and optionally wl\_data\_offer.accept) before requesting wl\_data\_offer.finish, in order to convey the action selected by the user. If the preferred action is not in the wl\_data\_offer.source\_actions mask, an error will be raised.*

*If the 'ask' action is dismissed (e.g. user cancellation), the client is expected to perform wl\_data\_offer.destroy right away.*

*This request can only be made on drag-and-drop offers, a protocol error will be raised otherwise.*

*Definition at line* **2051** *of file* **wayland-client-protocol.cpp***.*

### void wayland::proxy\_t::set\_queue (event\_queue\_t queue)` [inherited]`

*Assign a proxy to an event queue.*

**Parameters**

*queue The event queue that will handle this proxy*

*Assign proxy to event queue. Events coming from proxy will be queued in queue instead of the display's main queue.*

*See also:* **display\_t::dispatch\_queue()***.*

**Examples** **proxy\_wrapper.cpp***.*

## Member Data Documentation

### constexpr std::uint32\_t wayland::data\_offer\_t::accept\_since\_version = 1` [static]`, ` [constexpr]`

*Minimum protocol version required for the* **accept** *function.*

*Definition at line* **808** *of file* **wayland-client-protocol.hpp***.*

### constexpr std::uint32\_t wayland::data\_offer\_t::finish\_since\_version = 3` [static]`, ` [constexpr]`

*Minimum protocol version required for the* **finish** *function.*

*Definition at line* **859** *of file* **wayland-client-protocol.hpp***.*

### constexpr std::uint32\_t wayland::data\_offer\_t::receive\_since\_version = 1` [static]`, ` [constexpr]`

*Minimum protocol version required for the* **receive** *function.*

*Definition at line* **835** *of file* **wayland-client-protocol.hpp***.*

### constexpr std::uint32\_t wayland::data\_offer\_t::set\_actions\_since\_version = 3` [static]`, ` [constexpr]`

*Minimum protocol version required for the* **set\_actions** *function.*

*Definition at line* **907** *of file* **wayland-client-protocol.hpp***.*

## Author

*Generated automatically by Doxygen for Wayland++ from the source code.*
