Copy/Paste doesn't work between Guest and host with xterm

Discussions about using Linux guests in VirtualBox.
GrAaL
Posts: 4
Joined: 11. Sep 2009, 15:52
Primary OS: MS Windows XP
VBox Version: OSE self-compiled
Guest OSses: UBUNTU 8.10, kernel 2.6.27-14

Copy/Paste doesn't work between Guest and host with xterm

Post by GrAaL »

Hi,

I'm using a classic Windows XP SP2 host with a classic ubuntu 3.10 linux guest.
I've install virtualbox and ubuntu to remove Cygwin.
My trouble is that the copy/paste between guest and host doesn't work until I press "ctrl+c" on the guest, it's clearly impossible in Xterm, I must copy the text inside the guest to a text editor like Gedit, reselect the text and then press ctrl+c.
it seems that the copy/paste system of virtualbox is based on ctrl+c/ctrl+v action instead of hooking the buffer.
Is there a way to force VirtualBox to look at the buffer instead of the keyboard ?

Thank you !

GraaL
Sasquatch
Volunteer
Posts: 17798
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: PUEL
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

Re: Copy/Paste doesn't work between Guest and host with xterm

Post by Sasquatch »

It's been asked before, and answered. If you search Google for the simple terms "linux terminal copy paste", or even in the preferences of your terminal application (or the xterm manual itself), you would know that Ctrl+SHIFT+c and Ctrl+SHIFT+v will copy/paste text.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
GrAaL
Posts: 4
Joined: 11. Sep 2009, 15:52
Primary OS: MS Windows XP
VBox Version: OSE self-compiled
Guest OSses: UBUNTU 8.10, kernel 2.6.27-14

Re: Copy/Paste doesn't work between Guest and host with xterm

Post by GrAaL »

It doesn't work.
I don't talk about the aTerm, Gnome terminal or anything else, I talk about the real Xterm .
There is no "Edit" menu or anything else write in the windows menu, normally, I just have to select the text to add it in the buffer, but in this case, selected text is only available int he guest...

GraAL
Sasquatch
Volunteer
Posts: 17798
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: PUEL
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

Re: Copy/Paste doesn't work between Guest and host with xterm

Post by Sasquatch »

In that case it's only in the xterm buffer, outside the global clipboard shared by the OS. I'm sorry, but this is one of the rare applications that just won't work with the shared clipboard feature, for none of the existing virtualization applications unless it specifically address this type of buffer.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
GrAaL
Posts: 4
Joined: 11. Sep 2009, 15:52
Primary OS: MS Windows XP
VBox Version: OSE self-compiled
Guest OSses: UBUNTU 8.10, kernel 2.6.27-14

Re: Copy/Paste doesn't work between Guest and host with xterm

Post by GrAaL »

I'm not sure but I think that the trouble is different, the trouble is that the shared clipboard doesn't work with selected text.... Difficult to explain for a little frenchy like me. I try :
1- If I select text in my linux VM on an application like firefox, without type anything on the keyboard, and I open Gedit and click on the center button of the mouse, text selected is paste.
2 - If I do the same with Xterm, it works too
3 - If I select text in firefox (always without touching the keyboard) it can't be paste outside the VM
4- If I type ctrl+c in the VM then paste the text outside the VM it works.

In fact, this is the "select text cliboard" that is not connected with the shared clipboard, it doesn't depends of the application.
That's why I was thinking that the shared clipboard was working only with keyboard action.

You were talking about the address of the VM clipboard to add to the shared clipboard, could you explain me how to do that or give me a link ?

Thank you very much,

Best regards,

GrAaL
Sasquatch
Volunteer
Posts: 17798
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: PUEL
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

Re: Copy/Paste doesn't work between Guest and host with xterm

Post by Sasquatch »

