Import kwayland-server in libkwin
This issue is to track the progress of importing kwayland-server code in libkwin library.
Motivation
kwayland-server provides a set of Qt friendly wrappers around wayland protocol interfaces. However, those wrappers can't simply exist in vacuum. We work around that by adding various callback mechanism, which makes everything more complex than it has to be. Besides that, there's a strong connection between kwin and kwayland-server. If kwayland-server changes, kwin will mostly have to. This makes git bisecting really painful!
But perhaps the main problem is that having wrappers in a separate library adds more work and it solves hypothetical problems. Besides implementing the wayland protocol, one would need to decide what api to expose to the compositor and then implement the protocol in the compositor. Originally, the purpose of kwayland-server was to fill the gap between libwayland and the compositor. However, we've switched to qtwaylandscanner, which took over the responsibility of filling that gap.
As the experience shows, many people wishing to write a compositor for their specific usecase are not keen about implementing a drm backend, a scene graph, etc. They most likely going to take an existing compositor and tweak to it to meet their needs. Also, why would you want to use kwayland-server and waste a lot of money implementing other missing components if there are other wayland compositor libraries that provide more?
As we decided earlier this year, it's worth bringing wayland server code back to kwin. Relevant kwin mailing list discussion: https://mail.kde.org/pipermail/kwin/2021-May/005220.html
Blockers
There are a couple of blockers:
-
kscreenlocker uses kwayland::server (not kwayland-server). We still need to deal with it, e.g. by replacing IPC stuff with QLocalSocket or something else: kscreenlocker!64 (merged) -
some builtin effects use kwayland-server stuff and kwin4_effect_builtins links with libkwin. We need to break that dependency by linking builtin effects with kwin executables: !1534 (merged)
Timeline
Originally, the plan was to get it done in 5.23, but that was put on hold after discovering issues with builtin effects. This needs to be done in 5.24 5.25, some time after 5.23 release.
Post-merge tasks
- Kill src/waylandoutput.{h,cpp} and src/waylandoutputdevice.{h,cpp}. OutputInterface and OutputDeviceV2Interface can use AbstractOutput directly
- Split drm-lease-v1 implementation: add generic leasing infra in the drm backend and make the wayland protocol implementation use it
- Clean up idle detection logic - introduce simple idle detection api in libkwin and port IdleInterface and src/plugins/idletime to it instead of each having their own way to detect idle state
- Unify surface and client buffer abstractions with x11 and internal clients
- etc