Client-side wrapper around zwlr_data_control_device_v1.
More...
#include <phosphor-wayland/include/PhosphorWayland/ClipboardDevice.h>
Signals | |
| void | selectionChanged (const QStringList &mimeTypes) |
The clipboard selection changed; mimeTypes lists the offered types (empty when the selection was cleared). | |
| void | dataReceived (const QString &mimeType, const QByteArray &data) |
Asynchronous result of receive(). data is empty on failure. | |
Public Member Functions | |
| ClipboardDevice (QObject *parent=nullptr) | |
| ~ClipboardDevice () override | |
| QStringList | mimeTypes () const |
| MIME types offered by the current clipboard selection, or an empty list when the selection is cleared (or the protocol is unsupported). | |
| void | receive (const QString &mimeType) |
Asynchronously read the current clipboard selection as mimeType. | |
| void | setSelection (const QMap< QString, QByteArray > &data) |
Take ownership of the clipboard selection, offering data keyed by MIME type; when a client pastes, the bytes for the requested type are written. | |
Static Public Member Functions | |
| static bool | isSupported () |
True iff the compositor advertises zwlr_data_control_manager_v1. | |
Client-side wrapper around zwlr_data_control_device_v1.
Watches the session's clipboard selection (independent of keyboard focus, the point of wlr-data-control), reports which MIME types the current selection offers, reads the selection content on demand, and can take ownership of the selection to re-offer data (paste a history entry back). This is the foundation primitive a clipboard-history service composes; it carries no policy, persistence, or model of its own.
Construct one per process. The device binds the protocol global on the first instance and Wayland keeps a per-binding event stream, so a second device would receive a duplicate stream of selections.
Threading: every method MUST be called from the GUI thread.
Reads are asynchronous: receive() returns immediately and the bytes arrive later via dataReceived(), read off a pipe on the event loop so a large or slow producer never blocks the UI.
|
explicit |
|
override |
|
signal |
Asynchronous result of receive(). data is empty on failure.
|
static |
True iff the compositor advertises zwlr_data_control_manager_v1.
The constructor still succeeds when unsupported, but the device signals nothing.
| QStringList PhosphorWayland::ClipboardDevice::mimeTypes | ( | ) | const |
MIME types offered by the current clipboard selection, or an empty list when the selection is cleared (or the protocol is unsupported).
| void PhosphorWayland::ClipboardDevice::receive | ( | const QString & | mimeType | ) |
Asynchronously read the current clipboard selection as mimeType.
The result arrives via dataReceived(mimeType, data) (with empty data on failure or when mimeType is not offered). A no-op with no current selection.
|
signal |
The clipboard selection changed; mimeTypes lists the offered types (empty when the selection was cleared).
| void PhosphorWayland::ClipboardDevice::setSelection | ( | const QMap< QString, QByteArray > & | data | ) |
Take ownership of the clipboard selection, offering data keyed by MIME type; when a client pastes, the bytes for the requested type are written.
Replaces any previous selection this device set. Pass at least one type.