GrAaL wrote:You were talking about the address of the VM clipboard to add to the shared clipboard, could you explain me how to do that or give me a link ?
I never mentioned any of that. I only said that the SC does not work with the selection buffer, because it's a different kind of buffer. Usually, selecting text does nothing in Linux, no copy/paste options. You must have some kind of clipboard manager running on the Guest to get that behaviour.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
GrAaL
Posts: 4
Joined: 11. Sep 2009, 15:52
Primary OS: MS Windows XP
VBox Version: OSE self-compiled
Guest OSses: UBUNTU 8.10, kernel 2.6.27-14

Re: Copy/Paste doesn't work between Guest and host with xterm

Post by GrAaL »

Hi,

That's strange... My Ubuntu 8.10 works like that with (at least) firefox, Xterm, Gnome Terminal, Gedit and I think I remember that fedora was also working like that.
I've also seen that this bug is reporting for 2 year in the virtualbox support (Ticket #1169, X11 style cut n paste support)
The ticket seems to be still opened, so it still not resolved.
I also find that with google :
Xterm by default only uses the PRIMARY selection for copy and paste, and follows the implicit selection model where the selection is set immediately when text is selected with the mouse, without any further action from the user.

Most GTK/Gnome applications uses both an implicit selection model with the PRIMARY selection, and an explicit selection model with the CLIPBOARD selection.
(http://linux.seindal.dk/2005/06/16/xter ... clipboard/)

this page give a kind of workaround but it doesn't work (I've also not really work hard to try)

Thank you very much,

Best regards,

GraAL
zsd
Posts: 3
Joined: 14. Nov 2009, 18:00
Primary OS: Linux other
VBox Version: OSE other
Guest OSses: Slackware, ubuntu, windoze

Re: Copy/Paste doesn't work between Guest and host with xterm

Post by zsd »

It seems that vbox assumes you want to use the "clipboard" selection.
I would prefer to use the "primary" selection, since it is easier and faster for me (YMMV).

Is there any way to convince vbox (3.0.10) to use the primary selection?

If not, can someone enlighten me as to what is the best place to request this as a new feature?

Thanks.
mike097821
Posts: 1
Joined: 10. Jan 2010, 12:12
Primary OS: MS Windows XP
VBox Version: PUEL
Guest OSses: Linux Debian Lenny

Re: Copy/Paste doesn't work between Guest and host with xterm

Post by mike097821 »

zsd wrote:It seems that vbox assumes you want to use the "clipboard" selection.
I would prefer to use the "primary" selection, since it is easier and faster for me (YMMV).

Is there any way to convince vbox (3.0.10) to use the primary selection?
Yes, there is. Insert the following into your Xdefaults

XTerm*selectToClipboard:true

This, together with http://linux.seindal.dk/2005/06/16/xter ... clipboard/
should fix all your clipboard-worries between xterm and Win32.
orsenthil
Posts: 2
Joined: 5. Dec 2009, 02:54
Primary OS: MS Windows XP
VBox Version: PUEL
Guest OSses: Ubuntu

Re: Copy/Paste doesn't work between Guest and host with xterm

Post by orsenthil »

mike097821 wrote:Yes, there is. Insert the following into your Xdefaults

XTerm*selectToClipboard:true

This, together with http://linux.seindal.dk/2005/06/16/xter ... clipboard/
should fix all your clipboard-worries between xterm and Win32.
I tried this suggestion, but of no avail. It does not work either.
orsenthil
Posts: 2
Joined: 5. Dec 2009, 02:54
Primary OS: MS Windows XP
VBox Version: PUEL
Guest OSses: Ubuntu

Re: Copy/Paste doesn't work between Guest and host with xterm

Post by orsenthil »

orsenthil wrote:
mike097821 wrote:Yes, there is. Insert the following into your Xdefaults

XTerm*selectToClipboard:true

This, together with http://linux.seindal.dk/2005/06/16/xter ... clipboard/
should fix all your clipboard-worries between xterm and Win32.
I tried this suggestion, but of no avail. It does not work either.
One way, I could solve this problem was compiling a xterm patched with CLIPBOARD http://www.davidsimmons.com/soft/xtermhacks/ support. :) at last.
soapboxalpha
Posts: 1
Joined: 6. Jan 2011, 20:49
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: Debian Linux

