From ad6ea7594a11d8a35be84a8ae2e8403ea3344a3b Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Mon, 9 Sep 2013 15:50:39 +0200
Subject: [linux-vdagent PATCH 5/5] vdagent-x11: Release clipboard on client
disconnect if owned by client
https://bugzilla.redhat.com/show_bug.cgi?id=1003977
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
src/vdagent-x11.c | 10 ++++++++++
src/vdagent-x11.h | 2 ++
src/vdagent.c | 1 +
3 files changed, 13 insertions(+)
diff --git a/src/vdagent-x11.c b/src/vdagent-x11.c
index 4588b3d..5ce6000 100644
--- a/src/vdagent-x11.c
+++ b/src/vdagent-x11.c
@@ -1305,6 +1305,16 @@ void vdagent_x11_clipboard_release(struct vdagent_x11 *x11, uint8_t selection)
vdagent_x11_do_read(x11);
}
+void vdagent_x11_client_disconnected(struct vdagent_x11 *x11)
+{
+ int sel;
+
+ for (sel = 0; sel < VD_AGENT_CLIPBOARD_SELECTION_SECONDARY; sel++) {
+ if (x11->clipboard_owner[sel] == owner_client)
+ vdagent_x11_clipboard_release(x11, sel);
+ }
+}
+
/* Function used to determine the default location to save file-xfers,
xdg desktop dir or xdg download dir. We error on the save side and use a
whitelist approach, so any unknown desktops will end up with saving
diff --git a/src/vdagent-x11.h b/src/vdagent-x11.h
index a2a2485..d64a42a 100644
--- a/src/vdagent-x11.h
+++ b/src/vdagent-x11.h
@@ -46,6 +46,8 @@ void vdagent_x11_clipboard_data(struct vdagent_x11 *x11, uint8_t selection,
uint32_t type, uint8_t *data, uint32_t size);
void vdagent_x11_clipboard_release(struct vdagent_x11 *x11, uint8_t selection);
+void vdagent_x11_client_disconnected(struct vdagent_x11 *x11);
+
int vdagent_x11_has_icons_on_desktop(struct vdagent_x11 *x11);
#endif
diff --git a/src/vdagent.c b/src/vdagent.c
index f270615..d7f7aba 100644
--- a/src/vdagent.c
+++ b/src/vdagent.c
@@ -104,6 +104,7 @@ void daemon_read_complete(struct udscs_connection **connp,
free(data);
break;
case VDAGENTD_CLIENT_DISCONNECTED:
+ vdagent_x11_client_disconnected(x11);
vdagent_file_xfers_destroy(vdagent_file_xfers);
vdagent_file_xfers = vdagent_file_xfers_create(client, fx_dir,
fx_open_dir, debug);
--
1.8.3.1