Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server selection overwrites client clipboard #1896

Open
L-U-T-i opened this issue Jan 15, 2025 · 5 comments
Open

Server selection overwrites client clipboard #1896

L-U-T-i opened this issue Jan 15, 2025 · 5 comments
Labels
enhancement New feature or request

Comments

@L-U-T-i
Copy link

L-U-T-i commented Jan 15, 2025

Describe the bug
If the text is copied from a local machine, and pasted to the first remote machine - overwriting some other text - the clipboard content seem to change and - instead of locally copied text - the text which has just been overwritten on the first remote machine (Primary selection) is pasted into the second remote machine after (instead of a clipboard content, which should still be the content copied from the local machine).

To Reproduce
Steps to reproduce the behavior:

  1. Connect to 2 remote desktops, open pluma (mate desktop text editor; probably any other text editor should behave the same way...) in each of them, and write some text in the 1st remote desktop ('BBB' for instance)
  2. Open pluma on the local machine, write some text ('AAA' for instance) and copy it into the clipboard (select the text, right click on it and select 'copy')
  3. Select the already written text in pluma on the 1st remote machine ('BBB'), and paste over it the clipboard content (text just copied from the local machine - 'AAA') - right clicking on the selected text ('BBB') and select 'paste' in the popup menu (or, select 'Edit' -> 'Paste' in the application menu)
  4. Paste the clipboard content in pluma on the 2nd remote desktop (NOT with the middle mouse button to paste 'Primary selection'!!!); while 'AAA' is expected to be pasted there, 'BBB' is actually pasted (which has never been copied to the clipboard)
  5. Open a new pluma window (or terminal window or whatever such that can accept the text...) on the 1st remote desktop, and paste (right click or application menu 'Paste') the clipboard content there - 'AAA' is still pasted (as expected)

Expected behavior
I would expect the same text just copied from from the local machine will be pasted on the 1st and on the 2nd remote desktop, as nothing has to be copied to the clipboard in between.

It is interesting that pasting in some other text editor window on the same (1st) remote machine after step 3 (step 5 above) works as expected (text 'AAA' is actually pasted, so clipboard content on this remote machine is not overridden by a Primary selection), but pasting on another remote machine (step 4) results in Primary selection from the 1st remote machine is pasted there instead of the clipboard content.

So, something is obviously wrong somewhere, as I would expect a consistent behavior - the same text to be pasted after step 3 in another text editor window (or terminal or any other application) in 1st and on the 2nd remote desktop, what is obviously not the case. After that, it can be a subject of discussion if the right click paste should result in Primary selection to be pasted instead of a clipboard content or not, if one believes this would be better / more reasonable...

Client (please complete the following information):

  • OS: Rocky Linux 9.5
  • VNC client: TigerVNC
  • VNC client version: 1.14.80, git commit 9881fe0
  • Client downloaded from: github, custom rpmbuild (based on Fedora spec file and spec file provided by the package)

Server (please complete the following information):

  • OS: Rocky Linux 9.5
  • VNC server: TigerVNC
  • VNC server version: 1.14.80, git commit 9881fe0
  • Server downloaded from: github, custom rpmbuild (based on Fedora spec file and spec file provided by the package)
  • Server was started using: systemd

Additional context
I am sorry to bother, this is the same (hopefully more clear) report of a - for me very annoying - issue #1889, which has been reported already and closed (and was not reopened despite I've asked @samhed - who closed it - to reopen it as he obviously still misunderstands my point and consider the reported behavior as expected).

