clipboard-master icon indicating copy to clipboard operation
clipboard-master copied to clipboard

Wayland support?

Open Microwave-WYB opened this issue 2 years ago • 4 comments

It would be awesome if we can add Wayland support!

Microwave-WYB avatar Jun 14 '22 09:06 Microwave-WYB

are you familiar with wayland? I don't really know it and whether there is proper API bindings. Considering how complicated X11 is, I wouldn't be surprised if Wayland itself would be pretty complicated stuff.

In addition to that it would probably require to introduce feature to use wayland instead of x11

DoumanAsh avatar Jun 14 '22 09:06 DoumanAsh

It is very tricky to have proper support for Wayland. The Wayland standard protocol does not allow applications without a focused window to access the user clipboard, and compositors need to implement their own protocols for such use cases. wlroots-based compositors and KDE's KWin implement the wlr_data_control protocol, but GNOME's Mutter does not. So there is no good way to support all Wayland environments. wl-clipboard uses a very nasty hack which spawns a 1x1 window first and hope for the compositor to auto focus that window, then start reading the clipboard.

gnattu avatar Feb 04 '24 17:02 gnattu

For compositors does implement wlr_data_control protocol, we have wl-clipboard-rs which implemented reading and writing using this protocol.

gnattu avatar Feb 04 '24 17:02 gnattu

My own fork added very basic support to wayland for compositors implemented wlr_data_control protocol. However, due to lacking of monitoring apis being implemented, it triggers the callback by checking if the hash of the contents in the clipboard has changed, and can only be used for pure text contents. This is not suitable for upstreaming but is good enough for my own project at the moment.

gnattu avatar Feb 06 '24 10:02 gnattu