All of lore.kernel.org
 help / color / mirror / Atom feed
From: marcandre.lureau@redhat.com
To: qemu-devel@nongnu.org
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>, kraxel@redhat.com
Subject: [PATCH v2 05/13] ui/clipboard: add helper to retrieve current clipboard
Date: Wed, 21 Jul 2021 12:41:31 +0400	[thread overview]
Message-ID: <20210721084139.1124779-6-marcandre.lureau@redhat.com> (raw)
In-Reply-To: <20210721084139.1124779-1-marcandre.lureau@redhat.com>

From: Marc-André Lureau <marcandre.lureau@redhat.com>

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/ui/clipboard.h |  9 +++++++++
 ui/clipboard.c         | 15 +++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/include/ui/clipboard.h b/include/ui/clipboard.h
index eb789a285a..e9fcb15c66 100644
--- a/include/ui/clipboard.h
+++ b/include/ui/clipboard.h
@@ -109,6 +109,15 @@ void qemu_clipboard_peer_register(QemuClipboardPeer *peer);
  */
 void qemu_clipboard_peer_unregister(QemuClipboardPeer *peer);
 
+/**
+ * qemu_clipboard_info
+ *
+ * @selection: clipboard selection.
+ *
+ * Return the current clipboard data & owner informations.
+ */
+QemuClipboardInfo *qemu_clipboard_info(QemuClipboardSelection selection);
+
 /**
  * qemu_clipboard_info_new
  *
diff --git a/ui/clipboard.c b/ui/clipboard.c
index 3525b30178..56c14509fe 100644
--- a/ui/clipboard.c
+++ b/ui/clipboard.c
@@ -4,6 +4,8 @@
 static NotifierList clipboard_notifiers =
     NOTIFIER_LIST_INITIALIZER(clipboard_notifiers);
 
+static QemuClipboardInfo *cbinfo[QEMU_CLIPBOARD_SELECTION__COUNT];
+
 void qemu_clipboard_peer_register(QemuClipboardPeer *peer)
 {
     notifier_list_add(&clipboard_notifiers, &peer->update);
@@ -16,7 +18,20 @@ void qemu_clipboard_peer_unregister(QemuClipboardPeer *peer)
 
 void qemu_clipboard_update(QemuClipboardInfo *info)
 {
+    g_autoptr(QemuClipboardInfo) old = NULL;
+    assert(info->selection < QEMU_CLIPBOARD_SELECTION__COUNT);
+
     notifier_list_notify(&clipboard_notifiers, info);
+
+    old = cbinfo[info->selection];
+    cbinfo[info->selection] = qemu_clipboard_info_ref(info);
+}
+
+QemuClipboardInfo *qemu_clipboard_info(QemuClipboardSelection selection)
+{
+    assert(selection < QEMU_CLIPBOARD_SELECTION__COUNT);
+
+    return cbinfo[selection];
 }
 
 QemuClipboardInfo *qemu_clipboard_info_new(QemuClipboardPeer *owner,
-- 
2.32.0.264.g75ae10bc75



  parent reply	other threads:[~2021-07-21  8:43 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-21  8:41 [PATCH v2 00/13] Clipboard fixes (for 6.1?) marcandre.lureau
2021-07-21  8:41 ` [PATCH v2 01/13] ui/vdagent: fix leak on error path marcandre.lureau
2021-07-21  8:41 ` [PATCH v2 02/13] ui/vdagent: remove copy-pasta comment marcandre.lureau
2021-07-21  8:41 ` [PATCH v2 03/13] ui/gtk-clipboard: use existing macros marcandre.lureau
2021-07-21  8:41 ` [PATCH v2 04/13] ui/gtk-clipboard: fix clipboard enum typo marcandre.lureau
2021-07-21  8:41 ` marcandre.lureau [this message]
2021-07-21  8:41 ` [PATCH v2 06/13] ui/clipboard: release owned grabs on unregister marcandre.lureau
2021-07-21  8:41 ` [PATCH v2 07/13] ui/vdagent: disconnect handlers and reset state on finalize marcandre.lureau
2021-07-21  8:41 ` [PATCH v2 08/13] ui/vdagent: reset outbuf on disconnect marcandre.lureau
2021-07-21  8:41 ` [PATCH v2 09/13] ui/vdagent: split clipboard recv message handling marcandre.lureau
2021-07-21  8:41 ` [PATCH v2 10/13] ui/vdagent: use qemu_clipboard_info helper marcandre.lureau
2021-07-21  8:41 ` [PATCH v2 11/13] ui/gtk-clipboard: " marcandre.lureau
2021-07-21  8:41 ` [PATCH v2 12/13] ui/vdagent: send release when no clipboard owner marcandre.lureau
2021-07-21  8:41 ` [PATCH v2 13/13] ui/gtk-clipboard: emit release clipboard events marcandre.lureau
2021-07-21 11:38 ` [PATCH v2 00/13] Clipboard fixes (for 6.1?) Marc-André Lureau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210721084139.1124779-6-marcandre.lureau@redhat.com \
    --to=marcandre.lureau@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.