[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 11/13] ui/gtk-clipboard: use qemu_clipboard_info helper
From: |
marcandre . lureau |
Subject: |
[PATCH v2 11/13] ui/gtk-clipboard: use qemu_clipboard_info helper |
Date: |
Wed, 21 Jul 2021 12:41:37 +0400 |
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
- [PATCH v2 00/13] Clipboard fixes (for 6.1?), marcandre . lureau, 2021/07/21
- [PATCH v2 01/13] ui/vdagent: fix leak on error path, marcandre . lureau, 2021/07/21
- [PATCH v2 03/13] ui/gtk-clipboard: use existing macros, marcandre . lureau, 2021/07/21
- [PATCH v2 02/13] ui/vdagent: remove copy-pasta comment, marcandre . lureau, 2021/07/21
- [PATCH v2 04/13] ui/gtk-clipboard: fix clipboard enum typo, marcandre . lureau, 2021/07/21
- [PATCH v2 05/13] ui/clipboard: add helper to retrieve current clipboard, marcandre . lureau, 2021/07/21
- [PATCH v2 06/13] ui/clipboard: release owned grabs on unregister, marcandre . lureau, 2021/07/21
- [PATCH v2 09/13] ui/vdagent: split clipboard recv message handling, marcandre . lureau, 2021/07/21
- [PATCH v2 10/13] ui/vdagent: use qemu_clipboard_info helper, marcandre . lureau, 2021/07/21
- [PATCH v2 11/13] ui/gtk-clipboard: use qemu_clipboard_info helper,
marcandre . lureau <=
- [PATCH v2 12/13] ui/vdagent: send release when no clipboard owner, marcandre . lureau, 2021/07/21
- [PATCH v2 13/13] ui/gtk-clipboard: emit release clipboard events, marcandre . lureau, 2021/07/21
- [PATCH v2 07/13] ui/vdagent: disconnect handlers and reset state on finalize, marcandre . lureau, 2021/07/21
- [PATCH v2 08/13] ui/vdagent: reset outbuf on disconnect, marcandre . lureau, 2021/07/21
- Re: [PATCH v2 00/13] Clipboard fixes (for 6.1?), Marc-André Lureau, 2021/07/21