:: James ''Wez'' Weatherall <[EMAIL PROTECTED]>
:: X uses two different clipboard formats, only one of which is directly
:: supported by Xvnc. 

: "Ehud Karni" <[EMAIL PROTECTED]>
: After your email I checked it with xterm and found that it worked.  I
: could paste into the Xvnc xterm and when I marked it in the xterm it
: copied successfully into Emacs. 
: I checked the possible various Emacs functions to paste from the X
: clipboard and found that `x-get-cut-buffer' does paste directly from
: the client VNC. 

Let me add some detail.  The vncviewer and Xvnc makes some
attempt to support both, but it's difficult to do thoroughly.

The two "clipboard formats" are, first, the "cut buffer" (where the X
server has a copy of the data), and second, the "selection", where some
client has the data and hands it to other clients that ask.  The distinction
was important back in the day, when memory was limited, so having the
clients talk to each other was better than having a middleman keep
a third copy.

Many X applications ignore the cut buffer and set and read the selection
(actually...  "the primary selection": you can have more than one, but
it's rare to have any but the one).  The xterm application tries to both
read and set both the selection and the cut buffer, and "do the right
thing" as often as it can.  That's why it can act as a go-between. 

Here's the problem.  The vncviewer tries to copy stuff across, but, you
see, it isn't actually an X client of the remote Xvnc; it doesn't talk X
protocol to it at all.  So it can't keep the data itself and offer a
selection; the only thing it CAN do is hand the data to the Xvnc server
under the table and thus set the cut buffer.  Well, actually "cut buffer
zero"; same comments apply to cut buffers as to selections. 

There are two little programs that can be used to assist when
(eg tcl/tk, netscape, and lots of other clients) the app you want
to paste into can't grab the X cut buffer directly like emacs can.
One is "xcutsel", and is available on most all X installations.
If you run it, it offers to "copy primary to 0" or "copy 0 to primary".
So, if you've got a program that sets the one or the other, you can
copy the data across.  This whole issue and use of xcutsel to solve
is mentioned in the VNC FAQ, but in not so much detail.

So here's the worst case: netscape talks to the selection, and
doesn't understand the cut buffer.  So if you have some text in a
local netscape that you want to paste into a remote netscape inside
a vncviewer, you have to be running a local and a remote xcutsel, and
you 
        1. select text on the local netscape
        2. click "copy PRIMARY to 0" on the local xcutsel
        3. move the cursor into the vncviewer; this copyies the
           cut buffer content you just copied to the remote Xnvc server
        4. click "copy 0 to PRIMARY" on the remote xcutsel
        5. finally, you can paste into the remote netscape.

Sometimes I have found you need a step 2a, click "copy 0 to PRIMARY"
so that xcutsel takes the local selection away from the local netscape; 
sometimes necessary to get the correct text copied across, go figure.

That's as bad as it gets.  It's actually easier than it sounds.

The other tool is "xselection", not so commonly distributed, but can be
found and downloaded from the net.  It allows shell scripts to read and
write the X selections and cut buffers.  It could be used to do the work
of xcutsel, but it's packaged as command-line and pipe-oriented utility,
rather than a little GUI widget.  You could write your own translation
helper, say as a window manager function, or a tcl/tk widget, that
requires fewer clicks than xcutsel, ie, you maybe wouldn't have to keep
track of which way to copy.  I've gotten used to xcutsel, though. 

It has occured to me that Xvnc could have a helper process that could be
told grab and hold the primary selection whenever there's an incoming
cut buffer selection form the viewer.  This could make it work more naturally. 
---------------------------------------------------------------------
To unsubscribe, send a message with the line: unsubscribe vnc-list
to [EMAIL PROTECTED]
See also: http://www.uk.research.att.com/vnc/intouch.html
---------------------------------------------------------------------

Reply via email to