Support for syncing the clipboard from X11 to Wayland and vice versa
ClosedPublic

Authored by graesslin on Jun 22 2016, 12:57 PM.

Details

Summary

The clipboard sync is done by a dedicated helper binary launched by
KWin. This helper binary is forced to xcb platform to picky-back on
Qt's implementation of the X11 clipboard. In addition it implements
the Wayland clipboard - which is much simpler. Reading the Wayland
clipboard is based on the implementation in QtWayland.

KWin internally knows the DataDeviceInterface belonging to the helper
application. Whenever an xwayland client is focussed, this DataDevice
is allowed to set the selection and KWin manually updates the current
selection in the SeatInterface. By that the sync from X11 to Wayland
is implemented. When afterwards a Wayland client is selected, it's sent
the current selection which references the X clipboard and a data
transfer can be initiated in the normal Wayland way.

For the other direction KWin sends the current selection to the helper's
DataDevice whenever an xwayland window is focused. The helper application
reads the Wayland clipboard and sets it on the X11 clipboard. Thus the
Wayland clipboard is synced to X11.

The approach used here will also be useful for implementing a clipboard
manager (aka klipper).

Currently the implementation is not yet fully completed. We need to
make sure that the helper application gets restarted in case of a crash.

Test Plan

Test cases still missing. I'm not exactly sure how I can test
this. But running the code currently and happily copy/paste.

Diff Detail

Repository
R108 KWin
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
graesslin updated this revision to Diff 4671.Jun 22 2016, 12:57 PM
graesslin retitled this revision from to Support for syncing the clipboard from X11 to Wayland and vice versa.
graesslin updated this object.
graesslin edited the test plan for this revision. (Show Details)
graesslin added reviewers: Plasma on Wayland, KWin.
Restricted Application added projects: Plasma on Wayland, KWin. · View Herald TranscriptJun 22 2016, 12:57 PM
Restricted Application added subscribers: kwin, plasma-devel. · View Herald Transcript
graesslin updated this revision to Diff 4737.Jun 26 2016, 1:34 PM

Added test case for the clipboard sync. And adjusted the implementation to the issues
it found.

The test case found further issues, which will be fixed in following phab requests.

sebas accepted this revision.Jun 28 2016, 3:28 PM
sebas added a reviewer: sebas.
This revision is now accepted and ready to land.Jun 28 2016, 3:28 PM
This revision was automatically updated to reflect the committed changes.