Currently, synchronized resizing for X11 clients on Wayland is disabled
because updateXTime() is implemented only for the standalone X11 platform.
We cannot make roundtrips to Xwayland to query its current X11 time stamp
because we may end up in a dead lock. On the other hand, we cannot query
the time stamp asynchronously because doing so may introduce a lot of
regressions. The best option what we've got is to guess Xwayland's X11
time stamp. Fortunately, we know that Xwayland uses the system monotonic
time for time stamps. So, we can query the monotonic time in
updateXTime(). Note that when KWin is not running as a Wayland window
manager, it still does roundtrips to the X server.
Unfortunately, providing an implementation for updateXTime() and moving
the sync alarm filter to the toplevel directory is not enough. The latest
stable release of Xwayland (1.20.8) doesn't use multiple window buffers.
So, it's quite possible that an X11 client may update the buffer after
it's been committed and not released by the compositor yet. In our case,
when the frame window is resized, the buffer will be destroyed. This in
its turn _may_ render the previous and the current window pixmap invalid.
There are several ways to work around the window pixmap issue. (a) Just
ignore it. We probably don't want to do it because visual artifacts
caused by invalid window pixmaps are relatively severe. (b) Scratch the
contents of the buffer when the surface is committed rather than late in
the rendering process. The main drawback of this approach is that it
means we need to perform unnecessary copy operations if the client has
attached more than one shm buffer during a vblank interval. (c) Enable
synchronize resizing for Xwayland that uses multiple window buffers.
Even with all of its drawbacks, the option (b) is quite tempting since
it makes window pixmap management a little bit robust. However, it'd
require changes in the buffer management code, which I personally would
like to avoid. So, instead, I've picked the option (c). With the addition
of multiple window buffers in Xwayland 1.21, there should not be any
severe visual artifacts during a resize operation and we don't have to
tweak our buffer management code.
In order to disable synchronized resizing for Xwayland clients, this
patch series has introduced a new client class - XwaylandClient. The new
class is used to represent X11 clients that are connected to Xwayland.
The X11Client class is used to represent X11 clients when KWin runs as
not a Wayland window manager. The new class also allows to specialize
some code that is irrelevant to X11Client.