wayland::server::data_source_t(3)
π NAME π
okay so welcome to wayland::server::data_source_t(3) from Wayland++, bestie π β this whole page is literally about the offer to transfer data. that's the vibe. no cap.
β¨ SYNOPSIS β¨
#include <wayland-server-protocol.hpp>
π«Ά Public Member Functions π«Ά
std::function< void(std::string)> & on_offer ()β add an offered mime type. iconic little callback moment.std::function< void()> & on_destroy ()β destroy the data source. bye bestie πstd::function< void(data_device_manager_dnd_action)> & on_set_actions ()β set the available drag-and-drop actions. drag-and-drop main character energy.void target (std::string const &mime_type, bool post=true)β a target accepts an offered mime type. slay, they picked one.void send (std::string const &mime_type, int fd, bool post=true)β send the data. literally the whole point πvoid cancelled (bool post=true)β selection was cancelled. rude, but okay.void dnd_drop_performed (bool post=true)β the drag-and-drop operation physically finished. it's giving completion.bool can_dnd_drop_performed () constβ Check whether thednd_drop_performedfunction is available with the currently bound version of the protocol.void dnd_finished (bool post=true)β the drag-and-drop operation concluded. periodt.bool can_dnd_finished () constβ Check whether thednd_finishedfunction 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. let them know what's tea.bool can_action () constβ Check whether theactionfunction 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. not me getting rejected πbool proxy_has_object () constβ Check whether this wrapper actually wraps an object.void post_no_memory () constβ no cap, this one's just there.uint32_t get_id () constβ get the id.client_t get_client () constβ get the client.unsigned int get_version () constβ get the version.std::string get_class ()β get the class.
π Static Public Attributes π
static constexpr std::uint32_t target_since_version = 1β Minimum protocol version required for thetargetfunction.static constexpr std::uint32_t send_since_version = 1β Minimum protocol version required for thesendfunction.static constexpr std::uint32_t cancelled_since_version = 1β Minimum protocol version required for thecancelledfunction.static constexpr std::uint32_t dnd_drop_performed_since_version = 3β Minimum protocol version required for thednd_drop_performedfunction.static constexpr std::uint32_t dnd_finished_since_version = 3β Minimum protocol version required for thednd_finishedfunction.static constexpr std::uint32_t action_since_version = 3β Minimum protocol version required for theactionfunction.
πΈ Detailed Description πΈ
offer to transfer data. yes we're back to that, because that's literally the entire point π
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. like, it's the origin story and the customer service desk, all at once π«Ά
Definition at line 1090 of file wayland-server-protocol.hpp.
bestie this is only part 1, there's more loadingβ¦ ππ
β¨ Member Function Documentation β¨
π¬ action β notify the selected action
void data_source_t::action (data_device_manager_dnd_action const &
dnd_action, bool post = true)
Okay so this event is literally the compositor sliding into your DMs to tell you which action got picked π
Parameters
dnd_actionβ the action selected by the compositor
Here's the tea: this event fires after the compositor matches the source-side and destination-side actions against each other. Only one action (or none at all, no cap) will ever be offered here.
And it's not a one-and-done situation β this event can be emitted multiple times during a single drag-and-drop operation. Mostly it's reacting to destination-side changes coming through wl_data_offer.set_actions, and to the data device entering/leaving surfaces.
Timing matters, bestie: you can only receive this event after wl_data_source.dnd_drop_performed if the drag-and-drop operation ended in an "ask" action. In that case the final wl_data_source.action event happens, like, immediately before wl_data_source.dnd_finished. So close together. π«Ά
Compositors may also switch up the selected action on the fly β usually because you're mashing keyboard modifiers mid-drag. Iconic behaviour honestly.
The most recent action you receive is always the valid one. The chosen action can change alongside negotiation (an"ask"action turning into a"move"operation is a whole vibe), so the effects of the final action must always be applied inwl_data_offer.dnd_finished. Don't get caught lacking on this one π
Clients can trigger cursor surface changes starting from this point, so the cursor actually reflects the current action. Slay.
Definition at line 2020 of file wayland-server-protocol.cpp.
π can_action β is this even available rn?
bool data_source_t::can_action () const
Check whether the action function is available with the currently bound version of the protocol. Basically a vibe check on the protocol version β¨
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. Version check, but make it cute π
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. Same energy as the last two, fr fr β¨
Definition at line 2015 of file wayland-server-protocol.cpp.
π cancelled β selection was cancelled
void data_source_t::cancelled (bool post = true)
Not to be dramatic but this data source? No longer valid. It's giving "we need to talk." π There are several reasons 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. Like, properly. π§Ή
Heads up for the old-school objects: 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. That's it. That's the only trigger. π
Definition at line 1995 of file wayland-server-protocol.cpp.
π― dnd_drop_performed β the drag-and-drop operation physically finished
void data_source_t::dnd_drop_performed (bool post = true)
Your user actually performed the drop action. Iconic of them. But β and this is important β this event does not indicate acceptance. wl_data_source.cancelled may still be emitted afterwards if the drop destination doesn't accept any mime type. So don't start celebrating yet π
Also, this event might not be received at all 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. Hands off the destroy button bestie π
Definition at line 2000 of file wayland-server-protocol.cpp.
π dnd_finished β the drag-and-drop operation concluded
void data_source_t::dnd_finished (bool post = true)
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. You're released, bestie π¦
And if the action used to perform the operation was "move", the source can now delete the transferred data. Cleanup era β¨
Definition at line 2010 of file wayland-server-protocol.cpp.
π·οΈ wayland::server::resource_t::get_class [inherited]
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.
π€ wayland::server::resource_t::get_client [inherited]
client_t wayland::server::resource_t::get_client () const [inherited]
Get the associated client.
Returns the client that owns the resource.
π wayland::server::resource_t::get_id [inherited]
uint32_t wayland::server::resource_t::get_id () const [inherited]
Get the internal ID of the resource.
Returns the internal ID of the resource
π’ wayland::server::resource_t::get_version [inherited]
unsigned int wayland::server::resource_t::get_version () const [inherited]
Get interface version.
Returns Interface version this resource has been constructed with.
πͺ¦ on_destroy β destroy the data source
std::function< void()> & data_source_t::on_destroy ()
Destroy the data source. That's it. That's the whole thing π
Definition at line 1973 of file wayland-server-protocol.cpp.
π on_offer β add an offered mime type
std::function< void(std::string)> & data_source_t::on_offer ()
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. You can call it several times to offer multiple types β go off, collect them all π
Definition at line 1967 of file wayland-server-protocol.cpp.
ποΈ on_set_actions β set the available drag-and-drop actions
std::function< void(data_device_manager_dnd_action)> &
data_source_t::on_set_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. Not a warning. Not a vibe. 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. Rules are rules, bestie π€
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. You goofed the mask π₯²
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. Wrong source, wrong energy π
Definition at line 2035 of file wayland-server-protocol.cpp.
π§ wayland::server::resource_t::post_no_memory [inherited]
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. (Yes, "certail" β we're keeping it, it's part of the lore π)
π¦ wayland::server::resource_t::proxy_has_object [inherited]
bool wayland::server::resource_t::proxy_has_object () const [inherited]
Check whether this wrapper actually wraps an object. Emotional availability check, but for wrappers π«Ά
Returns true if there is an underlying object, false if this wrapper is empty
π¨ send β send the data
void data_source_t::send (std::string const & mime_type, int fd, bool post =
true)
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. Don't forget the close, that's the whole assignment π₯
Definition at line 1990 of file wayland-server-protocol.cpp.
π― target β a target accepts an offered mime type
void data_source_t::target (std::string const & mime_type, bool post = true)
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. Little status pings, but make it protocol β¨
Definition at line 1985 of file wayland-server-protocol.cpp.
π Member Data Documentation π
action_since_version
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 1294 of file wayland-server-protocol.hpp.
cancelled_since_version
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 1213 of file wayland-server-protocol.hpp.
dnd_drop_performed_since_version
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 1232 of file wayland-server-protocol.hpp.
dnd_finished_since_version
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 1253 of file wayland-server-protocol.hpp.
send_since_version
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 1183 of file wayland-server-protocol.hpp.
target_since_version
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 1168 of file wayland-server-protocol.hpp.
πΈ Author πΈ
Generated automatically by Doxygen for Wayland++ from the source code. (Yes, a robot wrote this and honestly? It ate. π€β¨)
Okay bestie, that's the whole page β Version 1.0.1, dated Fri Mar 27 2026, brought to you by Wayland++ and a Doxygen sprint. Go forth and drag-and-drop responsibly, mwah πππ¦
π¦ 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