diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2021-08-05 17:57:04 +0400 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2021-08-31 17:25:14 +0400 |
commit | 1387865eca16984fc6d57702ac9e999527681b22 (patch) | |
tree | 20ff9afc790becdedd001ec16c5db4cb5827b39b | |
parent | 482bbaf4776d223971ec68ddd4d31d8861d31f1c (diff) | |
download | qemu-1387865eca16984fc6d57702ac9e999527681b22.zip qemu-1387865eca16984fc6d57702ac9e999527681b22.tar.gz qemu-1387865eca16984fc6d57702ac9e999527681b22.tar.bz2 |
ui/clipboard: add qemu_clipboard_peer_release() helper
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20210805135715.857938-8-marcandre.lureau@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
-rw-r--r-- | include/ui/clipboard.h | 11 | ||||
-rw-r--r-- | ui/clipboard.c | 12 |
2 files changed, 23 insertions, 0 deletions
diff --git a/include/ui/clipboard.h b/include/ui/clipboard.h index 25e0b47..6298986 100644 --- a/include/ui/clipboard.h +++ b/include/ui/clipboard.h @@ -121,6 +121,17 @@ 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 * * @selection: clipboard selection. diff --git a/ui/clipboard.c b/ui/clipboard.c index 490c322..c277247 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; |