]> git.proxmox.com Git - spiceterm.git/commitdiff
cleanup clipboard owner handling
authorDietmar Maurer <dietmar@proxmox.com>
Tue, 8 Oct 2013 13:08:04 +0000 (15:08 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 8 Oct 2013 13:08:04 +0000 (15:08 +0200)
spiceterm.c

index dd63b90e0a6c95b21d1f3add8646ca191e0e0731..f6de5d5c4a25b3e0c7d3dd70dc632191a13abe3d 100644 (file)
@@ -1492,6 +1492,18 @@ static unsigned char vdagent_write_buffer[VDAGENT_WBUF_SIZE];
 static int vdagent_write_buffer_pos = 0;
 static int agent_owns_clipboard[256] = { 0, };
 
+static void
+spiceterm_clear_selection(spiceTerm *vt)
+{
+    DPRINTF(1, "mark_active = %d", vt->mark_active);
+
+    vt->mark_active = 0;
+    if (vt->selection) free (vt->selection);
+    vt->selection = NULL;
+    spiceterm_unselect_all(vt);
+}
 static void
 spiceterm_motion_event(spiceTerm *vt, uint32_t x, uint32_t y, uint32_t buttons)
 {
@@ -1747,8 +1759,6 @@ static void vdagent_request_clipboard(spiceTerm *vt, uint8_t selection)
 {
     uint32_t size;
     
-    agent_owns_clipboard[selection] = 1;
-
     size = 4 + sizeof(VDAgentClipboardRequest);
 
     int msg_size =  sizeof(VDIChunkHeader) + sizeof(VDAgentMessage) + size;
@@ -1874,6 +1884,7 @@ vmc_write(SpiceCharDeviceInstance *sin, const uint8_t *buf, int len)
         uint8_t selection = *((uint8_t *)grab);
         DPRINTF(1, "VD_AGENT_CLIPBOARD_GRAB %d", selection);
         agent_owns_clipboard[selection] = 0;
+        spiceterm_clear_selection(vt);
         break;
     }
     case VD_AGENT_CLIPBOARD_REQUEST: {