The wl_data_offer interface

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. More...

## Data Structures

struct | wl_data_offer_listener

## Macros

#define | WL_DATA_OFFER_OFFER_SINCE_VERSION 1
#define | WL_DATA_OFFER_SOURCE_ACTIONS_SINCE_VERSION 3
#define | WL_DATA_OFFER_ACTION_SINCE_VERSION 3
#define | WL_DATA_OFFER_ACCEPT_SINCE_VERSION 1
#define | WL_DATA_OFFER_RECEIVE_SINCE_VERSION 1
#define | WL_DATA_OFFER_DESTROY_SINCE_VERSION 1
#define | WL_DATA_OFFER_FINISH_SINCE_VERSION 3
#define | WL_DATA_OFFER_SET_ACTIONS_SINCE_VERSION 3

## Functions

static int | wl_data_offer_add_listener (struct wl_data_offer *wl_data_offer, const struct wl_data_offer_listener *listener, void *data)
static void | wl_data_offer_set_user_data (struct wl_data_offer *wl_data_offer, void *user_data)
static void * | wl_data_offer_get_user_data (struct wl_data_offer *wl_data_offer)
static void | wl_data_offer_accept (struct wl_data_offer *wl_data_offer, uint32_t serial, const char *mime_type)
static void | wl_data_offer_receive (struct wl_data_offer *wl_data_offer, const char *mime_type, int32_t fd)
static void | wl_data_offer_destroy (struct wl_data_offer *wl_data_offer)
static void | wl_data_offer_finish (struct wl_data_offer *wl_data_offer)
static void | wl_data_offer_set_actions (struct wl_data_offer *wl_data_offer, uint32_t dnd_actions, uint32_t preferred_action)

## Detailed Description

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.

## Macro Definition Documentation

## WL_DATA_OFFER_ACCEPT_SINCE_VERSION

#define WL_DATA_OFFER_ACCEPT_SINCE_VERSION 1

Definition at line 1893 of file wayland-client-protocol.h.

## WL_DATA_OFFER_ACTION_SINCE_VERSION

#define WL_DATA_OFFER_ACTION_SINCE_VERSION 3

Definition at line 1888 of file wayland-client-protocol.h.

## WL_DATA_OFFER_DESTROY_SINCE_VERSION

#define WL_DATA_OFFER_DESTROY_SINCE_VERSION 1

Definition at line 1901 of file wayland-client-protocol.h.

## WL_DATA_OFFER_FINISH_SINCE_VERSION

#define WL_DATA_OFFER_FINISH_SINCE_VERSION 3

Definition at line 1905 of file wayland-client-protocol.h.

## WL_DATA_OFFER_OFFER_SINCE_VERSION

#define WL_DATA_OFFER_OFFER_SINCE_VERSION 1

Definition at line 1880 of file wayland-client-protocol.h.

## WL_DATA_OFFER_RECEIVE_SINCE_VERSION

#define WL_DATA_OFFER_RECEIVE_SINCE_VERSION 1

Definition at line 1897 of file wayland-client-protocol.h.

## WL_DATA_OFFER_SET_ACTIONS_SINCE_VERSION

#define WL_DATA_OFFER_SET_ACTIONS_SINCE_VERSION 3

Definition at line 1909 of file wayland-client-protocol.h.

## WL_DATA_OFFER_SOURCE_ACTIONS_SINCE_VERSION

#define WL_DATA_OFFER_SOURCE_ACTIONS_SINCE_VERSION 3

Definition at line 1884 of file wayland-client-protocol.h.

## Function Documentation

## wl_data_offer_accept()

static void wl_data_offer_accept | ( | struct wl_data_offer * | wl_data_offer,
|  | uint32_t | serial,
|  | const char * | mime_type
| ) |  |

inline static

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 1950 of file wayland-client-protocol.h.

{
wl_proxy_marshal((struct wl_proxy *) wl_data_offer,
WL_DATA_OFFER_ACCEPT, serial, mime_type);
}

