QEMU UI subsystem
QEMU Clipboard
Introduction
The header ui/clipboard.h declares the qemu clipboard interface.
All qemu elements which want use the clipboard can register as clipboard peer. Subsequently they can set the clipboard content and get notifications for clipboard updates.
Typical users are user interfaces (gtk), remote access protocols (vnc) and devices talking to the guest (vdagent).
Even though the design allows different data types only plain text is supported for now.
-
enum QemuClipboardType
Constants
QEMU_CLIPBOARD_TYPE_TEXTtext/plain; charset=utf-8
QEMU_CLIPBOARD_TYPE__COUNTtype count.
-
enum QemuClipboardSelection
Constants
QEMU_CLIPBOARD_SELECTION_CLIPBOARDclipboard (explitcit cut+paste).
QEMU_CLIPBOARD_SELECTION_PRIMARYprimary selection (select + middle mouse button).
QEMU_CLIPBOARD_SELECTION_SECONDARYsecondary selection (dunno).
QEMU_CLIPBOARD_SELECTION__COUNTselection count.
-
struct QemuClipboardPeer
Definition
struct QemuClipboardPeer {
const char *name;
Notifier notifier;
void (*request)(QemuClipboardInfo *info, QemuClipboardType type);
};
Members
namepeer name.
notifiernotifier for clipboard updates.
requestcallback for clipboard data requests.
Description
Clipboard peer description.
-
enum QemuClipboardNotifyType
Constants
QEMU_CLIPBOARD_UPDATE_INFOclipboard info update
QEMU_CLIPBOARD_RESET_SERIALreset clipboard serial
Description
Clipboard notify type.
-
struct QemuClipboardNotify
Definition
struct QemuClipboardNotify {
QemuClipboardNotifyType type;
union {
QemuClipboardInfo *info;
};
};
Members
typethe type of event.
{unnamed_union}anonymous
infoa QemuClipboardInfo event.
Description
Clipboard notify data.
-
struct QemuClipboardInfo
Definition
struct QemuClipboardInfo {
uint32_t refcount;
QemuClipboardPeer *owner;
QemuClipboardSelection selection;
bool has_serial;
uint32_t serial;
struct {
bool available;
bool requested;
size_t size;
void *data;
} types[QEMU_CLIPBOARD_TYPE__COUNT];
};
Members
refcountreference counter.
ownerclipboard owner.
selectionclipboard selection.
has_serialwhether serial is available.
serialthe grab serial counter.
typesclipboard data array (one entry per type).
Description
Clipboard content data and metadata.
-
void qemu_clipboard_peer_register(QemuClipboardPeer *peer)
Parameters
QemuClipboardPeer *peerpeer information.
Description
Register clipboard peer. Registering is needed for both active (set+grab clipboard) and passive (watch clipboard for updates) interaction with the qemu clipboard.
-
void qemu_clipboard_peer_unregister(QemuClipboardPeer *peer)
Parameters
QemuClipboardPeer *peerpeer information.
Description
Unregister clipboard peer.
-
bool qemu_clipboard_peer_owns(QemuClipboardPeer *peer, QemuClipboardSelection selection)
Parameters
QemuClipboardPeer *peerpeer information.
QemuClipboardSelection selectionclipboard selection.
Description
Return TRUE if the peer owns the clipboard.
-
void qemu_clipboard_peer_release(QemuClipboardPeer *peer, QemuClipboardSelection selection)
Parameters
QemuClipboardPeer *peerpeer information.
QemuClipboardSelection selectionclipboard selection.
Description
If the peer owns the clipboard, release it.
-
QemuClipboardInfo *qemu_clipboard_info(QemuClipboardSelection selection)
Parameters
QemuClipboardSelection selectionclipboard selection.
Description
Return the current clipboard data & owner informations.
-
bool qemu_clipboard_check_serial(QemuClipboardInfo *info, bool client)
Parameters
QemuClipboardInfo *infoclipboard info.
bool clientwhether to check from the client context and priority.
Description
Return TRUE if the info has a higher serial than the current clipboard.
-
QemuClipboardInfo *qemu_clipboard_info_new(QemuClipboardPeer *owner, QemuClipboardSelection selection)
Parameters
QemuClipboardPeer *ownerclipboard owner.
QemuClipboardSelection selectionclipboard selection.
Description
Allocate a new QemuClipboardInfo and initialize it with the given owner and selection.
QemuClipboardInfo is a reference-counted struct. The new struct is returned with a reference already taken (i.e. reference count is one).
-
QemuClipboardInfo *qemu_clipboard_info_ref(QemuClipboardInfo *info)
Parameters
QemuClipboardInfo *infoclipboard info.
Description
Increase info reference count.
-
void qemu_clipboard_info_unref(QemuClipboardInfo *info)
Parameters
QemuClipboardInfo *infoclipboard info.
Description
Decrease info reference count. When the count goes down to zero free the info struct itself and all clipboard data.
-
void qemu_clipboard_update(QemuClipboardInfo *info)
Parameters
QemuClipboardInfo *infoclipboard info.
Description
Update the qemu clipboard. Notify all registered peers (including the clipboard owner) that the qemu clipboard has been updated.
This is used for both new completely clipboard content and for clipboard data updates in response to qemu_clipboard_request() calls.
-
void qemu_clipboard_reset_serial(void)
Parameters
voidno arguments
Description
Reset the clipboard serial.
-
void qemu_clipboard_request(QemuClipboardInfo *info, QemuClipboardType type)
Parameters
QemuClipboardInfo *infoclipboard info.
QemuClipboardType typeclipboard data type.
Description
Request clipboard content. Typically the clipboard owner only advertises the available data types and provides the actual data only on request.
-
void qemu_clipboard_set_data(QemuClipboardPeer *peer, QemuClipboardInfo *info, QemuClipboardType type, uint32_t size, const void *data, bool update)
Parameters
QemuClipboardPeer *peerclipboard peer.
QemuClipboardInfo *infoclipboard info.
QemuClipboardType typeclipboard data type.
uint32_t sizedata size.
const void *datadata blob.
bool updatenotify peers about the update.
Description
Set clipboard content for the given type. This function will make a copy of the content data and store that.