ui/clipboard: add qemu_clipboard_peer_owns() helper

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20210805135715.857938-7-marcandre.lureau@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
Marc-André Lureau 2021-08-05 17:57:03 +04:00
parent 684e64d36d
commit 482bbaf477
2 changed files with 19 additions and 0 deletions

View File

@ -109,6 +109,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
*

View File

@ -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;