References WL_DATA_OFFER_ACCEPT.

## wl_data_offer_add_listener()

static int wl_data_offer_add_listener | ( | struct wl_data_offer * | wl_data_offer,
|  | const struct wl_data_offer_listener * | listener,
|  | void * | data
| ) |  |

inline static

Definition at line 1864 of file wayland-client-protocol.h.

{
return wl_proxy_add_listener((struct wl_proxy *) wl_data_offer,
(void (**)(void)) listener, data);
}

## wl_data_offer_destroy()

static void wl_data_offer_destroy | ( | struct wl_data_offer * | wl_data_offer | ) |

inline static

Destroy the data offer.

Definition at line 1988 of file wayland-client-protocol.h.

{
wl_proxy_marshal((struct wl_proxy *) wl_data_offer,
WL_DATA_OFFER_DESTROY);
wl_proxy_destroy((struct wl_proxy *) wl_data_offer);
}

References WL_DATA_OFFER_DESTROY.

## wl_data_offer_finish()

static void wl_data_offer_finish | ( | struct wl_data_offer * | wl_data_offer | ) |

inline static

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.

Definition at line 2012 of file wayland-client-protocol.h.

{
wl_proxy_marshal((struct wl_proxy *) wl_data_offer,
WL_DATA_OFFER_FINISH);
}

References WL_DATA_OFFER_FINISH.

## wl_data_offer_get_user_data()

static void* wl_data_offer_get_user_data | ( | struct wl_data_offer * | wl_data_offer | ) |

inline static

Definition at line 1920 of file wayland-client-protocol.h.

{
return wl_proxy_get_user_data((struct wl_proxy *) wl_data_offer);
}

## wl_data_offer_receive()

static void wl_data_offer_receive | ( | struct wl_data_offer * | wl_data_offer,
|  | const char * | mime_type,
|  | int32_t | fd
| ) |  |

inline static

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 1976 of file wayland-client-protocol.h.

{
wl_proxy_marshal((struct wl_proxy *) wl_data_offer,
WL_DATA_OFFER_RECEIVE, mime_type, fd);
}

References WL_DATA_OFFER_RECEIVE.

## wl_data_offer_set_actions()

static void wl_data_offer_set_actions | ( | struct wl_data_offer * | wl_data_offer,
|  | uint32_t | dnd_actions,
|  | uint32_t | preferred_action
| ) |  |

inline static

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_drag_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 2054 of file wayland-client-protocol.h.

{
wl_proxy_marshal((struct wl_proxy *) wl_data_offer,
WL_DATA_OFFER_SET_ACTIONS, dnd_actions, preferred_action);
}

References WL_DATA_OFFER_SET_ACTIONS.

## wl_data_offer_set_user_data()

static void wl_data_offer_set_user_data | ( | struct wl_data_offer * | wl_data_offer,
|  | void * | user_data
| ) |  |

inline static

Definition at line 1913 of file wayland-client-protocol.h.

{
wl_proxy_set_user_data((struct wl_proxy *) wl_data_offer, user_data);
}
WL_DATA_OFFER_FINISH
#define WL_DATA_OFFER_FINISH
Definition: wayland-client-protocol.h:1874
WL_DATA_OFFER_DESTROY
#define WL_DATA_OFFER_DESTROY
Definition: wayland-client-protocol.h:1873
data
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1974
WL_DATA_OFFER_SET_ACTIONS
#define WL_DATA_OFFER_SET_ACTIONS
Definition: wayland-client-protocol.h:1875
WL_DATA_OFFER_RECEIVE
#define WL_DATA_OFFER_RECEIVE
Definition: wayland-client-protocol.h:1872
WL_DATA_OFFER_ACCEPT
#define WL_DATA_OFFER_ACCEPT
Definition: wayland-client-protocol.h:1871
fd
GLuint64 GLenum GLint fd
Definition: gl2ext.h:1508