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 theset_actionsfunction 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 theofferfunction.static constexpr std::uint32_t set_actions_since_version = 3โ Minimum protocol version required for theset_actionsfunction.
โจ 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 withwl_proxy*. Events are dispatched and it is destructed when theproxy_tis destructed. User data is set.displayโ C pointer is awl_display*. No events are dispatched,wl_display_disconnectis called when theproxy_tis destructed. User data is set.foreignโ C pointer is a standard type compatible withwl_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_destroyis not called when theproxy_tis destructed, user data is not touched. Consequently, there is no reference counting for theproxy_t. Lifetime of such wrappers should preferably be short to minimize the chance that the owning library decides to destroy thewl_proxy. ๐ (do not touch, fr fr)proxy_wrapperโ C pointer is awl_proxy*that was constructed withwl_proxy_create_wrapper. No events are dispatched,wl_proxy_wrapper_destroyis called when theproxy_tis destroyed. Reference counting is active. A reference to theproxy_tcreating 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 datafdโ 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.
thednd_actionsargument must contain only values expressed in thewl_data_device_manager.dnd_actionsenum, 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
- ubuntu stonking: waylandpp-dev 1.0.1-2 ยท BSD-2-Clause
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms