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>
master
Marc-André Lureau 2021-08-05 17:57:04 +04:00
parent 482bbaf477
commit 1387865eca
2 changed files with 23 additions and 0 deletions

View File

@ -120,6 +120,17 @@ void qemu_clipboard_peer_unregister(QemuClipboardPeer *peer);
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
*

View File

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