Re: Copy/Paste doesn't work between Guest and host with xterm

Post by soapboxalpha »

I use vbox 4.0.0 on Windows 7, with a debian linux 5 guest OS. Shared clipboard works inside the guest OS as follows:

1) copying in the host and pasting in the guest works as expected.

2) copying in the guest and pasting in the host with X applications that allow ctrl-c/ctrl-v (or menu-based) copy and paste operations seems to work correctly.

3) copying in the guest and pasting in the host with X applications that rely on simple text selection in X do not work correctly.

Here's a workaround for xterm that appears to have resolved my problem (From http://www.davidsimmons.com/soft/xtermhacks/debian):
for the Copy & Paste functionality one simply needs to add the following line to the ~/.Xresources file:

Code: Select all

XTerm*VT100.translations: #override <Btn1Up>: select-end(PRIMARY, CLIPBOARD, CUT_BUFFER0)
You can test it with an xterm:

Code: Select all

xterm -xrm 'XTerm*VT100.translations: #override <Btn1Up>: select-end(PRIMARY, CLIPBOARD, CUT_BUFFER0)'
phatrick
Posts: 2
Joined: 11. Mar 2011, 12:27
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: Ubuntu, OpenSUSE

Re: Copy/Paste doesn't work between Guest and host with xterm

Post by phatrick »

Try re-installing the guest additions, this works but is a pain.

Though I've not tried this yet there is a fix suggested here
http://www.virtualbox.org/ticket/3894


version changed from VirtualBox 3.0.12 to VirtualBox 4.0.4.
Anyone currently affected by this might want to try one of the following test builds (see this page):

http://www.virtualbox.org/download/test ... _amd64.deb
(Ubuntu 10.10 64bit deb)
http://www.virtualbox.org/download/test ... r70731.run
(64bit Linux shell script installer)
http://www.virtualbox.org/download/test ... r70731.run
(32bit Linux shell script installer)
You should remove your existing installation (just the software, not the VMs) before installing one of them. They contain a hack that should restore keyboard input when the machine window is clicked on.
zsd
Posts: 3
Joined: 14. Nov 2009, 18:00
Primary OS: Linux other
VBox Version: OSE other
Guest OSses: Slackware, ubuntu, windoze

Re: Copy/Paste doesn't work between Guest and host with xterm

Post by zsd »

mike097821 wrote:
zsd wrote:It seems that vbox assumes you want to use the "clipboard" selection.
I would prefer to use the "primary" selection, since it is easier and faster for me (YMMV).

Is there any way to convince vbox (3.0.10) to use the primary selection?
Yes, there is. Insert the following into your Xdefaults

XTerm*selectToClipboard:true

This, together with http://linux.seindal.dk/2005/06/16/xter ... clipboard/
should fix all your clipboard-worries between xterm and Win32.
Thanks for your suggestion. For me, the problem is not just xterm, I use multiple programs that play nicely with the X primary selection. So while that fix may work for mrxvt (as well as xterm) it is not a general solution. (And in my case it is2 Linux machines, I virtually never use windows.)

The (*cough*) other guys used to (maybe still do) have an option to choose whether you want the host and guest to share the clipboard or the selection. I have no idea whether that would be a huge implementation effort or a relatively small effort. Anyone with a knowledge of the vbox implementation care to speculate?

Cheers
elecpic
Posts: 2
Joined: 24. Jun 2011, 04:29
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: Arch Linux 32bits

Re: Copy/Paste doesn't work between Guest and host

Post by elecpic »

Hi there, I think I'm having the same problem. I collected some information and would like to share.

First, my system:
  • Host OS: Windows 7 pro 64 bits
    VirtualBox 4.08
    Intel VT-X disabled in BIOS
    Guest OS: Arch Linux 32 bits
    VirtualBox Guest Additions 4.0.8-4 (Arch package installed with ArchWiki directives)
Wrapping up the thread so far, we're talking about a virtualbox problem that seems to be a limitation of the shared clipboard feature.

