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

Selected text and copied text should go to separate clipboards — standard X11 clipboard behavior #162

Open
DrZingo opened this issue Feb 14, 2021 · 4 comments
Labels
enhancement New feature or request linux Relates some variant of Linux

Comments

@DrZingo
Copy link

DrZingo commented Feb 14, 2021

When selecting text, you should be able to paste it into terminal (or other applications) with middle mouse click. PRIMARY clipboard should be used for this.
Also when selecting text and choosing copy, when pasted into vim (terminal), vim hangs for a while, and pastes something old instead. CLIPBOARD clipboard should be used for this
Tested with vim -u DEFAULTS -U NONE -i NONE

https://specifications.freedesktop.org/clipboards-spec/clipboards-latest.txt

@skyjake skyjake added the linux Relates some variant of Linux label Feb 15, 2021
@skyjake
Copy link
Owner

skyjake commented Feb 15, 2021

Thanks for the link, this is all news to me as a casual X11 user.

I'll have to dig into the SDL source code to see what exactly SDL_SetClipboardText() does in practice, and if there is any way to influence the behavior. Of course, there is always the option of using X11 APIs directly for this, but I would prefer a more cross-platform solution...

There is an existing command line tool: https://github.com/astrand/xclip/

That is a good resource to see how the APIs work (appears quite complex!), but one option is to simply run xclip behind the scenes when the user marks a selection, or clicks the middle button.

@DrZingo
Copy link
Author

DrZingo commented Feb 15, 2021

To call xclip behind the scenes is fine with me, but I think xlib is the way to go if not SDL have a way to do it.
I compiled this, which shows lagrange window name as "null" when copying from it. Maybe it have something to do with this?
https://wahjava.wordpress.com/2006/08/05/x-cut-and-paste-aka-x-clipboard/

@skyjake
Copy link
Owner

skyjake commented Feb 16, 2021

I'll have to take a much closer look at the Xlib APIs. If it turns out to be not too complicated, it is indeed better to not call external tools just for accessing the clipboard.

@skyjake skyjake changed the title Selected text should go into primary clipboard (Linux) Selected text should go into primary clipboard (X11) May 4, 2021
@skyjake skyjake added the enhancement New feature or request label May 4, 2021
@skyjake skyjake changed the title Selected text should go into primary clipboard (X11) Selected text and copied text should go to separate clipboards — standard X11 clipboard behavior May 5, 2021
@skyjake
Copy link
Owner

skyjake commented Nov 22, 2022

Interesting new feature in SDL 2.26:

Added SDL_SetPrimarySelectionText(), SDL_GetPrimarySelectionText(), and SDL_HasPrimarySelectionText() to interact with the X11 primary selection clipboard

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

No branches or pull requests

2 participants