From: marcandre.lureau@redhat.com
To: qemu-devel@nongnu.org
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>, kraxel@redhat.com
Subject: [PATCH v2 11/13] ui/gtk-clipboard: use qemu_clipboard_info helper
Date: Wed, 21 Jul 2021 12:41:37 +0400 [thread overview]
Message-ID: <20210721084139.1124779-12-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/gtk.h | 1 -
ui/gtk-clipboard.c | 14 ++++++--------
2 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/include/ui/gtk.h b/include/ui/gtk.h
index 9516670ebc..60e9cdc39c 100644
--- a/include/ui/gtk.h
+++ b/include/ui/gtk.h
@@ -139,7 +139,6 @@ struct GtkDisplayState {
bool external_pause_update;
QemuClipboardPeer cbpeer;
- QemuClipboardInfo *cbinfo[QEMU_CLIPBOARD_SELECTION__COUNT];
uint32_t cbpending[QEMU_CLIPBOARD_SELECTION__COUNT];
GtkClipboard *gtkcb[QEMU_CLIPBOARD_SELECTION__COUNT];
bool cbowner[QEMU_CLIPBOARD_SELECTION__COUNT];
diff --git a/ui/gtk-clipboard.c b/ui/gtk-clipboard.c
index 2c78de9500..4e4b3c52bb 100644
--- a/ui/gtk-clipboard.c
+++ b/ui/gtk-clipboard.c
@@ -45,24 +45,24 @@ static void gd_clipboard_get_data(GtkClipboard *clipboard,
GtkDisplayState *gd = data;
QemuClipboardSelection s = gd_find_selection(gd, clipboard);
QemuClipboardType type = QEMU_CLIPBOARD_TYPE_TEXT;
- QemuClipboardInfo *info = qemu_clipboard_info_ref(gd->cbinfo[s]);
+ g_autoptr(QemuClipboardInfo) info = NULL;
+
+ info = qemu_clipboard_info_ref(qemu_clipboard_info(s));
qemu_clipboard_request(info, type);
- while (info == gd->cbinfo[s] &&
+ while (info == qemu_clipboard_info(s) &&
info->types[type].available &&
info->types[type].data == NULL) {
main_loop_wait(false);
}
- if (info == gd->cbinfo[s] && gd->cbowner[s]) {
+ if (info == qemu_clipboard_info(s) && gd->cbowner[s]) {
gtk_selection_data_set_text(selection_data,
info->types[type].data,
info->types[type].size);
} else {
/* clipboard owner changed while waiting for the data */
}
-
- qemu_clipboard_info_unref(info);
}
static void gd_clipboard_clear(GtkClipboard *clipboard,
@@ -81,9 +81,7 @@ static void gd_clipboard_notify(Notifier *notifier, void *data)
QemuClipboardSelection s = info->selection;
bool self_update = info->owner == &gd->cbpeer;
- if (info != gd->cbinfo[s]) {
- qemu_clipboard_info_unref(gd->cbinfo[s]);
- gd->cbinfo[s] = qemu_clipboard_info_ref(info);
+ if (info != qemu_clipboard_info(s)) {
gd->cbpending[s] = 0;
if (!self_update) {
GtkTargetList *list;
--
2.32.0.264.g75ae10bc75
next prev parent reply other threads:[~2021-07-21 8:54 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 ` [PATCH v2 05/13] ui/clipboard: add helper to retrieve current clipboard marcandre.lureau
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 ` marcandre.lureau [this message]
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-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 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).