First, we discard the following issues which could lead to similar effects described in the above thread:
  • - VirtualBox Shared Clipboard has not been set to bidirectional.
    - VirtualBox Guest Additions has not been installed on the the guest OS.
    - Linux distro-specific directives has not been followed correctly.
As far as I read information on similar problems, what GrAal is reporting is not specific to XTerm but rather in the way X server and the different X-client-applications running on it handle the "clipboards". Let's clear up the naming of the distinctive "clipboards". In Linux, we could find 3 different ones (quoting Wikipedia article on X Window Selection)
  • 1. PRIMARY selection (used when the user selects some data)
    2. CLIPBOARD selection (used when the user selects some data and explicitly requests it to be "copied" to the clipboard, such as by invoking "Copy" under the "Edit" menu of an application. This implies keyboard-bindings to these commands like ctrl-c and ctrl-v.)
    3. CUT_BUFFERS (Obsolete. I don't think the actual problem is related to that. See the Wikipedia article for further information)
The interesting part is:
At the level of the (X) core protocol, the PRIMARY and CLIPBOARD selections do not differ. But the xclipboard client makes them behave differently. In particular, when another client asserts the ownership of the CLIPBOARD selection, this program requests and displays it in a window. Any further request for this selection are handled by xclipboard. This way, the content of the selection survives the client having copied it.
http://en.wikipedia.org/wiki/X_Window_s ... #Clipboard

In other words, the CLIPBOARD selection behaves differently from one application to another. This could explain the fact of having our shared clipboard problem with some applications and not with others because VirtualBox only use the CLIPBOARD selection so far. If there's a way of changing this, I would like to know. The problem occurs depending if the application uses the CLIPBOARD selection or not. It could also occurs if the application uses the CLIPBOARD selection in a non-standard way. As far as I know, I think the PRIMARY selection is managed by X itself and works the same way in all guest applications. The real problem (the one for which this thread was created) is that VirtualBox doesn't use the PRIMARY selection and you cannot paste in the host using this method. In the other hand, the CLIPBOARD selection can be pasted in the host. However, you have to hassle with the differences between applications.
GEdit works fine from the defaults. You can copy in guest/gedit with crtl-c and paste in host/notepad with ctrl-v.
In many terminals like gnome-terminal, you can copy with ctrl-shift-c with no customization.
I don't know for Firefox but if you use Iceweasel, it uses only PRIMARY selection.

With the initial default configuration of some applications, it doesn't work (e.g. XTerm)
Workarounds exist (I didn't find the ideal solution yet as it would be that VBOX use PRIMARY selection).
  • - Application customization (differs, e.g. XTerm and Emacs)
    - Clipboard managers
As it was proposed for XTerm, some applications allow customizations of the way they handle the "clipboards". The following worked for me. To keep it simple, it tells XTerm to copy the PRIMARY selection to CLIPBOARD selection which can be pasted in the host.
for the Copy & Paste functionality one simply needs to add the following line to the ~/.Xresources file:

Code: Select all

XTerm*VT100.translations: #override <Btn1Up>: select-end(PRIMARY, CLIPBOARD, CUT_BUFFER0)
You can test it with an xterm:

Code: Select all

xterm -xrm 'XTerm*VT100.translations: #override <Btn1Up>: select-end(PRIMARY, CLIPBOARD, CUT_BUFFER0)'
There are also clipboard managers like Glipper, Klipper, Parcellite which keep the 2 "clipboards" in sync at all time. However, I read that these tools doesn't offer enough control yet to be perfect. The major inconvenient of clipboards syncing is when one would like to select data and replace it with the clipboard content. The former action will instead cause the clipboard content to be overwritten by the selection.
In text editor applications like gedit, one might want to control the clipboard explicitly with ctrl-c and ctrl-v and enable the PRIMARY selection control only in terminals.
I have to try to know if this really bugs me. Is anybody tried clipboard managers already?

I hope I convince you of removing XTerm from the title :wink:
I wish this post helps someone to quickly understand, diagnose and find a solution that fits his need.
Maybe someday we'll be able to configure VBOX to use PRIMARY selection.
Post Reply