---
name: "wayland_data_source_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_source_t"
---

# wayland\_data\_source\_t(3)

offer to transfer data

## NAME

wayland::data\_source\_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 **offer** (std::string const &mime\_type)\
 add an offered mime type  void **set\_actions** (**data\_device\_manager\_dnd\_action** const &dnd\_actions)\
 set the available 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\_target** ()\
 a target accepts an offered mime type  std::function\< void(std::string, int)\> & **on\_send** ()\
 send the data  std::function\< void()\> & **on\_cancelled** ()\
 selection was cancelled  std::function\< void()\> & **on\_dnd\_drop\_performed** ()\
 the drag-and-drop operation physically finished  std::function\< void()\> & **on\_dnd\_finished** ()\
 the drag-and-drop operation concluded  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 **offer\_since\_version** = 1\
 Minimum protocol version required for the **offer** 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

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 provides a way to describe the offered data and a way to respond to requests to transfer the data.

Definition at line **1001** 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

### 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\_source\_t::can\_set\_actions () const

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

*Definition at line* **2158** *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***.*

### void data\_source\_t::offer (std::string const & mime\_type)

*add an offered mime type*

**Parameters**

*mime\_type mime type offered by the data source*

*This request adds a mime type to the set of mime types advertised to targets. Can be called several times to offer multiple types.*

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

### std::function\< void(data\_device\_manager\_dnd\_action)\> & data\_source\_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, mainly in response to destination side changes through wl\_data\_offer.set\_actions, and as the data device enters/leaves surfaces.*

*It is only possible to receive this event after wl\_data\_source.dnd\_drop\_performed if the drag-and-drop operation ended in an 'ask' action, in which case the final wl\_data\_source.action event will happen immediately before wl\_data\_source.dnd\_finished.*

*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. The chosen action may change alongside negotiation (e.g. an 'ask' action can turn into a 'move' operation), so the effects of the final action must always be applied in wl\_data\_offer.dnd\_finished.*

*Clients can trigger cursor surface changes from this point, so they reflect the current action.*

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

### std::function\< void()\> & data\_source\_t::on\_cancelled ()

*selection was cancelled This data source is no longer valid. There are several reasons why this could happen:*

- •

  *The data source has been replaced by another data source.*

- •

  *The drag-and-drop operation was performed, but the drop destination did not accept any of the mime types offered through wl\_data\_source.target.*

- •

  *The drag-and-drop operation was performed, but the drop destination did not select any of the actions present in the mask offered through wl\_data\_source.action.*

- •

  *The drag-and-drop operation was performed but didn't happen over a surface.*

- •

  *The compositor cancelled the drag-and-drop operation (e.g. compositor dependent timeouts to avoid stale drag-and-drop transfers).*

*The client should clean up and destroy this data source.*

*For objects of version 2 or older, wl\_data\_source.cancelled will only be emitted if the data source was replaced by another data source.*

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

### std::function\< void()\> & data\_source\_t::on\_dnd\_drop\_performed ()

*the drag-and-drop operation physically finished The user performed the drop action. This event does not indicate acceptance, wl\_data\_source.cancelled may still be emitted afterwards if the drop destination does not accept any mime type.*

*However, this event might however not be received if the compositor cancelled the drag-and-drop operation before this event could happen.*

*Note that the data\_source may still be used in the future and should not be destroyed here.*

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

### std::function\< void()\> & data\_source\_t::on\_dnd\_finished ()

*the drag-and-drop operation concluded The drop destination finished interoperating with this data source, so the client is now free to destroy this data source and free all associated data.*

*If the action used to perform the operation was 'move', the source can now delete the transferred data.*

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

### std::function\< void(std::string, int)\> & data\_source\_t::on\_send ()

*send the data*

**Parameters**

*mime\_type mime type for the data* \
 *fd file descriptor for the data*

*Request for data from the client. Send the data as the specified mime type over the passed file descriptor, then close it.*

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

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

*a target accepts an offered mime type*

**Parameters**

*mime\_type mime type accepted by the target*

*Sent when a target accepts pointer\_focus or motion events. If a target does not accept any of the offered types, type is NULL.*

*Used for feedback during drag-and-drop.*

*Definition at line* **2164** *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\_source\_t::set\_actions (data\_device\_manager\_dnd\_action const & dnd\_actions)

*set the available drag-and-drop actions*

**Parameters**

*dnd\_actions actions supported by the data source*

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

*The dnd\_actions argument must contain only values expressed in the wl\_data\_device\_manager.dnd\_actions enum, otherwise it will result in a protocol error.*

*This request must be made once only, and can only be made on sources used in drag-and-drop, so it must be performed before wl\_data\_device.start\_drag. Attempting to use the source other than for drag-and-drop will raise a protocol error.*

*Definition at line* **2153** *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\_source\_t::offer\_since\_version = 1` [static]`, ` [constexpr]`

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

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

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

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

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

## Author

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