qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v3 07/18] ui/clipboard: add qemu_clipboard_peer_release() helper


From: marcandre . lureau
Subject: [PATCH v3 07/18] ui/clipboard: add qemu_clipboard_peer_release() helper
Date: Thu, 5 Aug 2021 17:57:04 +0400

From: Marc-André Lureau <marcandre.lureau@redhat.com>

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/ui/clipboard.h | 11 +++++++++++
 ui/clipboard.c         | 12 ++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/include/ui/clipboard.h b/include/ui/clipboard.h
index 25e0b470c8..6298986b15 100644
--- a/include/ui/clipboard.h
+++ b/include/ui/clipboard.h
@@ -120,6 +120,17 @@ void qemu_clipboard_peer_unregister(QemuClipboardPeer 
*peer);
 bool qemu_clipboard_peer_owns(QemuClipboardPeer *peer,
                               QemuClipboardSelection selection);
 
+/**
+ * qemu_clipboard_peer_release
+ *
+ * @peer: peer information.
+ * @selection: clipboard selection.
+ *
+ * If the peer owns the clipboard, release it.
+ */
+void qemu_clipboard_peer_release(QemuClipboardPeer *peer,
+                                 QemuClipboardSelection selection);
+
 /**
  * qemu_clipboard_info
  *
diff --git a/ui/clipboard.c b/ui/clipboard.c
index 490c3220f4..c277247a7f 100644
--- a/ui/clipboard.c
+++ b/ui/clipboard.c
@@ -24,6 +24,18 @@ bool qemu_clipboard_peer_owns(QemuClipboardPeer *peer,
     return info && info->owner == peer;
 }
 
+void qemu_clipboard_peer_release(QemuClipboardPeer *peer,
+                                 QemuClipboardSelection selection)
+{
+    g_autoptr(QemuClipboardInfo) info = NULL;
+
+    if (qemu_clipboard_peer_owns(peer, selection)) {
+        /* set empty clipboard info */
+        info = qemu_clipboard_info_new(NULL, selection);
+        qemu_clipboard_update(info);
+    }
+}
+
 void qemu_clipboard_update(QemuClipboardInfo *info)
 {
     g_autoptr(QemuClipboardInfo) old = NULL;
-- 
2.32.0.264.g75ae10bc75




reply via email to

[Prev in Thread] Current Thread [Next in Thread]