[Spice-devel] [PATCH spice-gtk 1/3] clipboard: do not delay release if agent has "no release on regrab"

marcandre.lureau at redhat.com marcandre.lureau at redhat.com
Fri Mar 22 14:20:12 UTC 2019


From: Marc-André Lureau <marcandre.lureau at redhat.com>

Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
---
 configure.ac            | 2 +-
 meson.build             | 2 +-
 src/channel-main.c      | 2 ++
 src/spice-gtk-session.c | 9 ++++++++-
 4 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index d234822..12159fd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -86,7 +86,7 @@ AC_CHECK_LIBM
 AC_SUBST(LIBM)
 
 AC_CONFIG_SUBDIRS([subprojects/spice-common])
-PKG_CHECK_MODULES([SPICE_PROTOCOL], [spice-protocol >= 0.12.15])
+PKG_CHECK_MODULES([SPICE_PROTOCOL], [spice-protocol >= 0.12.16])
 
 COMMON_CFLAGS='-I${top_builddir}/subprojects/spice-common/ -I${top_srcdir}/subprojects/spice-common/ ${SPICE_PROTOCOL_CFLAGS}'
 AC_SUBST(COMMON_CFLAGS)
diff --git a/meson.build b/meson.build
index e0fba93..3383f26 100644
--- a/meson.build
+++ b/meson.build
@@ -75,7 +75,7 @@ endforeach
 #
 # check for mandatory dependencies
 #
-spice_protocol_version='>= 0.12.15'
+spice_protocol_version='>= 0.12.16'
 
 glib_version = '2.46'
 glib_version_info = '>= @0@'.format(glib_version)
diff --git a/src/channel-main.c b/src/channel-main.c
index 10c31ac..7d4b5c2 100644
--- a/src/channel-main.c
+++ b/src/channel-main.c
@@ -222,6 +222,7 @@ static const char *agent_caps[] = {
     [ VD_AGENT_CAP_AUDIO_VOLUME_SYNC   ] = "volume-sync",
     [ VD_AGENT_CAP_MONITORS_CONFIG_POSITION ] = "monitors config position",
     [ VD_AGENT_CAP_FILE_XFER_DISABLED ] = "file transfer disabled",
+    [ VD_AGENT_CAP_CLIPBOARD_NO_RELEASE_ON_REGRAB ] = "no release on re-grab",
 };
 #define NAME(_a, _i) ((_i) < SPICE_N_ELEMENTS(_a) ? (_a[(_i)] ?: "?") : "?")
 
@@ -1333,6 +1334,7 @@ static void agent_announce_caps(SpiceMainChannel *channel)
     VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_CLIPBOARD_SELECTION);
     VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_MONITORS_CONFIG_POSITION);
     VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_FILE_XFER_DETAILED_ERRORS);
+    VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_CLIPBOARD_NO_RELEASE_ON_REGRAB);
 
     agent_msg_queue(channel, VD_AGENT_ANNOUNCE_CAPABILITIES, size, caps);
     g_free(caps);
diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c
index d73a44b..7a7ebb7 100644
--- a/src/spice-gtk-session.c
+++ b/src/spice-gtk-session.c
@@ -1101,7 +1101,8 @@ static gboolean clipboard_release_timeout(gpointer user_data)
  * sides, client and remote, racing for the clipboard grab, and
  * believing each other is the owner.
  *
- * Workaround this problem by delaying the release event by 0.5 sec.
+ * Workaround this problem by delaying the release event by 0.5 sec,
+ * unless the no-release-on-regrab capability is present.
  * FIXME: protocol change to solve the conflict and set client priority.
  */
 #define CLIPBOARD_RELEASE_DELAY 500 /* ms */
@@ -1119,6 +1120,12 @@ static void clipboard_release_delay(SpiceMainChannel *main, guint selection,
 
     clipboard_release_delay_remove(self, selection, true);
 
+    if (spice_main_channel_agent_test_capability(s->main,
+                                                 VD_AGENT_CAP_CLIPBOARD_NO_RELEASE_ON_REGRAB)) {
+        clipboard_release(self, selection);
+        return;
+    }
+
     rel = g_new0(SpiceGtkClipboardRelease, 1);
     rel->self = self;
     rel->selection = selection;
-- 
2.21.0.4.g36eb1cb9cf



More information about the Spice-devel mailing list