I'd ask @CendioOssman to take a look on that before one of you close this issue as well. I hope you will understand that obiously a Primary selection is somehow overriding a copied clipboard content between remote vnc desktops in a way I wouldn't expect (I never use a Primary selection and never had such issues in any local environment, and don't remember to see this behavior in vnc before some years ago...).

A very similar bug has been present in the past (just the selected text on the remote machine to be overwritten has been pasted instead of text copied into the clipboard on the local machine, if I remember well). This seem to be a kind of reincarnation of that one...

@samhed
Copy link
Member

samhed commented Jan 26, 2025

Hi again,

You are right that this would probably be unexpected in some scenarios, like the one you describe. I was likely too quick to close your first issue.

Just as you describe, the remote primary selection and the remote regular clipboard are squashed together when syncing with the local clipboard. But I could see a future where the two different clipboards are separately synced with the local counterparts, in cases where the local system also has two different. The more complex question is what to do, when the local system only has one clipboard, like Windows does.

For the sake of it, I would like to add a simpler scenario, that illustrates the problem with the two clipboards being squashed:

  1. Copy some text locally (Ctrl+C)
  2. Connect to a remote desktop
  3. Select some text, but don't copy it
  4. Paste locally (Ctrl+V)

People used to Windows would probably expect the text from step 1 to be pasted, but that is not what happens. Rather, the text selected in step 3 is pasted, which might be more in line with what Linux-people would expect.

@samhed
Copy link
Member

samhed commented Jan 26, 2025

For your use case, you can try to disable sending the primary selection to the viewers. Does that make things behave like you want? vncconfig has an option for this.

@CendioOssman CendioOssman changed the title Weird cllipboard behavior, 2nd attempt Server selection overwrites client clipboard Jan 28, 2025
@CendioOssman CendioOssman added the enhancement New feature or request label Jan 28, 2025
@L-U-T-i
Copy link
Author

L-U-T-i commented Jan 28, 2025

Hello @samhed,

thank you for your feedback.

It is exactly how you write in your simpler scenario (just selecting a remote test "overwrites" local clipboard), but I don't agree with you that linux people would expect that. I'd rather say it is just how tigervnc (haven't checked the other vnc solutions, maybe some other do it the same way, but it doesn't change my opinion about that) behaves at the moment.

Why? If you take exactly the same example (your scenario as above), but skip step 2 and just select some other text locally in step 3, in normal circumstances (select "paste" in application menu or in right click popup menu or CTRL-V paste or SHIFT-INS paste) text from step 1 is still pasted in step 4 (as I would expect). Only in case of the middle mouse click, selected text from step 3 is pasted (which I actually never use, and don't consider a standard paste or normal paste anyhow). I've checked the behavior in Pluma (Mate Desktop text editor) as well as in Gnome Text Editor and in terminal (CTRL-V doesn't do nothing there though).

About squashing clipboard and primary selection together, for me the only logical choice would be to ignore primary selection if any side doesn't support it. At least by default. If one would prefer a clipboard content and primary selection to interfere, I would resolve that with configuration options, but default should probably still remain to separate those. This way, everything would be the closest to a local behavior (which is not at the moment, as I've tried to describe above).

Thank you for your tip about vncconfig SendPrimary option. I haven't been aware of that. Considering I don't use a Primary selection at all, it actually kind of resolves my issue. In particular if I will be able to make it default through /etc/tigervnc/vncserver-config-defaults setting (I guess it should be with SendPrimary=off extra line - have to try it yet...) - as setting this through vncconfig every time would really be annoying. But I still consider that only as a workaround.

Hello @CendioOssman,
for the reasons just described, I wouldn't consider my issue as an enhancement, but more as a bug report. I would consider an enhancement it there would be a configurable option to request a primary selection to anyhow override a clipboard content in the way not standard in linux (to get it through a menu or CTRL-V paste instead of through a middle mouse click paste only). At least in Fedora / RHEL world (can't say about other distributions though, maybe in some other CTRL-V actually pastes a primary selection content instead...).

@samhed
Copy link
Member

samhed commented Jan 28, 2025

I understand your point of view. I don't know how common the pattern of select-then-paste is, when replacing some text. I suspect there is no real way of knowing what most people expect.

One thing that is important to keep in mind here though, is that TigerVNC has worked like it currently does for a long time. We should be extra careful with any changes to the default behavior, even if we add options.

@L-U-T-i
Copy link
Author

L-U-T-i commented Jan 28, 2025

There are cases when you can not (easily) avoid it - like when you create a new document / directory in caja (mate desktop) - a just created file / directory is named "new file" / "untitled folder", and already selected (to be easily named accoding to your preference).

Imagine you need to create the same file on 3 remote desktops now. You could easily just paste the new name (copied the first time you type it), but you can not, as "new file" is pasted on the 2nd and 3rd deskop instead...

Or, even more common - there is some config file with an option for which you need to change (replace) the value. You change it, and copy the new value to your clipboard on the 1st remote desktop (or, local desktop). But, as soon as you are on the 2nd remote desktop, you need to select the text at the same option first (to paste / replace the value), but at that moment, your clipboard content for the next remote desktop is already gone...

I think there is a reason why clipboard and primary selection behave on local system as thy are, each of them. And, users should probably expect the same results for the same actions no matter weather text is local or remote. I would just expect that there would not be a different logic about that, weather the next window is local or remote, that's all...

You are right that tigervnc behaves like that for quite some time now. I believe I've reported a similar issue for the first time already in May 2021 (#1251). I'm quite confident that before the beginning of 2021 clipboard behaved as I expect, because I would complain even earlier if I would notice it (I've been doing similar things since about 2005 at least, and don't remember to have such issues before...). Later, I've filled the issue #1615 in March 2023, and believe it has been more or less about that (but I've misunderstand what is going on at that time) as well. And those 2 issues now. So, yes, it has quite some beard already... ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants