]> git.proxmox.com Git - mirror_qemu.git/commitdiff
ui/clipboard: add qemu_clipboard_check_serial()
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Wed, 21 Jul 2021 11:19:13 +0000 (15:19 +0400)
committerMarc-André Lureau <marcandre.lureau@redhat.com>
Tue, 21 Dec 2021 06:50:21 +0000 (10:50 +0400)
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
include/ui/clipboard.h
ui/clipboard.c

index e590b453c8b7d10a5372e9c1be0a1ede5d510c89..2c6488c1eec87726f806020e971c64441af717ae 100644 (file)
@@ -172,6 +172,16 @@ void qemu_clipboard_peer_release(QemuClipboardPeer *peer,
  */
 QemuClipboardInfo *qemu_clipboard_info(QemuClipboardSelection selection);
 
+/**
+ * qemu_clipboard_check_serial
+ *
+ * @info: clipboard info.
+ * @client: whether to check from the client context and priority.
+ *
+ * Return TRUE if the @info has a higher serial than the current clipboard.
+ */
+bool qemu_clipboard_check_serial(QemuClipboardInfo *info, bool client);
+
 /**
  * qemu_clipboard_info_new
  *
index 743b39edf4247c39383be6935e3c0d76654a4a97..ffbd80e5c60eca83e7738dd6501460a47a81c185 100644 (file)
@@ -41,6 +41,21 @@ void qemu_clipboard_peer_release(QemuClipboardPeer *peer,
     }
 }
 
+bool qemu_clipboard_check_serial(QemuClipboardInfo *info, bool client)
+{
+    if (!info->has_serial ||
+        !cbinfo[info->selection] ||
+        !cbinfo[info->selection]->has_serial) {
+        return true;
+    }
+
+    if (client) {
+        return cbinfo[info->selection]->serial >= info->serial;
+    } else {
+        return cbinfo[info->selection]->serial > info->serial;
+    }
+}
+
 void qemu_clipboard_update(QemuClipboardInfo *info)
 {
     QemuClipboardNotify notify = {