4e1899
From ad6ddbe2857cfc7e7c8657b1eefb91f305012ef5 Mon Sep 17 00:00:00 2001
4e1899
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
4e1899
Date: Tue, 15 Jul 2014 13:17:09 +0200
4e1899
Subject: [PATCH] Reply to TIMESTAMP requests
4e1899
4e1899
Add TIMESTAMP handling,
4e1899
This is to please vncviewer.
4e1899
4e1899
https://bugzilla.redhat.com/show_bug.cgi?id=1117764
4e1899
(cherry picked from commit b87fab52eb825429e5393ac4c2c073c918d8ed8f)
4e1899
---
4e1899
 src/vdagent-x11-priv.h |  1 +
4e1899
 src/vdagent-x11.c      | 15 +++++++++++++++
4e1899
 2 files changed, 16 insertions(+)
4e1899
4e1899
diff --git a/src/vdagent-x11-priv.h b/src/vdagent-x11-priv.h
4e1899
index c607850..4a5729b 100644
4e1899
--- a/src/vdagent-x11-priv.h
4e1899
+++ b/src/vdagent-x11-priv.h
4e1899
@@ -83,6 +83,7 @@ struct vdagent_x11 {
4e1899
     Atom targets_atom;
4e1899
     Atom incr_atom;
4e1899
     Atom multiple_atom;
4e1899
+    Atom timestamp_atom;
4e1899
     Window root_window[MAX_SCREENS];
4e1899
     Window selection_window;
4e1899
     struct udscs_connection *vdagentd;
4e1899
diff --git a/src/vdagent-x11.c b/src/vdagent-x11.c
4e1899
index 8781d5e..5ac2cf7 100644
4e1899
--- a/src/vdagent-x11.c
4e1899
+++ b/src/vdagent-x11.c
4e1899
@@ -218,6 +218,7 @@ struct vdagent_x11 *vdagent_x11_create(struct udscs_connection *vdagentd,
4e1899
     x11->targets_atom = XInternAtom(x11->display, "TARGETS", False);
4e1899
     x11->incr_atom = XInternAtom(x11->display, "INCR", False);
4e1899
     x11->multiple_atom = XInternAtom(x11->display, "MULTIPLE", False);
4e1899
+    x11->timestamp_atom = XInternAtom(x11->display, "TIMESTAMP", False);
4e1899
     for(i = 0; i < clipboard_format_count; i++) {
4e1899
         x11->clipboard_formats[i].type = clipboard_format_templates[i].type;
4e1899
         for(j = 0; clipboard_format_templates[i].atom_names[j]; j++) {
4e1899
@@ -1033,6 +1034,20 @@ static void vdagent_x11_handle_selection_request(struct vdagent_x11 *x11)
4e1899
         return;
4e1899
     }
4e1899
 
4e1899
+    if (event->xselectionrequest.target == x11->timestamp_atom) {
4e1899
+        /* TODO: use more accurate selection time */
4e1899
+        guint32 timestamp = event->xselectionrequest.time;
4e1899
+
4e1899
+        XChangeProperty(x11->display, event->xselectionrequest.requestor,
4e1899
+                       event->xselectionrequest.property,
4e1899
+                        event->xselectionrequest.target, 32, PropModeReplace,
4e1899
+                        (guint8*)&timestamp, 1);
4e1899
+        vdagent_x11_send_selection_notify(x11,
4e1899
+                       event->xselectionrequest.property, NULL);
4e1899
+       return;
4e1899
+    }
4e1899
+
4e1899
+
4e1899
     if (event->xselectionrequest.target == x11->targets_atom) {
4e1899
         vdagent_x11_send_targets(x11, selection, event);
4e1899
         return;