[PATCH linux/vd-agent 09/11] clipboard: filter out only our own events

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

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@xxxxxxxxxx>
---
 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

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]