---
name: "wayland_server_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_server_data_offer_t"
---

# wayland\_server\_data\_offer\_t(3)

offer to transfer data

## NAME

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

## SYNOPSIS

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

Inherits wayland::server::resource\_t.

### Public Member Functions

std::function\< void(uint32\_t, std::string)\> & **on\_accept** ()\
 accept one of the offered mime types  std::function\< void(std::string, int)\> & **on\_receive** ()\
 request that the data is transferred  std::function\< void()\> & **on\_destroy** ()\
 destroy data offer  std::function\< void()\> & **on\_finish** ()\
 the offer will no longer be used  std::function\< void(**data\_device\_manager\_dnd\_action**, **data\_device\_manager\_dnd\_action**)\> & **on\_set\_actions** ()\
 set the available/preferred drag-and-drop actions  void **offer** (std::string const &mime\_type, bool post=true)\
 advertise offered mime type  void **source\_actions** (**data\_device\_manager\_dnd\_action** const &source\_actions, bool post=true)\
 notify the source-side available actions  bool **can\_source\_actions** () const\
 Check whether the **source\_actions** function is available with the currently bound version of the protocol.  void **action** (**data\_device\_manager\_dnd\_action** const &dnd\_action, bool post=true)\
 notify the selected action  bool **can\_action** () const\
 Check whether the **action** function is available with the currently bound version of the protocol.  void **post\_invalid\_finish** (std::string const &msg)\
 Post error: finish request was called untimely.  void **post\_invalid\_action\_mask** (std::string const &msg)\
 Post error: action mask contains invalid values.  void **post\_invalid\_action** (std::string const &msg)\
 Post error: action argument has an invalid value.  void **post\_invalid\_offer** (std::string const &msg)\
 Post error: offer doesn't accept this request.  bool **proxy\_has\_object** () const\
 Check whether this wrapper actually wraps an object.  void **post\_no\_memory** () const\
 uint32\_t **get\_id** () const\
 client\_t **get\_client** () const\
 unsigned int **get\_version** () const\
 std::string **get\_class** ()\

### 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 **source\_actions\_since\_version** = 3\
 Minimum protocol version required for the **source\_actions** function.  static constexpr std::uint32\_t **action\_since\_version** = 3\
 Minimum protocol version required for the **action** 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 **821** of file **wayland-server-protocol.hpp**.

## Member Function Documentation

### void data\_offer\_t::action (data\_device\_manager\_dnd\_action const & dnd\_action, bool post = `true`)

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 **1893** of file **wayland-server-protocol.cpp**.

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

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

Definition at line **1898** of file **wayland-server-protocol.cpp**.

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

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

Definition at line **1888** of file **wayland-server-protocol.cpp**.

### std::string wayland::server::resource\_t::get\_class ()` [inherited]`

Retrieve the interface name (class) of a resource object.

**Returns**

Interface name of the resource object.

### client\_t wayland::server::resource\_t::get\_client () const` [inherited]`

Get the associated client

**Returns**

the client that owns the resource.

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

Get the internal ID of the resource

**Returns**

the internal ID of the resource

### unsigned int wayland::server::resource\_t::get\_version () const` [inherited]`

Get interface version

**Returns**

Interface version this resource has been constructed with.

### void data\_offer\_t::offer (std::string const & mime\_type, bool post = `true`)

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 **1878** of file **wayland-server-protocol.cpp**.

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

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 **1848** of file **wayland-server-protocol.cpp**.

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

destroy data offer Destroy the data offer.

Definition at line **1860** of file **wayland-server-protocol.cpp**.

### std::function\< void()\> & data\_offer\_t::on\_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 **1866** of file **wayland-server-protocol.cpp**.

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

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 **1854** of file **wayland-server-protocol.cpp**.

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

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 **1872** of file **wayland-server-protocol.cpp**.

### void data\_offer\_t::post\_invalid\_action (std::string const & msg)

Post error: action argument has an invalid value.

Definition at line **1913** of file **wayland-server-protocol.cpp**.

### void data\_offer\_t::post\_invalid\_action\_mask (std::string const & msg)

Post error: action mask contains invalid values.

Definition at line **1908** of file **wayland-server-protocol.cpp**.

### void data\_offer\_t::post\_invalid\_finish (std::string const & msg)

Post error: finish request was called untimely.

Definition at line **1903** of file **wayland-server-protocol.cpp**.

### void data\_offer\_t::post\_invalid\_offer (std::string const & msg)

Post error: offer doesn't accept this request.

Definition at line **1918** of file **wayland-server-protocol.cpp**.

### void wayland::server::resource\_t::post\_no\_memory () const` [inherited]`

Post 'not enough memory' error to the client

If the compositor has not enough memory to fulfill a certail request of the client, this function can be called to notify the client of this circumstance.

### bool wayland::server::resource\_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 data\_offer\_t::source\_actions (data\_device\_manager\_dnd\_action const & source\_actions, bool post = `true`)

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 **1883** of file **wayland-server-protocol.cpp**.

## Member Data Documentation

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

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

Definition at line **1038** of file **wayland-server-protocol.hpp**.

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

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

Definition at line **973** of file **wayland-server-protocol.hpp**.

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

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

Definition at line **987** of file **wayland-server-protocol.hpp**.

## Author

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