New classes Shell and ShellSurface are created. Both are in shell.[h|cpp]
to indicate their close relationship with the Shell having to create the
ShellSurface.
WaylandBackend is adjusted to hold a Shell* and ShellSurface* instead of
the lower level structs. This also required adjustements to the creation
of the Backend as it now doesn't set a default size any more. Thus the
backendReady signal may not be emitted before the initial configure
event arrived. This also makes it easier to support either the fullscreen
shell or wl_shell at the same time.
Of course a unit test is added for the two new classes. This needs to
be extended once we have more control over the mock Wayland server.
At the same time adding an autotest for the Output, moving the listener
into the Output class and providing enums for Subpixel and Transform.
KWin now requires wl_ouput interface version 2 as that allows us to emit
the changed signal in a better way.
The unit test is not yet capable of testing everything, we need a mock
Wayland server which is more flexible.
The FullscreenShell is a Wayland protocol provided by Weston to have
exactly one surface per output. This is exactly what KWin needs. So
in case the Wayland server we connect to provides the FullscreenShell
we prefer it over the normal Shell and mapping our surface as fullscreen.
The protocol is not yet part of wayland-client library, so the header
and source file needs to be generated. This is done during the build
process using the external tool wayland-scanner. The protocol
description is copied from the Westion 1.5 sources.
REVIEW: 119839
The Wayland::Registry class wraps wl_registry handling. It keeps track
of the interfaces in the registry and emits signals whenever a known
interface gets announced or removed. So far it only tracks the interfaces
which are used and needed by KWin.
The Wayland event queue is moved into a dedicated thread and a
new class is created for just creating the connection and listening
for events. The WaylandBackend creates the thread and uses an event
queue for the main thread.
REVIEW: 119761
All of kwin except the main function goes into a new (private) library
called kwin. Two new kdeinit_executables are created:
* kwin_x11
* kwin_wayland
Both only use a dedicated main_x11.cpp and main_wayland.cpp with the
main function and a KWin::Application subclass and linking the new
kwin library.
The main idea behind this is to be able to perform more sane sanity
checks. E.g. on Wayland we don't need to first test whether we can
create an X11 connection. Instead we should abort if we cannot connect
to the Wayland display. Also the multi-head checks are not needed on
Wayland, etc. etc. As most of that code is in the main function to
simplify it's better to split.
This will also make it easier to diverge more easily in future. The
Wayland variant can introduce more suited command line arguments for
example. This already started by having the --replace option only
available in X11 variant. The Wayland backend is still a window manager,
but doesn't claim the manager selection.
The Wayland Backend connects to the wl_output interface to get
information about the connected outputs and their modes. This information
can be used to setup screen information.
The Wayland Backend watches the socket it uses for communicating with the
Wayland compositor. If the socket is removed we have to perform a kind of
emergency stop. The backend tears down all data structures created from
the Wayland display and emits a signal that the system compositor died.
In addition the Wayland Backend starts to monitor the XDG_RUNTIME_DIR for
the socket to be added again. If the socket is created again the backend
reinitializes the Wayland connection.
This also requires the Compositor to restart. Therefore it connects to
the new signals emitted by the Wayland Backend to stop and start
compositing.
Major new functionality is xkbcommon support. InputRedirection holds an
instance to a small wrapper class which has the xkb context, keymap and
state. The keymap is initialied from the file descriptor we get from the
Wayland backend.
InputRedirection uses this to translate the keycodes into keysymbols and
to QString and to track the modifiers as provided by the
Qt::KeybordModifiers flags.
This provides us enough information for internal usage (e.g. pass through
effects if they have "grabbed" the keyboard).
If KWin doesn't filter out the key events, it passes them on to the
currently active Client respectively an unmanaged on top of the stack.
This needs still some improvement (not each unmanaged should get the
event). The Client/Unmnaged still uses xtest extension to send the key
events to the window. So keylogging is still possible.
So far this new class is not yet doing much. The WaylandBackend forwards
the received pointer events to this InputRedirection class. From there
signals are emitted to inform internal areas about the changes first.
The events are currently forwarded to X through the xtest extension. This
will be removed in future. Input will be forwarded directly to the
surface which wants it (no matter whether X11 or Wayland).
This enum describes how KWin is operating with the available windowing
systems. By default KWin is using the OperationModeX11, but if the
Wayland backend gets started KWin is using the OperationModeWaylandAndX11
This will be extended in future when XWayland and Wayland only become
viable options.
A user can now directly request a Wayland::Buffer object which exposes
the memory address of the shared memory with the wl_buffer. This allows
to use the Wayland Buffer directly as the storage of a QImage.
To make sure that the ShmPool does not reuse such a buffer the Buffer can
be marked as used.
When the ShmPool gets resized the memory addresses become invalid.
Therefore the ShmPool is now a QObject and emits a signal on resized pool
so that every user of a Wayland::Buffer can remap the memory.
The Wayland::Buffer no longer holds the exact memory address but only
the offset in the pool. The actual address of the pool is only known to
the ShmPool which allows us to remap a resized file.
If a new buffer cannot be provided by the given pool, it gets now resized
to the new needed size. This allows us to only create a very small pool.
A new Wayland::Buffer class is provided which wraps a:
* wl_buffer
* size
* stride
* memory address of data represented by the buffer
In addition the Buffer knows whether the compositor has released it or
not. This allows the ShmPool to reuse the buffer in case the same size
and stride is requested.
This is currently most relevant for the CursorData. Instead of keeping
the wl_buffer, the QImage for the cursor is kept and each time the cursor
is set for the surface a new buffer is requested from the ShmPool.
The ShmPool now either reuses an existing buffer or creates a new one.
Furthermore the ShmPool takes care of releasing all buffers at EOL.
The backend gets created by Workspace, but only if the environment
variable WAYLAND_DISPLAY is set.
Because of that the egl wayland backend does no longer create the
backend, but uses the already created one.
The functionality to create the connection to a Wayland compositor and
creating a fullscreen surface is moved into wayland_backend.(h|cpp). The
wl_egl_window for the surface is moved into the EglWaylandBackend to have
the actual WaylandBackend free from Egl. This will allow in future to
implement other compositing backends for Wayland which do not use egl.
This means that egl is no longer a build requirement for the wayland
related functionality.