[Spice-devel] [PATCH linux/vd-agent 09/11] clipboard: filter out only our own events
marcandre.lureau at redhat.com
marcandre.lureau at redhat.com
Fri Mar 22 15:12:44 UTC 2019
From: Marc-André Lureau <marcandre.lureau at redhat.com>
Do not rely on internal state when receiving clipboard events, as this
may race with external events. Use gtk_clipboard_set_with_owner()
Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
---
src/vdagent/clipboard.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/vdagent/clipboard.c b/src/vdagent/clipboard.c
index cf6e344..9fb87e3 100644
--- a/src/vdagent/clipboard.c
+++ b/src/vdagent/clipboard.c
@@ -238,8 +238,9 @@ static void clipboard_owner_change_cb(GtkClipboard *clipboard,
Selection *sel = &c->selections[sel_id];
/* if the event was caused by gtk_clipboard_set_with_data(), ignore it */
- if (sel->owner == OWNER_CLIENT)
+ if (gtk_clipboard_get_owner(clipboard) == G_OBJECT(c)) {
return;
+ }
if (sel->owner == OWNER_GUEST) {
clipboard_new_owner(c, sel_id, OWNER_NONE);
@@ -357,9 +358,10 @@ void vdagent_clipboard_grab(VDAgentClipboards *c, guint sel_id,
g_clear_pointer(&sel->last_targets_req, request_ref_cancel);
}
- if (gtk_clipboard_set_with_data(sel->clipboard,
- targets, n_targets,
- clipboard_get_cb, clipboard_clear_cb, c))
+ if (gtk_clipboard_set_with_owner(sel->clipboard,
+ targets, n_targets,
+ clipboard_get_cb, clipboard_clear_cb,
+ G_OBJECT(c)))
clipboard_new_owner(c, sel_id, OWNER_CLIENT);
else {
syslog(LOG_ERR, "%s: sel_id=%u: clipboard grab failed", __func__, sel_id);
--
2.21.0.4.g36eb1cb9cf
More information about the Spice-devel
mailing list