diff options
-rw-r--r-- | include/ui/clipboard.h | 10 | ||||
-rw-r--r-- | ui/clipboard.c | 15 |
2 files changed, 25 insertions, 0 deletions
diff --git a/include/ui/clipboard.h b/include/ui/clipboard.h index e590b45..2c6488c 100644 --- a/include/ui/clipboard.h +++ b/include/ui/clipboard.h @@ -173,6 +173,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 * * @owner: clipboard owner. diff --git a/ui/clipboard.c b/ui/clipboard.c index 743b39e..ffbd80e 100644 --- a/ui/clipboard.c +++ b/ui/clipboard.c @@ -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 = { |