You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is the failure mode when xclip is used under Wayland? Maybe xclip could detect that the chosen selection (Primary) isn't available and fallback to Clipboard.
What is the failure mode when xclip is used under Wayland? Maybe xclip could detect that the chosen selection (Primary) isn't available and fallback to Clipboard.
Run under kwin_wayland from the Fedora 34 KDE spin (which by default runs an XWayland server to support X11 programs), if a Wayland program has the primary selection and no X11 programs have a primary selection then xclip version 0.13 immediately crashes with segmentation fault.
I fiddled with gdb. It's crashing in doOut() in the "no fallback available, exit with failure" leg at line 748
free(sel_buf);
It seems to go through the loop calling xcout() a few times until it gets XCLIB_XCOUT_BAD_TARGET) and then calls free, but
p sel_buf
$12 = (unsigned char *) 0x38000000380 <error: Cannot access memory at address 0x38000000380>
so crash. But this is with the optimized binary; I don't know how sel_buf gets set.
As much grief as Wayland has caused for me, strangely it has not broken xclip on my computer. I am using Xwayland on Debian GNU/Linux 11 (the current stable release) with gnome.
Did you try the patched version "xclip-0.13-14.git11cba61.fc34" suggested in that bug? Did it help?
I just tried xclip-0.13-15.git11cba61.fc35.x86_64. I couldn't get it to crash.
I started an X11 program, chromium-browser running under Xwayland, and made some selections; xclip shows the X11 clipboard contents. Unsurprisingly (?) if I set the selection in a Wayland app (I used Firefox with MOZ_ENABLE_WAYLAND=1), that isn't reflected in xclip -o.
After exiting my one X11 program (but kwin_wayland is still running), xclip -o outputs "xclip: Error: There is no owner for the CLIPBOARD/ PRIMARY selection". But I can run echo 'NEW PRIMARY SELECTION' > xclip -selection primary without error.
It seems xclip is probably working about as well as can be expected under kwin Wayland.
I started an X11 program, chromium-browser running under Xwayland, and made some selections; xclip shows the X11 clipboard contents. Unsurprisingly (?) if I set the selection in a Wayland app (I used Firefox with MOZ_ENABLE_WAYLAND=1), that isn't reflected in xclip -o.
After exiting my one X11 program (but kwin_wayland is still running), xclip -o outputs "xclip: Error: There is no owner for the CLIPBOARD/ PRIMARY selection".
And it does work when you do xclip -selection clipboard -o, right?
If so, that would make me think that xclip, when no specific selection is requested, should now default to to using the clipboard instead of the primary selection. @astrand, what do you think? I know this breaks with past behavior, but it seems reasonable.
From one perspective, why should we change the behaviour and break compatibility for all X11 users, just because some other competing project wants to do things differently? xclip was written to support X11, not other systems. If other systems wants to provide backwards compatibility they can of course do that, but if this compatibility is bad or incomplete, should really xclip be changed? I think that would be wrong; at least as long as most xclip users are using X11 rather than Wayland.
Having that said: Perhaps we can consider change the default so that xclip first tries primary, and if that fails, then uses clipboard. What do you think of this?
Just as another datapoint, copying from a Wayland program (such as Chrome configured with ozone platform=wayland) I get this when used from a Wayland shell:
$ xclip -o -t TARGETS
xclip: Error: There is no owner for the PRIMARY selection
$ xclip -selection clipboard -o -t TARGETS
xclip: Error: There is no owner for the CLIPBOARD selection
qdbus org.kde.KWin /KWin org.kde.KWin.showDebugConsole shows the "Clipboard" content is correct. The source is shown as wl_data_source@x of <process>.
It'd be nice if xclip handled this somehow, but of course I understand if it did not. wl-clipboard works well for this use case.
Just as another datapoint, copying from a Wayland program (such as Chrome configured with ozone platform=wayland) I get this when used from a Wayland shell:
$ xclip -o -t TARGETS
xclip: Error: There is no owner for the PRIMARY selection
$ xclip -selection clipboard -o -t TARGETS
xclip: Error: There is no owner for the CLIPBOARD selection
qdbus org.kde.KWin /KWin org.kde.KWin.showDebugConsole shows the "Clipboard" content is correct. The source is shown as wl_data_source@x of <process>.
It'd be nice if xclip handled this somehow, but of course I understand if it did not. wl-clipboard works well for this use case.
Thank you for sharing. This resolved my issue with copying from neovim to other applications/windows using Wayland. It's part of the Ubuntu apt repo so installing was about as simple as it gets.
Activity
hackerb9 commentedon Oct 12, 2019
What is the failure mode when
xclipis used under Wayland? Maybe xclip could detect that the chosen selection (Primary) isn't available and fallback to Clipboard.skierpage commentedon May 17, 2021
Run under kwin_wayland from the Fedora 34 KDE spin (which by default runs an XWayland server to support X11 programs), if a Wayland program has the primary selection and no X11 programs have a primary selection then
xclipversion 0.13 immediately crashes with segmentation fault.I fiddled with gdb. It's crashing in
doOut()in the "no fallback available, exit with failure" leg at line 748It seems to go through the loop calling
xcout()a few times until it getsXCLIB_XCOUT_BAD_TARGET) and then calls free, butso crash. But this is with the optimized binary; I don't know how
sel_bufgets set.Hope this helps. I originally filed downstream bug https://bugzilla.redhat.com/show_bug.cgi?id=1961031 before finding this issue. Thanks for this utility!
I installed the wl-clipboard package for the equivalent commands wl-copy and wl-paste under Wayland; it's going to be hard to retrain my fingers 😉.
pabloab commentedon Nov 11, 2021
Maybe some ideas could be borrowed from wl-clipboard.
hackerb9 commentedon Nov 17, 2021
As much grief as Wayland has caused for me, strangely it has not broken
xclipon my computer. I am using Xwayland on Debian GNU/Linux 11 (the current stable release) with gnome.hackerb9 commentedon Nov 17, 2021
Skierpage wrote:
Did you try the patched version "xclip-0.13-14.git11cba61.fc34" suggested in that bug? Did it help?
skierpage commentedon Nov 24, 2021
I just tried xclip-0.13-15.git11cba61.fc35.x86_64. I couldn't get it to crash.
I started an X11 program, chromium-browser running under Xwayland, and made some selections; xclip shows the X11 clipboard contents. Unsurprisingly (?) if I set the selection in a Wayland app (I used Firefox with MOZ_ENABLE_WAYLAND=1), that isn't reflected in
xclip -o.After exiting my one X11 program (but kwin_wayland is still running),
xclip -ooutputs "xclip: Error: There is no owner for the CLIPBOARD/ PRIMARY selection". But I can runecho 'NEW PRIMARY SELECTION' > xclip -selection primarywithout error.It seems xclip is probably working about as well as can be expected under kwin Wayland.
[-]Dores not work with wayland[/-][+]Does not work with wayland[/+]hackerb9 commentedon Nov 24, 2021
And it does work when you do
xclip -selection clipboard -o, right?If so, that would make me think that
xclip, when no specific selection is requested, should now default to to using the clipboard instead of the primary selection. @astrand, what do you think? I know this breaks with past behavior, but it seems reasonable.astrand commentedon Nov 25, 2021
From one perspective, why should we change the behaviour and break compatibility for all X11 users, just because some other competing project wants to do things differently? xclip was written to support X11, not other systems. If other systems wants to provide backwards compatibility they can of course do that, but if this compatibility is bad or incomplete, should really xclip be changed? I think that would be wrong; at least as long as most xclip users are using X11 rather than Wayland.
Having that said: Perhaps we can consider change the default so that xclip first tries primary, and if that fails, then uses clipboard. What do you think of this?
hackerb9 commentedon Nov 26, 2021
Sounds like a good idea for output.
Should xclip on input default to writing to both the Primary selection and the Clipboard?
shmerl commentedon Jun 28, 2022
Apparently, Wayland won't sync clipboards unless one of the client windows is focused.
So for this to work, you need to run the terminal itself in XWayland.
So this works for KDE / konsole for example:
^ Starts konsole in XWayland more.
In the opened terminal:
rocketraman commentedon Jul 10, 2024
Just as another datapoint, copying from a Wayland program (such as Chrome configured with ozone platform=wayland) I get this when used from a Wayland shell:
qdbus org.kde.KWin /KWin org.kde.KWin.showDebugConsoleshows the "Clipboard" content is correct. The source is shown aswl_data_source@x of <process>.It'd be nice if
xcliphandled this somehow, but of course I understand if it did not.wl-clipboardworks well for this use case.BPowell76 commentedon Jul 19, 2024
Thank you for sharing. This resolved my issue with copying from neovim to other applications/windows using Wayland. It's part of the Ubuntu apt repo so installing was about as simple as it gets.