aboutsummaryrefslogtreecommitdiff
path: root/ui/clipboard.c
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2021-08-05 17:57:02 +0400
committerMarc-André Lureau <marcandre.lureau@redhat.com>2021-08-31 17:25:14 +0400
commit684e64d36d139c1473dd029661c20ba968c0fe53 (patch)
treed50e4db96b289f481f2e2294aca0074e7b9f958a /ui/clipboard.c
parent6b32aef09a7d592491a8e25ce1714cb0503a3d6e (diff)
downloadqemu-684e64d36d139c1473dd029661c20ba968c0fe53.zip
qemu-684e64d36d139c1473dd029661c20ba968c0fe53.tar.gz
qemu-684e64d36d139c1473dd029661c20ba968c0fe53.tar.bz2
ui/clipboard: add helper to retrieve current clipboard
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20210805135715.857938-6-marcandre.lureau@redhat.com> Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'ui/clipboard.c')
-rw-r--r--ui/clipboard.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/ui/clipboard.c b/ui/clipboard.c
index 3525b30..56c1450 100644
--- a/ui/clipboard.c
+++ b/ui/clipboard.c
@@ -4,6 +4,8 @@
static NotifierList clipboard_notifiers =
NOTIFIER_LIST_INITIALIZER(clipboard_notifiers);
+static QemuClipboardInfo *cbinfo[QEMU_CLIPBOARD_SELECTION__COUNT];
+
void qemu_clipboard_peer_register(QemuClipboardPeer *peer)
{
notifier_list_add(&clipboard_notifiers, &peer->update);
@@ -16,7 +18,20 @@ void qemu_clipboard_peer_unregister(QemuClipboardPeer *peer)
void qemu_clipboard_update(QemuClipboardInfo *info)
{
+ g_autoptr(QemuClipboardInfo) old = NULL;
+ assert(info->selection < QEMU_CLIPBOARD_SELECTION__COUNT);
+
notifier_list_notify(&clipboard_notifiers, info);
+
+ old = cbinfo[info->selection];
+ cbinfo[info->selection] = qemu_clipboard_info_ref(info);
+}
+
+QemuClipboardInfo *qemu_clipboard_info(QemuClipboardSelection selection)
+{
+ assert(selection < QEMU_CLIPBOARD_SELECTION__COUNT);
+
+ return cbinfo[selection];
}
QemuClipboardInfo *qemu_clipboard_info_new(QemuClipboardPeer *owner,