From 482bbaf4776d223971ec68ddd4d31d8861d31f1c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marc-Andr=C3=A9=20Lureau?= Date: Thu, 5 Aug 2021 17:57:03 +0400 Subject: [PATCH] ui/clipboard: add qemu_clipboard_peer_owns() helper MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Marc-André Lureau Message-Id: <20210805135715.857938-7-marcandre.lureau@redhat.com> Acked-by: Gerd Hoffmann --- include/ui/clipboard.h | 11 +++++++++++ ui/clipboard.c | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/include/ui/clipboard.h b/include/ui/clipboard.h index e9fcb15c66..25e0b470c8 100644 --- a/include/ui/clipboard.h +++ b/include/ui/clipboard.h @@ -110,6 +110,17 @@ void qemu_clipboard_peer_register(QemuClipboardPeer *peer); void qemu_clipboard_peer_unregister(QemuClipboardPeer *peer); /** + * qemu_clipboard_peer_owns + * + * @peer: peer information. + * @selection: clipboard selection. + * + * Return TRUE if the peer owns the clipboard. + */ +bool qemu_clipboard_peer_owns(QemuClipboardPeer *peer, + QemuClipboardSelection selection); + +/** * qemu_clipboard_info * * @selection: clipboard selection. diff --git a/ui/clipboard.c b/ui/clipboard.c index 56c14509fe..490c3220f4 100644 --- a/ui/clipboard.c +++ b/ui/clipboard.c @@ -16,6 +16,14 @@ void qemu_clipboard_peer_unregister(QemuClipboardPeer *peer) notifier_remove(&peer->update); } +bool qemu_clipboard_peer_owns(QemuClipboardPeer *peer, + QemuClipboardSelection selection) +{ + QemuClipboardInfo *info = qemu_clipboard_info(selection); + + return info && info->owner == peer; +} + void qemu_clipboard_update(QemuClipboardInfo *info) { g_autoptr(QemuClipboardInfo) old = NULL; -- 2.11.4.GIT