wayland::data_offer_t(3)
okay bestie, this is the wayland::data_offer_t(3) page from the Wayland++ set β manual name folded in right here, no cap. Itβs giving βclipboard but make it protocol,β and honestly? iconic. π«Ά
β¨ NAME β¨
wayland::data_offer_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 }β the wrapper-type enum is right here, bestie.
π¦ Public Member Functions π¦
void accept (uint32_t serial, std::string const &mime_type)β accept one of the offered mime types.void receive (std::string const &mime_type, int fd)β request that the data is transferred.void finish ()β the offer will no longer be used.bool can_finish () constβ check whether thefinishfunction is available with the currently bound version of the protocol.void set_actions (data_device_manager_dnd_action const &dnd_actions, data_device_manager_dnd_action const &preferred_action)β set the available/preferred drag-and-drop actions.bool can_set_actions () constβ check whether theset_actionsfunction is available with the currently bound version of the protocol.std::function< void(std::string)> & on_offer ()β advertise offered mime type.std::function< void(data_device_manager_dnd_action)> & on_source_actions ()β notify the source-side available actions.std::function< void(data_device_manager_dnd_action)> & on_action ()β notify the selected action.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.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 accept_since_version = 1β minimum protocol version required for theacceptfunction.static constexpr std::uint32_t receive_since_version = 1β minimum protocol version required for thereceivefunction.static constexpr std::uint32_t finish_since_version = 3β minimum protocol version required for thefinishfunction.static constexpr std::uint32_t set_actions_since_version = 3β minimum protocol version required for theset_actionsfunction.
π Detailed Description π
offer to transfer data
A wl_data_offer represents a piece of data offered for transfer by another client (the source client). It is used by the copy-and-paste and drag-and-drop mechanisms. The offer describes the different mime types that the data can be converted to and provides the mechanism for transferring the data directly from the source client.
Definition at line 760 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.
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.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, buckle up β this is the function-by-function glow-up of data_offer_t, plus all the inherited proxy_t bits that ride along. Every signature, every param, every line number is staying exactly where it belongs. No cap. β¨
πΈ void data_offer_t::accept (uint32_t serial, std::string const & mime_type)
accept one of the offered mime types β literally the "yes I'll take that, thank you" button.
Parameters:
serialβ serial number of the accept requestmime_typeβ mime type accepted by the client
Indicate that the client can accept the given mime type, or NULL for not accepted.
For objects of version 2 or older, this request is used by the client to give feedback whether the client can receive the given mime type, or NULL if none is accepted; the feedback does not determine whether the drag-and-drop operation succeeds or not.
For objects of version 3 or newer, this request determines the final result of the drag-and-drop operation. If the end result is that no mime types were accepted, the drag-and-drop operation will be cancelled and the corresponding drag source will receive wl_data_source.cancelled. Clients may still use this event in conjunction with wl_data_source.action for feedback.
π Definition at line 2028 of file wayland-client-protocol.cpp.
π§ wl_proxy * wayland::proxy_t::c_ptr () const [inherited]
Get a pointer to the underlying C struct.
Returns:
- The underlying
wl_proxywrapped by thisproxy_tif it exists, otherwise an exception is thrown
π¦ bool data_offer_t::can_finish () const
Check whether the finish function is available with the currently bound version of the protocol.
π Definition at line 2045 of file wayland-client-protocol.cpp.
π¦ bool data_offer_t::can_set_actions () const
Check whether the set_actions function is available with the currently bound version of the protocol.
π Definition at line 2056 of file wayland-client-protocol.cpp.
π₯ void data_offer_t::finish ()
the offer will no longer be used β Notifies the compositor that the drag destination successfully finished the drag-and-drop operation.
Upon receiving this request, the compositor will emit wl_data_source.dnd_finished on the drag source client.
β οΈ It is a client error to perform other requests thanwl_data_offer.destroyafter this one. It is also an error to perform this request after aNULLmime type has been set inwl_data_offer.acceptor no action was received throughwl_data_offer.action.
If wl_data_offer.finish request is received for a non drag and drop operation, the invalid_finish protocol error is raised.
π Definition at line 2040 of file 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.
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 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
π wrapper_type wayland::proxy_t::get_wrapper_type () const [inline], [inherited]
Get the type of a proxy object.
π Definition at line 303 of file wayland-client.hpp.
π std::function< void(data_device_manager_dnd_action)> & data_offer_t::on_action ()
notify the selected action
Parameters:
dnd_actionβ action selected by the compositor
This event indicates the action selected by the compositor after matching the source/destination side actions. Only one action (or none) will be offered here.
This event can be emitted multiple times during the drag-and-drop operation in response to destination side action changes through wl_data_offer.set_actions.
This event will no longer be emitted after wl_data_device.drop happened on the drag-and-drop destination, the client must honor the last action received, or the last preferred one set through wl_data_offer.set_actions when handling an "ask" action.
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. Prior to receiving wl_data_device.drop, the chosen action may change (e.g. due to keyboard modifiers being pressed). At the time of receiving wl_data_device.drop the drag-and-drop destination must honor the last action received.
Action changes may still happen after wl_data_device.drop, especially on "ask" actions, where the drag-and-drop destination may choose another action afterwards. Action changes happening at this stage are always the result of inter-client negotiation, the compositor shall no longer be able to induce a different action.
Upon "ask" actions, it is expected that the drag-and-drop destination may potentially choose a different action and/or mime type, based on wl_data_offer.source_actions and finally chosen by the user (e.g. popping up a menu with the available options). The final wl_data_offer.set_actions and wl_data_offer.accept requests must happen before the call to wl_data_offer.finish.
π Definition at line 2072 of file wayland-client-protocol.cpp.
π std::function< void(std::string)> & data_offer_t::on_offer ()
advertise offered mime type
Parameters:
mime_typeβ offered mime type
Sent immediately after creating the wl_data_offer object. One event per offered mime type.
π Definition at line 2062 of file wayland-client-protocol.cpp.
π§ std::function< void(data_device_manager_dnd_action)> & data_offer_t::on_source_actions ()
notify the source-side available actions
Parameters:
source_actionsβ actions offered by the data source
This event indicates the actions offered by the data source. It will be sent right after wl_data_device.enter, or anytime the source side changes its offered actions through wl_data_source.set_actions.
π Definition at line 2067 of file wayland-client-protocol.cpp.
π wayland::proxy_t::operator bool () const [inherited]
Check whether this wrapper actually wraps an object.
Returns:
trueif there is an underlying object,falseif 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.
Returns:
trueif there is an underlying object,falseif this wrapper is empty
πΈ 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.
π₯ void data_offer_t::receive (std::string const & mime_type, int fd)
request that the data is transferred
Parameters:
mime_typeβ mime type desired by receiverfdβ file descriptor for data transfer
To transfer the offered data, the client issues this request and indicates the mime type it wants to receive. The transfer happens through the passed file descriptor (typically created with the pipe system call). The source client writes the data in the mime type representation requested and then closes the file descriptor.
The receiving client reads from the read end of the pipe until EOF and then closes its end, at which point the transfer is complete.
This request may happen multiple times for different mime types, both before and after wl_data_device.drop. Drag-and-drop destination clients may preemptively fetch data or examine it more closely to determine acceptance.
π Definition at line 2034 of file wayland-client-protocol.cpp.
π
void data_offer_t::set_actions (data_device_manager_dnd_action const & dnd_actions, data_device_manager_dnd_action const & preferred_action)
set the available/preferred drag-and-drop actions
Parameters:
dnd_actionsβ actions supported by the destination clientpreferred_actionβ action preferred by the destination client
Sets the actions that the destination side client supports for this operation. This request may trigger the emission of wl_data_source.action and wl_data_offer.action events if the compositor needs to change the selected action.
This request can be called multiple times throughout the drag-and-drop operation, typically in response to wl_data_device.enter or wl_data_device.motion events.
This request determines the final result of the drag-and-drop operation. If the end result is that no action is accepted, the drag source will receive wl_data_source.cancelled.
The dnd_actions argument must contain only values expressed in the wl_data_device_manager.dnd_actions enum, and the preferred_action argument must only contain one of those values set, otherwise it will result in a protocol error.
While managing an "ask" action, the destination drag-and-drop client may perform further wl_data_offer.receive requests, and is expected to perform one last wl_data_offer.set_actions request with a preferred action other than "ask" (and optionally wl_data_offer.accept) before requesting wl_data_offer.finish, in order to convey the action selected by the user. If the preferred action is not in the wl_data_offer.source_actions mask, an error will be raised.
If the "ask" action is dismissed (e.g. user cancellation), the client is expected to perform wl_data_offer.destroy right away.
This request can only be made on drag-and-drop offers, a protocol error will be raised otherwise.
π Definition at line 2051 of file 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 β¨
Okay bestie, these are the compile-time vibe-check constants β every single one of them lives in wayland-client-protocol.hpp, and every single one of them is static and constexpr, which means they're frozen at compile time and you literally cannot argue with them. They're the "you must be at least this tall to ride" numbers for the protocol. π’
std::uint32_t wayland::data_offer_t::accept_since_version = 1[static],[constexpr]β the minimum protocol version required for theacceptfunction. That's1, the absolute bare minimum, the original flavor, the day-one queen. π Defined at line 809 ofwayland-client-protocol.hpp.std::uint32_t wayland::data_offer_t::finish_since_version = 3[static],[constexpr]β the minimum protocol version required for thefinishfunction, and ngl it's a3, so if your compositor is stuck on protocol version 1 or 2,finishis not happening for you, periodt. Defined at line 860 ofwayland-client-protocol.hpp.std::uint32_t wayland::data_offer_t::receive_since_version = 1[static],[constexpr]β the minimum protocol version required for thereceivefunction. Again just1β lowkey the most welcoming number in the whole file. π«Ά Defined at line 836 ofwayland-client-protocol.hpp.std::uint32_t wayland::data_offer_t::set_actions_since_version = 3[static],[constexpr]β the minimum protocol version required for theset_actionsfunction. Also a3, same energy asfinishβ fancy new feature, fancy new version requirement, that's the rule and we respect it. π Defined at line 908 ofwayland-client-protocol.hpp.
Double-check these before you gate anything on them, bestie β they're the floor, not a suggestion, and a mismatched protocol version is the kind of bug that eats a whole afternoon. π
πΈ Author πΈ
Generated automatically by Doxygen for Wayland++ from the source code.
Which is fr fr the most "no thoughts, just vibes" author credit ever β nobody hand-wrote this, Doxygen just manifested it directly from the source like a little documentation fairy. π§β¨
And that's a wrap on wayland::data_offer_t(3), bestie! π This was Version 1.0.1, dated Fri Mar 27 2026 13:15:00 β so go forth, gate your protocol versions correctly, and slay. πππ¦
π¦ 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