|
|
18559f |
From 1d349aa519571199d10d38b0a0e2f91b051ab3c8 Mon Sep 17 00:00:00 2001
|
|
|
18559f |
From: Victor Toso <me@victortoso.com>
|
|
|
18559f |
Date: Fri, 24 Feb 2017 14:12:45 +0100
|
|
|
18559f |
Subject: [PATCH spice-gtk 2/2] gtk-session: always reply to agent's clipboard
|
|
|
18559f |
request
|
|
|
18559f |
To: spice-devel@lists.freedesktop.org
|
|
|
18559f |
|
|
|
18559f |
This fixes a regression from 7b0de6217670e0f668aff2949f
|
|
|
18559f |
|
|
|
18559f |
We need to reply back to the agent all clipboard requests even in case
|
|
|
18559f |
of failure otherwise it will have a pending request. The following
|
|
|
18559f |
error message can be seen afterwards, in the linux agent, when client
|
|
|
18559f |
sends down some clipboard data:
|
|
|
18559f |
|
|
|
18559f |
> clipboard: selection requests pending on clipboard ownership
|
|
|
18559f |
> change, clearing
|
|
|
18559f |
|
|
|
18559f |
An easy way to reproduce this is:
|
|
|
18559f |
1-) In client, copy image from lo-draw (selection or ctrl+c)
|
|
|
18559f |
2-) In guest, paste it to GEdit (mouse3 our ctrl+v)
|
|
|
18559f |
3-) Move to the client
|
|
|
18559f |
4-) Move back to the guest
|
|
|
18559f |
5-) see error on vdagent logs
|
|
|
18559f |
|
|
|
18559f |
The reason for failure is that client's clipboard contains different
|
|
|
18559f |
data type (image) then what was requested from guest's editor (text)
|
|
|
18559f |
|
|
|
18559f |
While at it, include extra debug message as it might be hard to
|
|
|
18559f |
identify why clipboard did not work.
|
|
|
18559f |
|
|
|
18559f |
Resolves: rhbz#1409854
|
|
|
18559f |
Signed-off-by: Victor Toso <victortoso@redhat.com>
|
|
|
18559f |
Acked-by: Pavel Grunt <pgrunt@redhat.com>
|
|
|
18559f |
(cherry picked from commit 172c521271a3dc6d9ed0c297406c2fa29266682d)
|
|
|
18559f |
---
|
|
|
18559f |
src/spice-gtk-session.c | 21 +++++++++++++--------
|
|
|
18559f |
1 file changed, 13 insertions(+), 8 deletions(-)
|
|
|
18559f |
|
|
|
18559f |
diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c
|
|
|
18559f |
index 6424596..c0a46e8 100644
|
|
|
18559f |
--- a/src/spice-gtk-session.c
|
|
|
18559f |
+++ b/src/spice-gtk-session.c
|
|
|
18559f |
@@ -931,35 +931,40 @@ static void clipboard_received_text_cb(GtkClipboard *clipboard,
|
|
|
18559f |
char *conv = NULL;
|
|
|
18559f |
int len = 0;
|
|
|
18559f |
int selection;
|
|
|
18559f |
+ const guchar *data = NULL;
|
|
|
18559f |
|
|
|
18559f |
if (self == NULL)
|
|
|
18559f |
return;
|
|
|
18559f |
|
|
|
18559f |
+ selection = get_selection_from_clipboard(self->priv, clipboard);
|
|
|
18559f |
+ g_return_if_fail(selection != -1);
|
|
|
18559f |
+
|
|
|
18559f |
if (text == NULL) {
|
|
|
18559f |
SPICE_DEBUG("Failed to retrieve clipboard text");
|
|
|
18559f |
- return;
|
|
|
18559f |
+ goto notify_agent;
|
|
|
18559f |
}
|
|
|
18559f |
|
|
|
18559f |
g_return_if_fail(SPICE_IS_GTK_SESSION(self));
|
|
|
18559f |
|
|
|
18559f |
- selection = get_selection_from_clipboard(self->priv, clipboard);
|
|
|
18559f |
- g_return_if_fail(selection != -1);
|
|
|
18559f |
-
|
|
|
18559f |
len = strlen(text);
|
|
|
18559f |
if (!check_clipboard_size_limits(self, len)) {
|
|
|
18559f |
- return;
|
|
|
18559f |
+ SPICE_DEBUG("Failed size limits of clipboard text (%d bytes)", len);
|
|
|
18559f |
+ goto notify_agent;
|
|
|
18559f |
}
|
|
|
18559f |
|
|
|
18559f |
/* gtk+ internal utf8 newline is always LF, even on windows */
|
|
|
18559f |
conv = fixup_clipboard_text(self, text, &len;;
|
|
|
18559f |
if (!check_clipboard_size_limits(self, len)) {
|
|
|
18559f |
- g_free(conv);
|
|
|
18559f |
- return;
|
|
|
18559f |
+ SPICE_DEBUG("Failed size limits of clipboard text (%d bytes)", len);
|
|
|
18559f |
+ goto notify_agent;
|
|
|
18559f |
}
|
|
|
18559f |
|
|
|
18559f |
+ data = (const guchar *) (conv != NULL ? conv : text);
|
|
|
18559f |
+notify_agent:
|
|
|
18559f |
spice_main_clipboard_selection_notify(self->priv->main, selection,
|
|
|
18559f |
VD_AGENT_CLIPBOARD_UTF8_TEXT,
|
|
|
18559f |
- (guchar *)(conv ?: text), len);
|
|
|
18559f |
+ data,
|
|
|
18559f |
+ (data != NULL) ? len : 0);
|
|
|
18559f |
g_free(conv);
|
|
|
18559f |
}
|
|
|
18559f |
|
|
|
18559f |
--
|
|
|
18559f |
2.12.0
|
|
|
18559f |
|