A dedicated protocol is required to forward all clipboard changes to Klipper and allow Klipper to always update the clipboard content.
WIP branches exist, currently at unit test phase
A dedicated protocol is required to forward all clipboard changes to Klipper and allow Klipper to always update the clipboard content.
WIP branches exist, currently at unit test phase
We should talk to GNOME and wlroots about a common protocol for this functionality.
Is this task currently still actively being worked on? Otherwise I put it back in the Backlog for now.
On Wayland data offers are sent directly from a client as data source to another client's data device. In particular:
(1) is desired behavior but we want out clipboard manager Klipper to be an exception. (2) is unwanted in general for small data offers.
wlroots has the wlr-data-control-unstable-v1 protocol for clipboard managers. It's on the one hand a bit clunky because it's just a copy of the respective core Wayland interfaces, on the other side this solution is genius because there is no need for another specialized interface. The question is if this integrates nicely with our KWayland code which is complicated in regards to data sharing.
An alternative would be to implement a simple protocol that just activates a client as clipboard manager and then for every data source a data offer will first get routed to the clipboard manager before being sent to currently focused one. This could be part of plasma-window-management protocol. Such a clipboard manager could maybe not use the Wayland core data protocol for normal data transfers anymore in a sensible way.
Another question is if we should just directly replace any client's data source with the clipboard manager ones in case the clipboard manager buffers the data offer. In this case we would need an additional request for the clipboard manager in comparision to wlroot's protocol.
The hard part is the seat handling.
DataDevice now needs to handle forwarding both DataSource's and DataControlSources and vice versa.
Action plan is:
That's now all done. Pending merge after 5.19 forks.
Porting klipper is another story.
I've implemented an abstract SystemClipboard that wraps QClipboard or a client API of the protocol. Returns a QMimeData* which generally works fine.
It's written so it can be moved to a high level KWindowSystem somewhere in future.
One challenge it blocks when reading mimedata.
Returning a QByteArray blob async is easy, but QMimeData has additional code to turn that into the right QVariant. QMimeData is very syncronous.
Options are:
class DaveMimeData { QStringList availableFormats(); QFuture<QMimeData*> init(QStringList formats); //QFuture or KJob or whatever }
Where klipper can can then just list all the mimetypes it cares about, then we do one async call that gets a fully loaded completed QMimeData.
I wouldn't have a big problem with merging as is, it could make sense to have QFuture<QVariant> retrieveData as is. It would make it easier to time out when a client is being shitty and would allow to parallelize different queries.