Skip to content

Does not work with wayland #62

Open

Description

@ankostis

Latest Debian uses* wayland* by default, and all programs depending on xclip broke!.

I understand that this is an X utility, but still, if it is trivial to make it work out-of-the-box[*], it would be great.

[*] https://www.geekyhub.in/post/use-xclip-in-gnome-wayland/

Activity

  1. hackerb9 commented on Oct 12, 2019

    @hackerb9
    Collaborator

    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.

  2. skierpage commented on May 17, 2021

    @skierpage

    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.

    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 😉.

  3. pabloab commented on Nov 11, 2021

    @pabloab

    Maybe some ideas could be borrowed from wl-clipboard.

  4. hackerb9 commented on Nov 17, 2021

    @hackerb9
    Collaborator

    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.

  5. hackerb9 commented on Nov 17, 2021

    @hackerb9
    Collaborator

    Skierpage wrote:

    I originally filed downstream bug https://bugzilla.redhat.com/show_bug.cgi?id=1961031 before finding this issue.

    Did you try the patched version "xclip-0.13-14.git11cba61.fc34" suggested in that bug? Did it help?

  6. skierpage commented on Nov 24, 2021

    @skierpage

    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.

  7. changed the title [-]Dores not work with wayland[/-] [+]Does not work with wayland[/+] on Nov 24, 2021
  8. hackerb9 commented on Nov 24, 2021

    @hackerb9
    Collaborator

    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.

  9. astrand commented on Nov 25, 2021

    @astrand
    Owner

    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?

  10. hackerb9 commented on Nov 26, 2021

    @hackerb9
    Collaborator

    Sounds like a good idea for output.

    Should xclip on input default to writing to both the Primary selection and the Clipboard?

  11. shmerl commented on Jun 28, 2022

    @shmerl

    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:

    QT_QPA_PLATFORM=xcb konsole
    

    ^ Starts konsole in XWayland more.

    In the opened terminal:

    echo foo | xclip -selection clipboard
    
  12. rocketraman commented on Jul 10, 2024

    @rocketraman

    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.

  13. BPowell76 commented on Jul 19, 2024

    @BPowell76

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions