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 the dnd_drop_performed function 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 the dnd_finished function 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 the action function 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 the target function.
  • static constexpr std::uint32_t send_since_version = 1 β€” Minimum protocol version required for the send function.
  • static constexpr std::uint32_t cancelled_since_version = 1 β€” Minimum protocol version required for the cancelled function.
  • static constexpr std::uint32_t dnd_drop_performed_since_version = 3 β€” Minimum protocol version required for the dnd_drop_performed function.
  • static constexpr std::uint32_t dnd_finished_since_version = 3 β€” Minimum protocol version required for the dnd_finished function.
  • static constexpr std::uint32_t action_since_version = 3 β€” Minimum protocol version required for the action function.

🌸 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 in wl_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.

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