Loading...
Searching...
No Matches
wayland::server::data_source_t Class Reference

offer to transfer data More...

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

Inherits wayland::server::resource_t.

## Public Member Functions

std::function< void(std::string)> & | on_offer ()
| add an offered mime type
std::function< void()> & | on_destroy ()
| destroy the data source
std::function< void(data_device_manager_dnd_action)> & | on_set_actions ()
| set the available drag-and-drop actions
void | target (std::string const &mime_type, bool post=true)
| a target accepts an offered mime type
void | send (std::string const &mime_type, int fd, bool post=true)
| send the data
void | cancelled (bool post=true)
| selection was cancelled
void | dnd_drop_performed (bool post=true)
| the drag-and-drop operation physically finished
bool | can_dnd_drop_performed () const
| Check whether the dnd_drop_performed function is available with the currently bound version of the protocol.
void | dnd_finished (bool post=true)
| the drag-and-drop operation concluded
bool | can_dnd_finished () const
| Check whether the dnd_finished 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_action_mask (std::string const &msg)
| Post error: action mask contains invalid values.
void | post_invalid_source (std::string const &msg)
| Post error: source 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 | target_since_version = 1
| Minimum protocol version required for the target function.
static constexpr std::uint32_t | send_since_version = 1
| Minimum protocol version required for the send function.
static constexpr std::uint32_t | cancelled_since_version = 1
| Minimum protocol version required for the cancelled function.
static constexpr std::uint32_t | dnd_drop_performed_since_version = 3
| Minimum protocol version required for the dnd_drop_performed function.
static constexpr std::uint32_t | dnd_finished_since_version = 3
| Minimum protocol version required for the dnd_finished function.
static constexpr std::uint32_t | action_since_version = 3
| Minimum protocol version required for the action 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 1089 of file wayland-server-protocol.hpp.

## Member Function Documentation

## action()

void data_source_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, 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 2020 of file wayland-server-protocol.cpp.

## can_action()

bool data_source_t::can_action | ( |  | ) | const

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

Definition at line 2025 of file wayland-server-protocol.cpp.

## can_dnd_drop_performed()

bool data_source_t::can_dnd_drop_performed | ( |  | ) | const

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

Definition at line 2005 of file wayland-server-protocol.cpp.

## can_dnd_finished()

bool data_source_t::can_dnd_finished | ( |  | ) | const

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

Definition at line 2015 of file wayland-server-protocol.cpp.

## cancelled()

void data_source_t::cancelled | ( | bool | post = `true` | ) |

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

## dnd_drop_performed()

void data_source_t::dnd_drop_performed | ( | bool | post = `true` | ) |

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

## dnd_finished()

void data_source_t::dnd_finished | ( | bool | post = `true` | ) |

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

## get_class()

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.

## get_client()

client_t wayland::server::resource_t::get_client | ( |  | ) | const

inherited

Get the associated client

Returns
  the client that owns the resource.

## get_id()

uint32_t wayland::server::resource_t::get_id | ( |  | ) | const

inherited

Get the internal ID of the resource

Returns
  the internal ID of the resource

## get_version()

unsigned int wayland::server::resource_t::get_version | ( |  | ) | const

inherited

Get interface version

Returns
  Interface version this resource has been constructed with.

## on_destroy()

std::function< void()> & data_source_t::on_destroy | ( |  | ) |

destroy the data source

Destroy the data source.

Definition at line 1973 of file wayland-server-protocol.cpp.

## on_offer()

std::function< void(std::string)> & data_source_t::on_offer | ( |  | ) |

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

## on_set_actions()

std::function< void(data_device_manager_dnd_action)> & data_source_t::on_set_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 1979 of file wayland-server-protocol.cpp.

## post_invalid_action_mask()

void data_source_t::post_invalid_action_mask | ( | std::string const & | msg | ) |

Post error: action mask contains invalid values.

Definition at line 2030 of file wayland-server-protocol.cpp.

## post_invalid_source()

void data_source_t::post_invalid_source | ( | std::string const & | msg | ) |

Post error: source doesn't accept this request.

Definition at line 2035 of file wayland-server-protocol.cpp.

## post_no_memory()

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.

## proxy_has_object()

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

## send()

void data_source_t::send | ( | std::string const & | mime_type,
|  | int | fd,
|  | bool | post = `true`
| ) |  |

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

## target()

void data_source_t::target | ( | std::string const & | mime_type,
|  | bool | post = `true`
| ) |  |

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

## Member Data Documentation

## action_since_version

constexpr std::uint32_t wayland::server::data_source_t::action_since_version = 3

static constexpr

Minimum protocol version required for the action function.

Definition at line 1293 of file wayland-server-protocol.hpp.

## cancelled_since_version

constexpr std::uint32_t wayland::server::data_source_t::cancelled_since_version = 1

static constexpr

Minimum protocol version required for the cancelled function.

Definition at line 1212 of file wayland-server-protocol.hpp.

## dnd_drop_performed_since_version

constexpr std::uint32_t wayland::server::data_source_t::dnd_drop_performed_since_version = 3

static constexpr

Minimum protocol version required for the dnd_drop_performed function.

Definition at line 1231 of file wayland-server-protocol.hpp.

## dnd_finished_since_version

constexpr std::uint32_t wayland::server::data_source_t::dnd_finished_since_version = 3

static constexpr

Minimum protocol version required for the dnd_finished function.

Definition at line 1252 of file wayland-server-protocol.hpp.

## send_since_version

constexpr std::uint32_t wayland::server::data_source_t::send_since_version = 1

static constexpr

Minimum protocol version required for the send function.

Definition at line 1182 of file wayland-server-protocol.hpp.

## target_since_version

constexpr std::uint32_t wayland::server::data_source_t::target_since_version = 1

static constexpr

Minimum protocol version required for the target function.

Definition at line 1167 of file wayland-server-protocol.hpp.

The documentation for this class was generated from the following files:

- obj-x86_64-linux-gnu/wayland-server-protocol.hpp
- obj-x86_64-linux-gnu/wayland-server-protocol.cpp