[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 05/18] ui/clipboard: add helper to retrieve current clipboard
From: |
marcandre . lureau |
Subject: |
[PULL 05/18] ui/clipboard: add helper to retrieve current clipboard |
Date: |
Tue, 31 Aug 2021 17:31:19 +0400 |
From: Marc-André Lureau <marcandre.lureau@redhat.com>
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>
---
include/ui/clipboard.h | 9 +++++++++
ui/clipboard.c | 15 +++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/include/ui/clipboard.h b/include/ui/clipboard.h
index eb789a285a..e9fcb15c66 100644
--- a/include/ui/clipboard.h
+++ b/include/ui/clipboard.h
@@ -109,6 +109,15 @@ void qemu_clipboard_peer_register(QemuClipboardPeer *peer);
*/
void qemu_clipboard_peer_unregister(QemuClipboardPeer *peer);
+/**
+ * qemu_clipboard_info
+ *
+ * @selection: clipboard selection.
+ *
+ * Return the current clipboard data & owner informations.
+ */
+QemuClipboardInfo *qemu_clipboard_info(QemuClipboardSelection selection);
+
/**
* qemu_clipboard_info_new
*
diff --git a/ui/clipboard.c b/ui/clipboard.c
index 3525b30178..56c14509fe 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,
--
2.33.0.rc2
- [PULL 00/18] UI/clipboard fixes, marcandre . lureau, 2021/08/31
- [PULL 01/18] ui/vdagent: fix leak on error path, marcandre . lureau, 2021/08/31
- [PULL 02/18] ui/vdagent: remove copy-pasta comment, marcandre . lureau, 2021/08/31
- [PULL 03/18] ui/gtk-clipboard: use existing macros, marcandre . lureau, 2021/08/31
- [PULL 04/18] ui/gtk-clipboard: fix clipboard enum typo, marcandre . lureau, 2021/08/31
- [PULL 05/18] ui/clipboard: add helper to retrieve current clipboard,
marcandre . lureau <=
- [PULL 06/18] ui/clipboard: add qemu_clipboard_peer_owns() helper, marcandre . lureau, 2021/08/31
- [PULL 07/18] ui/clipboard: add qemu_clipboard_peer_release() helper, marcandre . lureau, 2021/08/31
- [PULL 08/18] ui/clipboard: release owned grabs on unregister, marcandre . lureau, 2021/08/31
- [PULL 09/18] ui/vdagent: disconnect handlers and reset state on finalize, marcandre . lureau, 2021/08/31
- [PULL 10/18] ui/vdagent: reset outbuf on disconnect, marcandre . lureau, 2021/08/31
- [PULL 11/18] ui/vdagent: split clipboard recv message handling, marcandre . lureau, 2021/08/31
- [PULL 12/18] ui/vdagent: use qemu_clipboard_peer_release helper, marcandre . lureau, 2021/08/31
- [PULL 13/18] ui/vdagent: use qemu_clipboard_info helper, marcandre . lureau, 2021/08/31
- [PULL 14/18] ui/vdagent: send empty clipboard when unhandled, marcandre . lureau, 2021/08/31
- [PULL 15/18] ui/gtk-clipboard: use qemu_clipboard_info helper, marcandre . lureau, 2021/08/31