Can SDL2 be made the highest priority Clipboard provider?
Issue #5792 has shown that on Linux there can be a problem with the clipboard provider of the DE framework under certain circumstances (Wayland in this case). Also, the clipboard provider gtk3 is not accessible in a virtual environment, and the necessary Python bindings aren't easily installable. This was fixed with 1a20a3a.
However, it's probably be better to have SDL2 as the highest priority clipboard provider instead, because that is a core requirement. We would have to make sure that this is completely reliable on all platforms beforehand.
Additionally, only xclip and xsel are Cutbuffer providers at the moment, which seems to enable selection + middle click copy/paste on Linux. We would need to determine, either:
- Is that a possibility with SDL2 as well?
- Is it desirable to have support for that out of the box, or should it rather be something optional instead?
Note: this seems to work with Xorg and XWayland (which is how Kivy currently runs), but is probably not supported with a native Wayland client anyway. Likewise, xclip & xsel might stop working under Wayland altogether (needs to be tested).
Seems like a good idea to me. However I've had multiple generations of Debian where the sdl2 clipboard provider just straight up does not work at all (in Kivy, I didn't test it separately). I've also seen this reported by a few other users since sdl2 was added, not sure about their distros. If anyone has run into this / done research etc, please share.
Is that a possibility with SDL2 as well?
I doubt it; cut buffers are X specific and obsolete, ref this link
X10 had these things called ``Cut Buffers'' that were a more limited and wasteful predecessor to selections. They are obsolete; don't use them. Some applications (like xterm) still have legacy support for them, but ignore that. [...]
Cut Buffers: | Obsolete. Never, ever, ever use them. Ever.
@bionoid Do you know or remember what versions those are/were. Would be good to have a list of potentially problematic systems for doing some testing (I haven't yet tried to do any of those anywhere).
That's some good info on that page, thanks. I guess what I meant was having support for the Primary clipboard on Linux (selection + MMB). I don't really know why they're called Cutbuffer providers in Kivy. Sounds like that's not a necessity for that.
However, haven't found anything in the SDL2 project yet which would indicate they support that. The clipboard interface there semes to be pretty simple ([1] [2] [3]).
Do you know or remember what versions those are/were.
It was on Debian 7 or 8 or both. The provider would appear to load just fine, but no copy/paste was possible (workaround was using xclip). It may be an issue with sdl2 version in those distros etc, unfortunately I never researched it in depth
Cutbuffer is causing critical error messages when the Linux system doesn't have xclip and xsel installed:
2024-07-10 11:22:52 [1,301ms] [CRITICAL] [kivy] Cutbuffer: Unable to find any valuable Cutbuffer provider. Please enable debug logging (e.g. add -d if running from the command line, or change the log level in the config) and re-run your app to identify potential causes
xclip - FileNotFoundError: [Errno 2] No such file or directory: 'xclip'
File ".../python/.venv/lib/python3.10/site-packages/kivy/core/__init__.py", line 59, in core_select_lib
mod = importlib.__import__(name='{2}.{0}.{1}'.format(
File "<frozen importlib._bootstrap>", line 1129, in __import__
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File ".../python/.venv/lib/python3.10/site-packages/kivy/core/clipboard/clipboard_xclip.py", line 17, in <module>
p = subprocess.Popen(['xclip', '-version'], stdout=subprocess.PIPE,
File "/usr/lib/python3.10/subprocess.py", line 971, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.10/subprocess.py", line 1863, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
xsel - FileNotFoundError: [Errno 2] No such file or directory: 'xsel'
File ".../python/.venv/lib/python3.10/site-packages/kivy/core/__init__.py", line 59, in core_select_lib
mod = importlib.__import__(name='{2}.{0}.{1}'.format(
File "<frozen importlib._bootstrap>", line 1129, in __import__
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File ".../python/.venv/lib/python3.10/site-packages/kivy/core/clipboard/clipboard_xsel.py", line 16, in <module>
p = subprocess.Popen(['xsel'], stdout=subprocess.PIPE)
File "/usr/lib/python3.10/subprocess.py", line 971, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.10/subprocess.py", line 1863, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
We don't really need the clipboard / cutbuffer, which I believe is not a rare case. Could you make a change to the log level so that the above message is not critical but just a warning?