Expand description
§Smithay: the Wayland compositor smithy
This crate is a general framework for building wayland compositors. It currently focuses on low-level, helpers and abstractions, handling most of the system-level and wayland protocol interactions. The window management and drawing logic is however at this time not provided (but helpers for this are planned for future version).
§Structure of the crate
The provided helpers are split into two main modules:
backend
contains helpers for interacting with the operating system, such as session management, interactions with the graphic stack and input processing.wayland
contains helpers for interacting with wayland clients according to the wayland protocol.
In addition, the xwayland
module contains helpers for managing an
XWayland instance if you want to support it. See the documentation of
these respective modules for information about their usage.
§General principles for using Smithay
§The event loop and state handling
Smithay is built around calloop
, a callback-oriented event loop, which fits naturally with the
general behavior of a wayland compositor: waiting for events to occur and react to them (be it
client requests, user input, or hardware events such as vblank
).
Using a callback-heavy structure however poses the question of state management: a lot of state needs
to be accessed from many different callbacks. To avoid a heavy requirement on shared pointers such
as Rc
and Arc
and the synchronization they require, calloop
allows you to provide a mutable
reference to a value that will be passed down to most callbacks. This structure provides
easy access to a centralized mutable state without synchronization (as the callback invocation is
always sequential), and is the recommended way of structuring your compositor.
TODO: Add a section here how this links to wayland-server’s Dispatch
and link to the wayland-server
docs, once they exist for 0.30.
Several objects, in particular on the wayland clients side, can exist as multiple instances where each instance has its own associated state. For these situations, these objects provide an interface allowing you to associate an arbitrary value to them, that you can access at any time from the object itself (rather than having your own container in which you search for the appropriate value when you need it).
§Logging
Smithay makes extensive use of tracing
for its internal logging.
For release builds it is recommended to limit the log level during compile time.
This can be done by adding a dependency to tracing
and enabling the corresponding features.
For example to enable trace
messages for debug builds, but limit release builds to debug
add
the following in your binary crate Cargo.toml
:
[dependencies]
tracing = { version = "0.1", features = ["max_level_trace", "release_max_level_debug"] }
If you do not want to use tracing
for your compositor, refer to log compatibility
for how to forward smithays debug output to other log
compatible frameworks.
Modules§
- backend
- Backend (rendering/input) helpers
- desktop
desktop
- Desktop management helpers
- input
- Input abstractions
- output
- Output
- reexports
- Reexports of crates, that are part of the public api, for convenience
- utils
- Various utilities functions and types
- wayland
wayland_frontend
- Protocol-related utilities
- xwayland
xwayland
- XWayland utilities
Macros§
- delegate_
alpha_ modifier wayland_frontend
- Macro to delegate implementation of the alpha modifier protocol
- delegate_
commit_ timing wayland_frontend
- Macro used to delegate
WpCommitTimingManagerV1
events - delegate_
compositor wayland_frontend
- delegate_
content_ type wayland_frontend
- Macro to delegate implementation of the wp content type protocol
- delegate_
cursor_ shape wayland_frontend
- delegate_
data_ control wayland_frontend
- delegate_
data_ device wayland_frontend
- delegate_
dmabuf wayland_frontend
- Macro to delegate implementation of the linux dmabuf to
DmabufState
. - delegate_
drm_ lease backend_drm
andwayland_frontend
- Macro to delegate implementation of the drm-lease protocol to
DrmLeaseState
. - delegate_
drm_ syncobj backend_drm
andwayland_frontend
- Macro to delegate implementation of the drm syncobj protocol to
DrmSyncobjState
. - delegate_
ext_ data_ control wayland_frontend
- Macro to delegate implementation of the ext_data_control protocol
- delegate_
fifo wayland_frontend
- Macro used to delegate
WpFifoManagerV1
events - delegate_
foreign_ toplevel_ list wayland_frontend
- Macro to delegate implementation of the xdg toplevel icon to ForeignToplevelListState.
- delegate_
fractional_ scale wayland_frontend
- delegate_
idle_ inhibit wayland_frontend
- delegate_
idle_ notify wayland_frontend
- Macro to delegate implementation of the ext idle notify protocol
- delegate_
input_ method_ manager wayland_frontend
- delegate_
kde_ decoration wayland_frontend
- delegate_
keyboard_ shortcuts_ inhibit wayland_frontend
- Macro to delegate implementation of the keyboard shortcuts inhibit protocol
- delegate_
layer_ shell wayland_frontend
- Macro to delegate implementation of wlr layer shell to
WlrLayerShellState
. - delegate_
output wayland_frontend
- delegate_
pointer_ constraints wayland_frontend
- delegate_
pointer_ gestures wayland_frontend
- Macro to delegate implementation of the pointer gestures protocol
- delegate_
presentation wayland_frontend
- delegate_
primary_ selection wayland_frontend
- delegate_
relative_ pointer wayland_frontend
- Macro to delegate implementation of the relative pointer protocol
- delegate_
seat wayland_frontend
- delegate_
security_ context wayland_frontend
- Macro to delegate implementation of the security context protocol
- delegate_
session_ lock wayland_frontend
- delegate_
shm wayland_frontend
- delegate_
single_ pixel_ buffer wayland_frontend
- Macro used to delegate
WpSinglePixelBuffer
events - delegate_
tablet_ manager wayland_frontend
- delegate_
text_ input_ manager wayland_frontend
- delegate_
viewporter wayland_frontend
- delegate_
virtual_ keyboard_ manager wayland_frontend
- delegate_
xdg_ activation wayland_frontend
- Macro to delegate implementation of the xdg activation to
XdgActivationState
. - delegate_
xdg_ decoration wayland_frontend
- Macro to delegate implementation of the xdg decoration to
XdgDecorationState
. - delegate_
xdg_ dialog wayland_frontend
- Macro to delegate implementation of the xdg dialog to
XdgDialogState
. - delegate_
xdg_ foreign wayland_frontend
- Macro to delegate implementation of the xdg foreign to
XdgForeignState
. - delegate_
xdg_ shell wayland_frontend
- delegate_
xdg_ system_ bell wayland_frontend
- Macro to delegate implementation of the xdg system bell to
XdgSystemBellState
. - delegate_
xdg_ toplevel_ icon wayland_frontend
- Macro to delegate implementation of the xdg toplevel icon to
XdgToplevelIconManager
. - delegate_
xwayland_ keyboard_ grab xwayland
andwayland_frontend
- Macro to delegate implementation of the xwayland keyboard grab protocol
- delegate_
xwayland_ shell xwayland
andwayland_frontend
- Macro to delegate implementation of the xwayland keyboard grab protocol
- egl_
platform backend_egl
- Create a
EGLPlatform<'a>
for the provided platform. - render_
elements - Aggregate multiple types implementing
RenderElement
into a single enum type - space_
elements desktop
- Aggregate multiple types implementing
SpaceElement
into a single enum type to be used with aSpace
.