wayland::data_source_t(3)

๐Ÿฆ‹ wayland::data_source_t โ€” offer to transfer data ๐Ÿฆ‹

okay so bestie, this is the Wayland++ manual, section (3), and we're getting into wayland::data_source_t โ€” literally the moment you offer data to somebody else's app. it's giving main-character energy for the clipboard. ๐Ÿ’…


๐ŸŒธ NAME ๐ŸŒธ

wayland::data_source_t โ€” offer to transfer data โœจ

๐ŸŽ€ 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 offer (std::string const &mime_type) โ€” add an offered mime type. yes bestie, tell everyone what you've got ๐Ÿ“
  • void set_actions (data_device_manager_dnd_action const &dnd_actions) โ€” set the available drag-and-drop actions, so drag-and-drop knows what's on the menu โœจ
  • bool can_set_actions () const โ€” Check whether the set_actions function is available with the currently bound version of the protocol. lowkey important before you call it ๐Ÿ‘€
  • std::function< void(std::string)> & on_target () โ€” a target accepts an offered mime type. slay, they picked one ๐Ÿ’…
  • std::function< void(std::string, int)> & on_send () โ€” send the data. this is the actual handoff, no cap ๐Ÿ“ฆ
  • std::function< void()> & on_cancelled () โ€” selection was cancelled. rip, it's over ๐Ÿ˜ญ
  • std::function< void()> & on_dnd_drop_performed () โ€” the drag-and-drop operation physically finished ๐Ÿซถ
  • std::function< void()> & on_dnd_finished () โ€” the drag-and-drop operation concluded. periodt, it's done โœจ
  • std::function< void(data_device_manager_dnd_action)> & on_action () โ€” notify the selected action, so you know which vibe they chose ๐ŸŒˆ
  • 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. (yes, it's giving the same energy twice, but that's what the page says ๐Ÿซ )
  • 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 offer_since_version = 1 โ€” Minimum protocol version required for the offer function.
  • static constexpr std::uint32_t set_actions_since_version = 3 โ€” Minimum protocol version required for the set_actions 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 1002 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. this is the lore, bestie ๐Ÿงš

๐Ÿ’€ 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. ๐Ÿ™ˆ (do not touch, fr fr)
  • 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 117 of file wayland-client.hpp.

โœจ MEMBER FUNCTION DOCUMENTATION โœจ

okay bestie, here's the function-by-function tea โ˜• โ€” every signature, every return value, every cursed edge case, all of it. no skips. ๐Ÿ’…

wl_proxy * wayland::proxy_t::c_ptr () const โ€” inherited

Get a pointer to the underlying C struct. ๐Ÿซถ

Returns โ€” the underlying wl_proxy that this proxy_t is wrapping, if it exists. if it doesn't exist? it throws. so like, vibe check your wrapper before you go dereferencing, ngl.

bool data_source_t::can_set_actions () const

Check whether the set_actions function is even available with the protocol version you're currently bound to. icon behaviour fr โ€” don't call stuff that isn't there. โœจ

Defined at line 2158 of 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. literally its little name tag. ๐Ÿท๏ธ

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 version, or 0 if the proxy was created with the unversioned API.

a returned value of 0 means no version info is available, so the caller must make safe assumptions about the object's real version. no guessing and then crying about it. ๐Ÿ˜ญ

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. ๐Ÿ‘‘

Defined at line 303 of wayland-client-protocol.hpp.


void data_source_t::offer (std::string const & mime_type)

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 โ€” go off, offer them all. ๐ŸŒˆ

Defined at line 2147 of wayland-client-protocol.cpp.

std::function< void(data_device_manager_dnd_action)> & data_source_t::on_action ()

notify the selected action. โœจ

Parameters

  • dnd_action โ€” action selected by the compositor

This event says which action the compositor picked after matching the source/destination side actions. only one action (or none) gets 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's 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. ๐Ÿ–ฑ๏ธ

Defined at line 2189 of wayland-client-protocol.cpp.

std::function< void()> & data_source_t::on_cancelled ()

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.

Defined at line 2174 of wayland-client-protocol.cpp.

std::function< void()> & data_source_t::on_dnd_drop_performed ()

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. no premature destroying, bestie, that's giving undefined chaos.

Defined at line 2179 of wayland-client-protocol.cpp.

std::function< void()> & data_source_t::on_dnd_finished ()

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. ๐Ÿ“ฆ

Defined at line 2184 of wayland-client-protocol.cpp.

std::function< void(std::string, int)> & data_source_t::on_send ()

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. closing it is not optional, iykyk. โœจ

Defined at line 2169 of wayland-client-protocol.cpp.

std::function< void(std::string)> & data_source_t::on_target ()

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. ๐Ÿ’ซ

Defined at line 2164 of wayland-client-protocol.cpp.


wayland::proxy_t::operator bool () const โ€” inherited

Check whether this wrapper actually wraps an object. the realest vibe check in the whole file tbh. ๐Ÿชž

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. same energy as operator bool, just saying it plainly.

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. ๐Ÿƒ

heads up: display_t instances cannot be released this way. attempts to do so are just ignored โ€” no error, no drama, nothing happens.

Examples: foreign_display.cpp.

void data_source_t::set_actions (data_device_manager_dnd_action const & dnd_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. โš ๏ธ no freestyle enum values, bestie.

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. ๐Ÿ˜ญ

Defined at line 2153 of 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.


๐ŸŒธ MEMBER DATA DOCUMENTATION ๐ŸŒธ

std::uint32_t wayland::data_source_t::offer_since_version = 1 โ€” [static], [constexpr]

Minimum protocol version required for the offer function. that's a 1, so it's basically always there for you. ๐Ÿฅฐ

Defined at line 1042 of wayland-client-protocol.hpp.

std::uint32_t wayland::data_source_t::set_actions_since_version = 3 โ€” [static], [constexpr]

Minimum protocol version required for the set_actions function. it's a 3, hence why can_set_actions exists to check for you. ๐Ÿ‘‘

Defined at line 1066 of wayland-client-protocol.hpp.


๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

Generated automatically by Doxygen for Wayland++ from the source code. not a human, just a very diligent little document generator doing its thing. ๐Ÿค–๐Ÿ’œ


and that's the whole page, bestie โ€” you ate it all up. ๐Ÿ“ version 1.0.1, dated Fri Mar 27 2026 13:15:00, wayland::data_source_t(3), slay, periodt. ๐ŸŽ€โœจ๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from