Skip to content

Commit

Permalink
ui/clipboard: add qemu_clipboard_peer_owns() helper
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
elmarco committed Aug 31, 2021
1 parent 684e64d commit 482bbaf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
11 changes: 11 additions & 0 deletions include/ui/clipboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
8 changes: 8 additions & 0 deletions ui/clipboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 482bbaf

Please sign in to comment.