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>,
	"Gerd Hoffmann" <kraxel@redhat.com>
Subject: [PATCH 11/12] ui/vdagent: send release when no clipboard owner
Date: Mon, 19 Jul 2021 11:26:53 +0400	[thread overview]
Message-ID: <20210719072654.845901-12-marcandre.lureau@redhat.com> (raw)
In-Reply-To: <20210719072654.845901-1-marcandre.lureau@redhat.com>

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

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 ui/vdagent.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/ui/vdagent.c b/ui/vdagent.c
index 65c9663e0d..34e1c332ee 100644
--- a/ui/vdagent.c
+++ b/ui/vdagent.c
@@ -345,6 +345,24 @@ static void vdagent_send_clipboard_grab(VDAgentChardev *vd,
     vdagent_send_msg(vd, msg);
 }
 
+static void vdagent_send_clipboard_release(VDAgentChardev *vd,
+                                           QemuClipboardInfo *info)
+{
+    g_autofree VDAgentMessage *msg = g_malloc0(sizeof(VDAgentMessage) +
+                                               sizeof(uint32_t));
+
+    if (have_selection(vd)) {
+        uint8_t *s = msg->data;
+        *s = info->selection;
+        msg->size += sizeof(uint32_t);
+    } else if (info->selection != QEMU_CLIPBOARD_SELECTION_CLIPBOARD) {
+        return;
+    }
+
+    msg->type = VD_AGENT_CLIPBOARD_RELEASE;
+    vdagent_send_msg(vd, msg);
+}
+
 static void vdagent_send_clipboard_data(VDAgentChardev *vd,
                                         QemuClipboardInfo *info,
                                         QemuClipboardType type)
@@ -386,7 +404,11 @@ static void vdagent_clipboard_notify(Notifier *notifier, void *data)
     if (info != qemu_clipboard_info(s)) {
         vd->cbpending[s] = 0;
         if (!self_update) {
-            vdagent_send_clipboard_grab(vd, info);
+            if (info->owner) {
+                vdagent_send_clipboard_grab(vd, info);
+            } else {
+                vdagent_send_clipboard_release(vd, info);
+            }
         }
         return;
     }
-- 
2.32.0.93.g670b81a890



  parent reply	other threads:[~2021-07-19  7:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-19  7:26 [PATCH 00/12] Clipboard fixes (for 6.1?) marcandre.lureau
2021-07-19  7:26 ` [PATCH 01/12] ui/vdagent: fix leak on error path marcandre.lureau
2021-07-19  7:26 ` [PATCH 02/12] ui/vdagent: remove copy-pasta comment marcandre.lureau
2021-07-19  7:26 ` [PATCH 03/12] ui/gtk-clipboard: use existing macros marcandre.lureau
2021-07-19  9:13   ` Philippe Mathieu-Daudé
2021-07-19  7:26 ` [PATCH 04/12] ui/gtk-clipboard: fix clipboard enum typo marcandre.lureau
2021-07-19  7:26 ` [PATCH 05/12] ui/clipboard: add helper to retrieve current clipboard marcandre.lureau
2021-07-19  7:26 ` [PATCH 06/12] ui/clipboard: release owned grabs on unregister marcandre.lureau
2021-07-19  7:26 ` [PATCH 07/12] ui/vdagent: unregister clipboard peer on finalize marcandre.lureau
2021-07-21  8:24   ` Marc-André Lureau
2021-07-19  7:26 ` [PATCH 08/12] ui/vdagent: split clipboard recv message handling marcandre.lureau
2021-07-19  7:26 ` [PATCH 09/12] ui/vdagent: use qemu_clipboard_info helper marcandre.lureau
2021-07-19  7:26 ` [PATCH 10/12] ui/gtk-clipboard: " marcandre.lureau
2021-07-19  7:26 ` marcandre.lureau [this message]
2021-07-19  7:26 ` [PATCH 12/12] ui/gtk-clipboard: emit release clipboard events marcandre.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=20210719072654.845901-12-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.