Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
PhosphorWayland::ClipboardDevice Class Reference

Client-side wrapper around zwlr_data_control_device_v1. More...

#include <phosphor-wayland/include/PhosphorWayland/ClipboardDevice.h>

Inheritance diagram for PhosphorWayland::ClipboardDevice:
[legend]

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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ClipboardDevice()

PhosphorWayland::ClipboardDevice::ClipboardDevice ( QObject *  parent = nullptr)
explicit

◆ ~ClipboardDevice()

PhosphorWayland::ClipboardDevice::~ClipboardDevice ( )
override

Member Function Documentation

◆ dataReceived

void PhosphorWayland::ClipboardDevice::dataReceived ( const QString &  mimeType,
const QByteArray &  data 
)
signal

Asynchronous result of receive(). data is empty on failure.

◆ isSupported()

static bool PhosphorWayland::ClipboardDevice::isSupported ( )
static

True iff the compositor advertises zwlr_data_control_manager_v1.

The constructor still succeeds when unsupported, but the device signals nothing.

◆ mimeTypes()

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

◆ receive()

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.

◆ selectionChanged

void PhosphorWayland::ClipboardDevice::selectionChanged ( const QStringList &  mimeTypes)
signal

The clipboard selection changed; mimeTypes lists the offered types (empty when the selection was cleared).

◆ setSelection()

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.


The documentation for this class was generated from the following file: