w***@ichips.intel.com
2004-05-17 17:58:27 UTC
Bram (and anyone else interested),
This topic has been discussed a few times before, but I have, I think,
some new information.
First, the background:
I typically run vim in a linux x-windows session run by VNC
(vncserver). This has always presented a problem for the copy/paste
operations when enabling the mouse in vim due the fact the vim puts
selected text only in the PRIMARY selection, while VNC pulled from
CUT_BUFFER0 for pasting. This was typically worked around with
autocutsel, which copied the primary selection to the cut buffer.
I recently started using a new version of vnc from RealVNC
(www.realvnc.com), which works a little differently and does NOT work
with autocutsel. It has its own utility (vncconfig) that is supposed to
support copy/paste between the vnc session and the vnc viewer. This
isn't working properly.
I've indirectly reported these problems to the developers of RealVNC.
They are looking at a solution within vnc, but they had one comment
regarding vim that I'd like to pass along. I'm not communicating with
them directly, and there were several emails before this one, but I'm
wondering if this is a valid critique of the way vim is operating. Note
that I have the same problems copying from "gedit" to windows, so this
is not a vim only problem.
I've looked at what I think is the relevant code. In ui.c, it has:
int
clip_x11_own_selection(myShell, cbd)
Widget myShell;
VimClipboard *cbd;
{
if (XtOwnSelection(myShell, cbd->sel_atom, CurrentTime,
clip_x11_convert_selection_cb, clip_x11_lose_ownership_cb,
NULL) == False)
return FAIL;
return OK;
}
I don't have an ICCM, but the man page on XtOwnSelection says:
The XtOwnSelectionInrcremental procedure informs the
Intrinsics incremental selection mechanism that the speci-
fied widget wishes to own the selection. It returns True
if the specified widget successfully becomes the selection
owner or False otherwise. For more information about
selection, target, and time, see Section 2.6 of the Inter-
Client Communication Conventions Manual.
I've looked around the vim code and can't find ANYWHERE that CurrentTime
is declared. Ahhh - I search a little further and find it defined in
the X.h file as 0L.
I did a quick try at replacing the CurrentTime with time(NULL) in the
above code, but that doesn't work correctly. I also tried replacing
CurrentTime with XtLastTimestampProcessed(dpy), which also required
passing a pointer to the display in to the function. That didn't seem
to work either. Any other ideas from someone more familiar with this
code?
This topic has been discussed a few times before, but I have, I think,
some new information.
First, the background:
I typically run vim in a linux x-windows session run by VNC
(vncserver). This has always presented a problem for the copy/paste
operations when enabling the mouse in vim due the fact the vim puts
selected text only in the PRIMARY selection, while VNC pulled from
CUT_BUFFER0 for pasting. This was typically worked around with
autocutsel, which copied the primary selection to the cut buffer.
I recently started using a new version of vnc from RealVNC
(www.realvnc.com), which works a little differently and does NOT work
with autocutsel. It has its own utility (vncconfig) that is supposed to
support copy/paste between the vnc session and the vnc viewer. This
isn't working properly.
I've indirectly reported these problems to the developers of RealVNC.
They are looking at a solution within vnc, but they had one comment
regarding vim that I'd like to pass along. I'm not communicating with
them directly, and there were several emails before this one, but I'm
wondering if this is a valid critique of the way vim is operating. Note
that I have the same problems copying from "gedit" to windows, so this
is not a vim only problem.
-----Original Message-----
From: Tristan Richardson
Sent: Friday, May 14, 2004 9:28 AM
Subject: RE: Cut/paste again
I've managed to compile vim version 6.2 with the GUI and reproduce the
problem.
I'm reasonably sure that it's a bug in vim.
When it acquires the PRIMARY selection it uses the special value
CurrentTime (0) as the timestamp. This is specifically disallowed by
the ICCCM (inter-client communications convention manual). The
timestamp on the selection must be a valid timestamp from an X event.
The VNC 4 code looks at the timestamps of the PRIMARY and CLIPBOARD
selections so that it transfers whichever is the most recent of them.
Because vim sets the timestamp to zero this doesn't work - though often
the first selection will get through, hence the behaviour you are
seeing.
I'll have a think about whether we can work round it somehow, but the
real solution is to fix the error at source :-)
Cheers
Tristan
Can vim use non-zero timestamps when it acquires the PRIMARY selection?From: Tristan Richardson
Sent: Friday, May 14, 2004 9:28 AM
Subject: RE: Cut/paste again
I've managed to compile vim version 6.2 with the GUI and reproduce the
problem.
I'm reasonably sure that it's a bug in vim.
When it acquires the PRIMARY selection it uses the special value
CurrentTime (0) as the timestamp. This is specifically disallowed by
the ICCCM (inter-client communications convention manual). The
timestamp on the selection must be a valid timestamp from an X event.
The VNC 4 code looks at the timestamps of the PRIMARY and CLIPBOARD
selections so that it transfers whichever is the most recent of them.
Because vim sets the timestamp to zero this doesn't work - though often
the first selection will get through, hence the behaviour you are
seeing.
I'll have a think about whether we can work round it somehow, but the
real solution is to fix the error at source :-)
Cheers
Tristan
I've looked at what I think is the relevant code. In ui.c, it has:
int
clip_x11_own_selection(myShell, cbd)
Widget myShell;
VimClipboard *cbd;
{
if (XtOwnSelection(myShell, cbd->sel_atom, CurrentTime,
clip_x11_convert_selection_cb, clip_x11_lose_ownership_cb,
NULL) == False)
return FAIL;
return OK;
}
I don't have an ICCM, but the man page on XtOwnSelection says:
The XtOwnSelectionInrcremental procedure informs the
Intrinsics incremental selection mechanism that the speci-
fied widget wishes to own the selection. It returns True
if the specified widget successfully becomes the selection
owner or False otherwise. For more information about
selection, target, and time, see Section 2.6 of the Inter-
Client Communication Conventions Manual.
I've looked around the vim code and can't find ANYWHERE that CurrentTime
is declared. Ahhh - I search a little further and find it defined in
the X.h file as 0L.
I did a quick try at replacing the CurrentTime with time(NULL) in the
above code, but that doesn't work correctly. I also tried replacing
CurrentTime with XtLastTimestampProcessed(dpy), which also required
passing a pointer to the display in to the function. That didn't seem
to work either. Any other ideas from someone more familiar with this
code?
--
Mark Waggoner |
***@ichips.intel.com | Hi! Mike Mulligan!
503-712-3335 | How are you going to get your steam shovel out?
dpg-or.pdx.intel.com/~waggoner |
Mark Waggoner |
***@ichips.intel.com | Hi! Mike Mulligan!
503-712-3335 | How are you going to get your steam shovel out?
dpg-or.pdx.intel.com/~waggoner |