xf_cliprdr: fill in support for TIMESTAMP requests.
authorSimon Tatham <anakin@pobox.com>
Fri, 13 Mar 2020 17:59:22 +0000 (17:59 +0000)
committerakallabeth <akallabeth@users.noreply.github.com>
Thu, 25 Feb 2021 08:51:41 +0000 (09:51 +0100)
commit04fd010402624ba8baf4d333a6499fc1ad1333a0
treef9a486b53f0b5bda122f3b759bea34b074961942
parent4a2265cb1eca258ecf49b0803585cefe7ffa0fbe
xf_cliprdr: fill in support for TIMESTAMP requests.

A selection owner is supposed to respond to a request for the
selection target TIMESTAMP by providing the X server time at which the
selection was written. There was a /* TODO */ comment in xf_cliprdr
where the code to do that should have been.

The absence of this can cause a problem when pasting into some X
clients. xtightvncviewer, in particular, will give up the attempt to
read from the clipboard at all if it doesn't get a satisfactory
response to the initial TIMESTAMP request - and the non-answer zero
value "CurrentTime" counts as unsatisfactory. It won't be happy with
anything short of a real X server time value.

(Checking the VNC source code, that's because it reads both PRIMARY
and CLIPBOARD and picks the one with the later timestamp. So it does
depend on the timestamps existing.)

When you're writing to the selection in response to a normal X event
like a mouse click or keyboard action, you get the selection timestamp
by copying the time field out of that X event. Here, we're doing it on
our own initiative, so we have to _request_ the X server time. There
isn't a GetServerTime request in the X protocol, so I work around it
by setting a property on our own window, and waiting for a
PropertyNotify event to come back telling me it's been done - which
will have a timestamp we can use.

(cherry picked from commit fcabbc9707e23b94d7e82021e997578fb20c9313)
client/X11/xf_cliprdr.c