aweinstock314 / rust-clipboard

System Clipboard interfacing library in Rust
Apache License 2.0
365 stars 75 forks source link

Wayland support #64

Open trimental opened 5 years ago

trimental commented 5 years ago

There are a few specifics to do with wayland design that sets this implementation apart from others such as x11

  1. A wayland window must be created by the client and have focus before setting or getting the clipboard contents
  2. Wayland events must be continuously dispatched for the clipboard to work. smithay-clipboard's new_threaded() method takes care of this using a thread that continuously dispatches those events
  3. You need to specify the name of the seat you want to use to access the clipboard from (each seat has a different clipboard). By default I've set it to seat0 as multiple seats are an exotic thing in the wayland ecosystem however it can be changed with the set_seat() function.
  4. A wayland display must be passed to the creation of the clipboard and that must be the same display what the window is using

I've left the default ClipboardContext set to X11ClipboardContext on linux and I think that allowing the user to directly use WaylandClipboardContext at their discretion to fit their needs would be a good enough API.

I've also added a wayland example to test out the implementation.

chrisduerr commented 5 years ago

I think this implementation is a bit troublesome since it does not use the ClipboardProvider trait, so that would make it pretty difficult for the consumers to abstract over different platforms.

I've got an alternative implementation here: https://github.com/chrisduerr/rust-clipboard