Expand description
layer-shika: A Wayland layer shell library with Slint UI integration
This crate provides a high-level API for creating Wayland widget components with Slint-based user interfaces. It’s built on a clean architecture with three internal layers (domain, adapters, composition), but users should only depend on this root crate.
§Architecture Note
layer-shika is internally organized as a Cargo workspace with three implementation crates:
layer-shika-domain: Core domain models and business logiclayer-shika-adapters: Wayland and rendering implementationslayer-shika-composition: Public API composition layer
Users should never import from these internal crates directly. This allows the internal architecture to evolve without breaking semver guarantees on the public API.
§Module Organization
The API is organized into conceptual facets:
shell– Main runtime and shell composition typeswindow– Surface configuration, layers, anchors, and popup typesoutput– Output (monitor) info, geometry, and policiesevent– Event loop handles and contextsslint_integration– Slint framework re-exports and wrapperscalloop– Event loop types for custom event sources
§Quick Start (Fluent Builder)
Single-surface use case with the fluent builder API:
use layer_shika::prelude::*;
Shell::from_file("ui/bar.slint")
.surface("Main")
.height(42)
.anchor(AnchorEdges::top_bar())
.exclusive_zone(42)
.build()?
.run()?;See the simple-bar example for a complete working implementation.
§Declarative Configuration
For reusable, programmatically generated, or externally sourced configurations:
use layer_shika::prelude::*;
let config = ShellConfig {
ui_source: CompiledUiSource::file("ui/bar.slint"),
surfaces: vec![
SurfaceComponentConfig::with_config("Bar", SurfaceConfig {
dimensions: SurfaceDimension::new(0, 42),
anchor: AnchorEdges::top_bar(),
exclusive_zone: 42,
..Default::default()
}),
],
};
Shell::from_config(config)?.run()?;See the declarative-config example for a complete working implementation.
§Multi-Surface Shell
Same API naturally extends to multiple surfaces:
use layer_shika::prelude::*;
Shell::from_file("ui/shell.slint")
.surface("TopBar")
.height(42)
.anchor(AnchorEdges::top_bar())
.surface("Dock")
.height(64)
.anchor(AnchorEdges::bottom_bar())
.build()?
.run()?;See the multi-surface example for a complete working implementation.
§Pre-compiled Slint
For explicit compilation control:
use layer_shika::prelude::*;
let compilation = Shell::compile_file("ui/shell.slint")?;
Shell::from_compilation(compilation)
.surface("TopBar")
.output_policy(OutputPolicy::AllOutputs)
.height(42)
.surface("Dock")
.output_policy(OutputPolicy::PrimaryOnly)
.height(64)
.build()?
.run()?;§Examples
Comprehensive examples demonstrating all features are available in the examples directory.
Run any example with: cargo run -p <example-name>
Re-exports§
pub use slint_integration::slint;pub use slint_integration::slint_interpreter;
Modules§
- calloop
- event
- output
- prelude
- Prelude module re-exporting all public API types
- shell
- slint_
integration - window
Structs§
- Anchor
Edges - Represents which edges of the output a layer surface should be anchored to.
- Callback
Context - Context provided to callback handlers with surface and control information
- Event
Dispatch Context - Event
Loop Handle - Handle for registering custom event sources with the event loop
- Handle
- Type-safe unique identifier for runtime resources
- Layer
Surface Handle - Low-level handle for configuring layer-shell surface properties
- Output
Geometry - Physical geometry and properties of an output
- Output
Info - Runtime information about a connected output (monitor)
- Output
Registry - Popup
Request - Configuration for showing a popup window
- Popup
Window - Selection
- A selection of surfaces matching a selector
- Selector
- Combined surface and output selector for precise targeting
- Shell
- Main runtime for managing Wayland layer-shell surfaces with Slint UI
- Shell
Builder - Builder for configuring and creating a Shell with one or more surfaces
- Shell
Config - Declarative configuration for creating a shell with multiple surfaces
- Shell
Control - Handle for runtime control of shell operations
- Shell
Event Context - Context providing access to shell state within custom event source callbacks
- Shell
Event Loop - Main event loop for the shell runtime
- Surface
Component Config - Associates a Slint component name with its surface configuration
- Surface
Config Builder - Builder for configuring a single surface within a Shell
- Surface
Definition - Definition of a surface including component name and configuration
- Surface
Info - Runtime information about a surface instance
- Surface
Instance Id
Enums§
- Anchor
Strategy - Strategy for calculating popup position relative to an anchor rectangle
- Compiled
UiSource - Source for Slint UI definition
- Error
- Error types for layer-shika operations
- Keyboard
Interactivity - Controls how a surface receives keyboard input
- Layer
- Vertical stacking layer for layer-shell surfaces
- Output
- Selector for targeting outputs (monitors) in runtime operations
- Output
Policy - Determines which outputs (monitors) should display the surface
- Popup
Placement - Where to position a popup relative to the surface
- Popup
Positioning Mode - Alignment mode for popup positioning
- Popup
Size - How to size a popup window
- Surface
- Selector for targeting surfaces when setting up callbacks or runtime configuration
- Surface
Target
Constants§
- DEFAULT_
COMPONENT_ NAME - Default Slint component name used when none is specified
- DEFAULT_
SURFACE_ NAME - Default surface name used internally
Traits§
- Shell
Runtime - Trait providing runtime access to shell components and event loop
- Shell
Surface Config Handler
Type Aliases§
- Output
Handle - Unique identifier for an output (monitor)
- Popup
Handle - Unique identifier for a popup window
- Result
- Result type alias using layer-shika’s Error
- Surface
Handle - Unique identifier for a layer surface