Wayland++  0.2.6
C++ Bindings for Wayland
wayland::data_device_t Class Reference

data transfer device More...

#include <wayland-client-protocol.hpp>

Inheritance diagram for wayland::data_device_t:
Collaboration diagram for wayland::data_device_t:

Public Types

enum  wrapper_type { wrapper_type::standard, wrapper_type::display, wrapper_type::foreign, wrapper_type::proxy_wrapper }
 

Public Member Functions

void start_drag (data_source_t source, surface_t origin, surface_t icon, uint32_t serial)
 start drag-and-drop operation More...
 
void set_selection (data_source_t source, uint32_t serial)
 copy data to the selection More...
 
void release ()
 destroy data device More...
 
bool can_release () const
 Check whether the release function is available with the currently bound version of the protocol. More...
 
std::function< void(data_offer_t)> & on_data_offer ()
 introduce a new wl_data_offer More...
 
std::function< void(uint32_t, surface_t, double, double, data_offer_t)> & on_enter ()
 initiate drag-and-drop session More...
 
std::function< void()> & on_leave ()
 end drag-and-drop session More...
 
std::function< void(uint32_t, double, double)> & on_motion ()
 drag-and-drop session motion More...
 
std::function< void()> & on_drop ()
 end drag-and-drop session successfully More...
 
std::function< void(data_offer_t)> & on_selection ()
 advertise new selection More...
 
uint32_t get_id () const
 Get the id of a proxy object. More...
 
std::string get_class () const
 Get the interface name (class) of a proxy object. More...
 
uint32_t get_version () const
 Get the protocol object version of a proxy object. More...
 
wrapper_type get_wrapper_type () const
 Get the type of a proxy object. More...
 
void set_queue (event_queue_t queue)
 Assign a proxy to an event queue. More...
 
wl_proxy * c_ptr () const
 Get a pointer to the underlying C struct. More...
 
bool proxy_has_object () const
 Check whether this wrapper actually wraps an object. More...
 
 operator bool () const
 Check whether this wrapper actually wraps an object. More...
 
bool operator== (const proxy_t &right) const
 Check whether two wrappers refer to the same object. More...
 
bool operator!= (const proxy_t &right) const
 Check whether two wrappers refer to different objects. More...
 
void proxy_release ()
 Release the wrapped object (if any), making this an empty wrapper. More...
 

Static Public Attributes

static constexpr std::uint32_t start_drag_since_version = 1
 Minimum protocol version required for the start_drag function. More...
 
static constexpr std::uint32_t set_selection_since_version = 1
 Minimum protocol version required for the set_selection function. More...
 
static constexpr std::uint32_t release_since_version = 2
 Minimum protocol version required for the release function. More...
 

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 1099 of file wayland-client-protocol.hpp.

Member Enumeration Documentation

◆ wrapper_type

enum wayland::proxy_t::wrapper_type
stronginherited

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 105 of file wayland-client.hpp.

Member Function Documentation

◆ c_ptr()

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

◆ can_release()

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 2232 of file wayland-client-protocol.cpp.

◆ get_class()

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

◆ get_id()

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
Examples
dump.cpp.

◆ get_version()

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

◆ get_wrapper_type()

wrapper_type wayland::proxy_t::get_wrapper_type ( ) const
inlineinherited

Get the type of a proxy object.

Definition at line 288 of file wayland-client.hpp.

◆ on_data_offer()

std::function< void(data_offer_t)> & data_device_t::on_data_offer ( )

introduce a new wl_data_offer

Parameters
idthe 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 2237 of file wayland-client-protocol.cpp.

◆ on_drop()

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 2257 of file wayland-client-protocol.cpp.

◆ on_enter()

std::function< void(uint32_t, surface_t, double, double, data_offer_t)> & data_device_t::on_enter ( )

initiate drag-and-drop session

Parameters
serialserial number of the enter event
surfaceclient surface entered
xsurface-local x coordinate
ysurface-local y coordinate
idsource 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 2242 of file wayland-client-protocol.cpp.

◆ on_leave()

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 2247 of file wayland-client-protocol.cpp.

◆ on_motion()

std::function< void(uint32_t, double, double)> & data_device_t::on_motion ( )

drag-and-drop session motion

Parameters
timetimestamp with millisecond granularity
xsurface-local x coordinate
ysurface-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 2252 of file wayland-client-protocol.cpp.

◆ on_selection()

std::function< void(data_offer_t)> & data_device_t::on_selection ( )

advertise new selection

Parameters
idselection 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. The client must destroy the previous selection data_offer, if any, upon receiving this event.

Definition at line 2262 of file wayland-client-protocol.cpp.

◆ operator bool()

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

◆ operator!=()

bool wayland::proxy_t::operator!= ( const proxy_t right) const
inherited

Check whether two wrappers refer to different objects.

◆ operator==()

bool wayland::proxy_t::operator== ( const proxy_t right) const
inherited

Check whether two wrappers refer to the same object.

◆ proxy_has_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

◆ proxy_release()

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.

◆ release()

void data_device_t::release ( )

destroy data device

This request destroys the data device.

Definition at line 2228 of file wayland-client-protocol.cpp.

◆ set_queue()

void wayland::proxy_t::set_queue ( event_queue_t  queue)
inherited

Assign a proxy to an event queue.

Parameters
queueThe 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.

◆ set_selection()

void data_device_t::set_selection ( data_source_t  source,
uint32_t  serial 
)

copy data to the selection

Parameters
sourcedata source for the selection
serialserial 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 2223 of file wayland-client-protocol.cpp.

◆ start_drag()

void data_device_t::start_drag ( data_source_t  source,
surface_t  origin,
surface_t  icon,
uint32_t  serial 
)

start drag-and-drop operation

Parameters
sourcedata source for the eventual transfer
originsurface where the drag originates
icondrag-and-drop icon surface
serialserial 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.

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 2218 of file wayland-client-protocol.cpp.

Member Data Documentation

◆ release_since_version

constexpr std::uint32_t wayland::data_device_t::release_since_version = 2
staticconstexpr

Minimum protocol version required for the release function.

Definition at line 1193 of file wayland-client-protocol.hpp.

◆ set_selection_since_version

constexpr std::uint32_t wayland::data_device_t::set_selection_since_version = 1
staticconstexpr

Minimum protocol version required for the set_selection function.

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

◆ start_drag_since_version

constexpr std::uint32_t wayland::data_device_t::start_drag_since_version = 1
staticconstexpr

Minimum protocol version required for the start_drag function.

Definition at line 1166 of file wayland-client-protocol.hpp.


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