From c259271317f9ee37336842616c3c3010a512da9a Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Thu, 28 Oct 2010 10:11:27 +0200 Subject: [PATCH] release clipboard when owned by agent and active session changes --- TODO | 1 - vdagentd.c | 24 +++++++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/TODO b/TODO index ecfb0bc..9092fca 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,3 @@ --release keyboard when owned by agent and active session changes -patch xorg driver to allow adding "random" resolutions -make vdagent xorg client try to add "random" resolutions -fedora package diff --git a/vdagentd.c b/vdagentd.c index 4dd84d0..97f9fc0 100644 --- a/vdagentd.c +++ b/vdagentd.c @@ -57,6 +57,7 @@ static int uinput_width = 0; static int uinput_height = 0; static const char *active_session = NULL; static struct udscs_connection *active_session_conn = NULL; +static int agent_owns_clipboard = 0; /* utility functions */ /* vdagentd <-> spice-client communication handling */ @@ -148,11 +149,19 @@ static void do_client_clipboard(struct vdagent_virtio_port *port, uint32_t type = 0, opaque = 0, size = 0; uint8_t *data = NULL; + if (!active_session_conn) { + fprintf(stderr, + "Could not find an agent connnection belonging to the " + "active session, ignoring client clipboard request\n"); + return; + } + switch (message_header->type) { case VD_AGENT_CLIPBOARD_GRAB: type = VDAGENTD_CLIPBOARD_GRAB; data = message_data; size = message_header->size; + agent_owns_clipboard = 0; break; case VD_AGENT_CLIPBOARD_REQUEST: { VDAgentClipboardRequest *req = (VDAgentClipboardRequest *)message_data; @@ -173,13 +182,6 @@ static void do_client_clipboard(struct vdagent_virtio_port *port, break; } - if (!active_session_conn) { - fprintf(stderr, - "Could not find an agent connnection belonging to the " - "active session, ignoring client clipboard request\n"); - return; - } - udscs_write(active_session_conn, type, opaque, data, size); } @@ -263,6 +265,7 @@ void do_agent_clipboard(struct udscs_connection *conn, vdagent_virtio_port_write(virtio_port, VDP_CLIENT_PORT, VD_AGENT_CLIPBOARD_GRAB, 0, data, header->size); + agent_owns_clipboard = 1; break; case VDAGENTD_CLIPBOARD_REQUEST: { VDAgentClipboardRequest req = { .type = header->opaque }; @@ -293,6 +296,7 @@ void do_agent_clipboard(struct udscs_connection *conn, case VDAGENTD_CLIPBOARD_RELEASE: vdagent_virtio_port_write(virtio_port, VDP_CLIENT_PORT, VD_AGENT_CLIPBOARD_RELEASE, 0, NULL, 0); + agent_owns_clipboard = 0; break; } @@ -377,6 +381,12 @@ void update_active_session_connection(void) active_session_conn = new_conn; + if (agent_owns_clipboard) { + vdagent_virtio_port_write(virtio_port, VDP_CLIENT_PORT, + VD_AGENT_CLIPBOARD_RELEASE, 0, NULL, 0); + agent_owns_clipboard = 0; + } + check_xorg_resolution(); } -- 2.11.4.GIT