I'm back with my next question regarding clipboard integration with Spice (and vdagent). For Guacamole, I've managed to get the Spice callbacks working to the point where data copied within the guest is available to the Guacamole Client. Now I'm trying to get it to work the other way around, where data copied on the client side is sent through to the Spice server, more specifically to vdagent running within the Spice session.
As a quick recap, I'm running CentOS Stream 8, and using the Xspice script to launch a Spice server (xorg spice qxl) that I can use for developing Guacamole's Spice protocol support. Within this X session I'm running the Xfce window/session manager, and I'm launching both spice-vdagentd and spice-vdagent within this session to get support for things like clipboard synchronization.
While the outbound (Spice -> Client) clipboard works fine, something is not working correctly getting the clipboard data to go the other direction (Client -> Spice).The code is here:
with the clipboard-specific functions, here:
Essentially what I'm doing when clipboard data is available on the client side is calling the spice_main_channel_clipboard_selection_grab() function to let the Spice server/vdagent know that clipboard data is available:
--
guac_client_log(user->client, GUAC_LOG_DEBUG, "Calling SPICE clipboard handler for MIME type: %s", mimetype);
guac_common_clipboard_reset(spice_client->clipboard, mimetype);
guint32 clipboard_types[] = { VD_AGENT_CLIPBOARD_UTF8_TEXT };
spice_main_channel_clipboard_selection_grab(spice_client->main_channel, VD_AGENT_CLIPBOARD_SELECTION_CLIPBOARD, clipboard_types, 1);
guac_common_clipboard_reset(spice_client->clipboard, mimetype);
guint32 clipboard_types[] = { VD_AGENT_CLIPBOARD_UTF8_TEXT };
spice_main_channel_clipboard_selection_grab(spice_client->main_channel, VD_AGENT_CLIPBOARD_SELECTION_CLIPBOARD, clipboard_types, 1);
--
Then, once the clipboard is settled on the client side, I call guac_main_channel_clipboard_selection_notify() to send the data along, followed by guac_main_channel_clipboard_selection_release() to release the previously-called grab:
--
/* Send via VNC only if finished connecting */
if (spice_client->main_channel != NULL) {
spice_main_channel_clipboard_selection_notify(spice_client->main_channel,
VD_AGENT_CLIPBOARD_SELECTION_CLIPBOARD,
VD_AGENT_CLIPBOARD_UTF8_TEXT,
(const unsigned char*) input,
spice_client->clipboard->length);
spice_main_channel_clipboard_selection_release(spice_client->main_channel,
VD_AGENT_CLIPBOARD_SELECTION_CLIPBOARD);
}
if (spice_client->main_channel != NULL) {
spice_main_channel_clipboard_selection_notify(spice_client->main_channel,
VD_AGENT_CLIPBOARD_SELECTION_CLIPBOARD,
VD_AGENT_CLIPBOARD_UTF8_TEXT,
(const unsigned char*) input,
spice_client->clipboard->length);
spice_main_channel_clipboard_selection_release(spice_client->main_channel,
VD_AGENT_CLIPBOARD_SELECTION_CLIPBOARD);
}
--
In the vdagent debug logs, I see the following:
spice-vdagentd: 0x55d56f3455e0 sent clipboard grab, arg1: 0, arg2: 0, size 4
spice-vdagentd: 0x55d56f3455e0 sent clipboard data, arg1: 0, arg2: 1, size 14
spice-vdagentd: 0x55d56f3455e0 sent clipboard release, arg1: 0, arg2: 0, size 0
spice-vdagentd: 0x55d56f3455e0 sent clipboard data, arg1: 0, arg2: 1, size 14
spice-vdagentd: 0x55d56f3455e0 sent clipboard release, arg1: 0, arg2: 0, size 0
The problem is that the clipboard within my window manager (Xfce) never receives this data - if I try to paste what I've copied on the client-side in a Notepad or Terminal application within the Spice session, it's completely empty.
Anything obviously wrong with this approach that anyone can spot, or any hints as to where to look next?
Thanks,
Nick