---
name: "wayland_data_device_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_device_t"
---

# wayland\_data\_device\_t(3)

data transfer device

## NAME

wayland::data\_device\_t - data transfer device

## 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 **start\_drag** (**data\_source\_t** const &source, **surface\_t** const &origin, **surface\_t** const &icon, uint32\_t serial)\
 start drag-and-drop operation  void **set\_selection** (**data\_source\_t** const &source, uint32\_t serial)\
 copy data to the selection  void **release** ()\
 destroy data device  bool **can\_release** () const\
 Check whether the **release** function is available with the currently bound version of the protocol.  std::function\< void(**data\_offer\_t**)\> & **on\_data\_offer** ()\
 introduce a new wl\_data\_offer  std::function\< void(uint32\_t, **surface\_t**, double, double, **data\_offer\_t**)\> & **on\_enter** ()\
 initiate drag-and-drop session  std::function\< void()\> & **on\_leave** ()\
 end drag-and-drop session  std::function\< void(uint32\_t, double, double)\> & **on\_motion** ()\
 drag-and-drop session motion  std::function\< void()\> & **on\_drop** ()\
 end drag-and-drop session successfully  std::function\< void(**data\_offer\_t**)\> & **on\_selection** ()\
 advertise new selection  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 **start\_drag\_since\_version** = 1\
 Minimum protocol version required for the **start\_drag** function.  static constexpr std::uint32\_t **set\_selection\_since\_version** = 1\
 Minimum protocol version required for the **set\_selection** function.  static constexpr std::uint32\_t **release\_since\_version** = 2\
 Minimum protocol version required for the **release** function.

## Detailed Description

data transfer device

There is one wl\_data\_device per seat which can be obtained from the global wl\_data\_device\_manager singleton.

A wl\_data\_device provides access to inter-client data transfer mechanisms such as copy-and-paste and drag-and-drop.

Definition at line **1202** 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\_device\_t::can\_release () const

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

*Definition at line* **2288** *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\_offer\_t)\> & data\_device\_t::on\_data\_offer ()

*introduce a new wl\_data\_offer*

**Parameters**

*id the new data\_offer object*

*The data\_offer event introduces a new wl\_data\_offer object, which will subsequently be used in either the data\_device.enter event (for drag-and-drop) or the data\_device.selection event (for selections). Immediately following the data\_device.data\_offer event, the new data\_offer object will send out data\_offer.offer events to describe the mime types it offers.*

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

### std::function\< void()\> & data\_device\_t::on\_drop ()

*end drag-and-drop session successfully The event is sent when a drag-and-drop operation is ended because the implicit grab is removed.*

*The drag-and-drop destination is expected to honor the last action received through wl\_data\_offer.action, if the resulting action is 'copy' or 'move', the destination can still perform wl\_data\_offer.receive requests, and is expected to end all transfers with a wl\_data\_offer.finish request.*

*If the resulting action is 'ask', the action will not be considered final. The drag-and-drop destination is expected to perform one last wl\_data\_offer.set\_actions request, or wl\_data\_offer.destroy in order to cancel the operation.*

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

### std::function\< void(uint32\_t, surface\_t, double, double, data\_offer\_t)\> & data\_device\_t::on\_enter ()

*initiate drag-and-drop session*

**Parameters**

*serial serial number of the enter event* \
 *surface client surface entered* \
 *x surface-local x coordinate* \
 *y surface-local y coordinate* \
 *id source data\_offer object*

*This event is sent when an active drag-and-drop pointer enters a surface owned by the client. The position of the pointer at enter time is provided by the x and y arguments, in surface-local coordinates.*

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

### std::function\< void()\> & data\_device\_t::on\_leave ()

*end drag-and-drop session This event is sent when the drag-and-drop pointer leaves the surface and the session ends. The client must destroy the wl\_data\_offer introduced at enter time at this point.*

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

### std::function\< void(uint32\_t, double, double)\> & data\_device\_t::on\_motion ()

*drag-and-drop session motion*

**Parameters**

*time timestamp with millisecond granularity* \
 *x surface-local x coordinate* \
 *y surface-local y coordinate*

*This event is sent when the drag-and-drop pointer moves within the currently focused surface. The new position of the pointer is provided by the x and y arguments, in surface-local coordinates.*

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

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

*advertise new selection*

**Parameters**

*id selection data\_offer object*

*The selection event is sent out to notify the client of a new wl\_data\_offer for the selection for this device. The data\_device.data\_offer and the data\_offer.offer events are sent out immediately before this event to introduce the data offer object. The selection event is sent to a client immediately before receiving keyboard focus and when a new selection is set while the client has keyboard focus. The data\_offer is valid until a new data\_offer or NULL is received or until the client loses keyboard focus. Switching surface with keyboard focus within the same client doesn't mean a new selection will be sent. The client must destroy the previous selection data\_offer, if any, upon receiving this event.*

*Definition at line* **2319** *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\_device\_t::release ()

*destroy data device This request destroys the data device.*

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

### void data\_device\_t::set\_selection (data\_source\_t const & source, uint32\_t serial)

*copy data to the selection*

**Parameters**

*source data source for the selection* \
 *serial serial number of the event that triggered this request*

*This request asks the compositor to set the selection to the data from the source on behalf of the client.*

*To unset the selection, set the source to NULL.*

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

### void data\_device\_t::start\_drag (data\_source\_t const & source, surface\_t const & origin, surface\_t const & icon, uint32\_t serial)

*start drag-and-drop operation*

**Parameters**

*source data source for the eventual transfer* \
 *origin surface where the drag originates* \
 *icon drag-and-drop icon surface* \
 *serial serial number of the implicit grab on the origin*

*This request asks the compositor to start a drag-and-drop operation on behalf of the client.*

*The source argument is the data source that provides the data for the eventual data transfer. If source is NULL, enter, leave and motion events are sent only to the client that initiated the drag and the client is expected to handle the data passing internally. If source is destroyed, the drag-and-drop session will be cancelled.*

*The origin surface is the surface where the drag originates and the client must have an active implicit grab that matches the serial.*

*The icon surface is an optional (can be NULL) surface that provides an icon to be moved around with the cursor. Initially, the top-left corner of the icon surface is placed at the cursor hotspot, but subsequent wl\_surface.attach request can move the relative position. Attach requests must be confirmed with wl\_surface.commit as usual. The icon surface is given the role of a drag-and-drop icon. If the icon surface already has another role, it raises a protocol error.*

*The current and pending input regions of the icon wl\_surface are cleared, and wl\_surface.set\_input\_region is ignored until the wl\_surface is no longer used as the icon surface. When the use as an icon ends, the current and pending input regions become undefined, and the wl\_surface is unmapped.*

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

## Member Data Documentation

### constexpr std::uint32\_t wayland::data\_device\_t::release\_since\_version = 2` [static]`, ` [constexpr]`

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

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

### constexpr std::uint32\_t wayland::data\_device\_t::set\_selection\_since\_version = 1` [static]`, ` [constexpr]`

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

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

### constexpr std::uint32\_t wayland::data\_device\_t::start\_drag\_since\_version = 1` [static]`, ` [constexpr]`

*Minimum protocol version required for the* **start\_drag** *function.*

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

## Author

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