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 v3 13/18] ui/vdagent: use qemu_clipboard_info helper
Date: Thu, 5 Aug 2021 17:57:10 +0400 [thread overview]
Message-ID: <20210805135715.857938-14-marcandre.lureau@redhat.com> (raw)
In-Reply-To: <20210805135715.857938-1-marcandre.lureau@redhat.com>
From: Marc-André Lureau <marcandre.lureau@redhat.com>
The clipboard unit now tracks the current clipboard grab, no need to
duplicate this work.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/vdagent.c | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/ui/vdagent.c b/ui/vdagent.c
index 99ba34646f..cd07937a4b 100644
--- a/ui/vdagent.c
+++ b/ui/vdagent.c
@@ -47,7 +47,6 @@ struct VDAgentChardev {
/* clipboard */
QemuClipboardPeer cbpeer;
- QemuClipboardInfo *cbinfo[QEMU_CLIPBOARD_SELECTION__COUNT];
uint32_t cbpending[QEMU_CLIPBOARD_SELECTION__COUNT];
};
typedef struct VDAgentChardev VDAgentChardev;
@@ -384,9 +383,7 @@ static void vdagent_clipboard_notify(Notifier *notifier, void *data)
QemuClipboardType type;
bool self_update = info->owner == &vd->cbpeer;
- if (info != vd->cbinfo[s]) {
- qemu_clipboard_info_unref(vd->cbinfo[s]);
- vd->cbinfo[s] = qemu_clipboard_info_ref(info);
+ if (info != qemu_clipboard_info(s)) {
vd->cbpending[s] = 0;
if (!self_update) {
vdagent_send_clipboard_grab(vd, info);
@@ -464,6 +461,7 @@ static void vdagent_clipboard_recv_grab(VDAgentChardev *vd, uint8_t s, uint32_t
static void vdagent_clipboard_recv_request(VDAgentChardev *vd, uint8_t s, uint32_t size, void *data)
{
QemuClipboardType type;
+ QemuClipboardInfo *info;
if (size < sizeof(uint32_t)) {
return;
@@ -475,13 +473,14 @@ static void vdagent_clipboard_recv_request(VDAgentChardev *vd, uint8_t s, uint32
default:
return;
}
- if (vd->cbinfo[s] && vd->cbinfo[s]->types[type].available &&
- vd->cbinfo[s]->owner != &vd->cbpeer) {
- if (vd->cbinfo[s]->types[type].data) {
- vdagent_send_clipboard_data(vd, vd->cbinfo[s], type);
+
+ info = qemu_clipboard_info(s);
+ if (info && info->types[type].available && info->owner != &vd->cbpeer) {
+ if (info->types[type].data) {
+ vdagent_send_clipboard_data(vd, info, type);
} else {
vd->cbpending[s] |= (1 << type);
- qemu_clipboard_request(vd->cbinfo[s], type);
+ qemu_clipboard_request(info, type);
}
}
}
@@ -502,7 +501,11 @@ static void vdagent_clipboard_recv_data(VDAgentChardev *vd, uint8_t s, uint32_t
}
data += 4;
size -= 4;
- qemu_clipboard_set_data(&vd->cbpeer, vd->cbinfo[s], type, size, data, true);
+
+ if (qemu_clipboard_peer_owns(&vd->cbpeer, s)) {
+ qemu_clipboard_set_data(&vd->cbpeer, qemu_clipboard_info(s),
+ type, size, data, true);
+ }
}
static void vdagent_clipboard_recv_release(VDAgentChardev *vd, uint8_t s)
--
2.32.0.264.g75ae10bc75
next prev parent reply other threads:[~2021-08-05 14:11 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-05 13:56 [PATCH v3 00/18] Clipboard fixes (for 6.1?) marcandre.lureau
2021-08-05 13:56 ` [PATCH v3 01/18] ui/vdagent: fix leak on error path marcandre.lureau
2021-08-27 13:29 ` Philippe Mathieu-Daudé
2021-08-05 13:56 ` [PATCH v3 02/18] ui/vdagent: remove copy-pasta comment marcandre.lureau
2021-08-05 13:57 ` [PATCH v3 03/18] ui/gtk-clipboard: use existing macros marcandre.lureau
2021-08-05 13:57 ` [PATCH v3 04/18] ui/gtk-clipboard: fix clipboard enum typo marcandre.lureau
2021-08-05 13:57 ` [PATCH v3 05/18] ui/clipboard: add helper to retrieve current clipboard marcandre.lureau
2021-08-05 13:57 ` [PATCH v3 06/18] ui/clipboard: add qemu_clipboard_peer_owns() helper marcandre.lureau
2021-08-05 13:57 ` [PATCH v3 07/18] ui/clipboard: add qemu_clipboard_peer_release() helper marcandre.lureau
2021-08-05 13:57 ` [PATCH v3 08/18] ui/clipboard: release owned grabs on unregister marcandre.lureau
2021-08-05 13:57 ` [PATCH v3 09/18] ui/vdagent: disconnect handlers and reset state on finalize marcandre.lureau
2021-08-27 13:33 ` Philippe Mathieu-Daudé
2021-08-05 13:57 ` [PATCH v3 10/18] ui/vdagent: reset outbuf on disconnect marcandre.lureau
2021-08-05 13:57 ` [PATCH v3 11/18] ui/vdagent: split clipboard recv message handling marcandre.lureau
2021-08-05 13:57 ` [PATCH v3 12/18] ui/vdagent: use qemu_clipboard_peer_release helper marcandre.lureau
2021-08-05 13:57 ` marcandre.lureau [this message]
2021-08-05 13:57 ` [PATCH v3 14/18] ui/vdagent: send empty clipboard when unhandled marcandre.lureau
2021-08-05 13:57 ` [PATCH v3 15/18] ui/gtk-clipboard: use qemu_clipboard_info helper marcandre.lureau
2021-08-05 13:57 ` [PATCH v3 16/18] ui/vdagent: send release when no clipboard owner marcandre.lureau
2021-08-05 13:57 ` [PATCH v3 17/18] ui/gtk-clipboard: emit release clipboard events marcandre.lureau
2021-08-05 13:57 ` [PATCH v3 18/18] ui/vdagent: add a migration blocker marcandre.lureau
2021-08-05 14:57 ` Marc-André Lureau
2021-08-27 13:21 ` [PATCH v3 00/18] Clipboard fixes (for 6.1?) Marc-André Lureau
2021-08-31 12:30 ` Gerd Hoffmann
2021-08-31 12:34 ` 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=20210805135715.857938-14-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).