Pedro M. de Echanove Pasquin 042652ec73
Some checks failed
CI / build + test (push) Has been cancelled
CI / cargo audit (push) Has been cancelled
windows: centralise input focus on a single FocusTarget, raise+focus on every window interaction
Focus was scattered across three stores — `Layouts::focus`, `Layers::focus` and `Windows::activated` — plus a hack that smuggled X11 surfaces through `Layers::focus`, with the keyboard target derived each frame from a `layers.focus.or(layout)` precedence. As a result "focused", "activated" and "has the keyboard" could drift apart: a window could be raised without taking the keyboard, the recurring "click a console window, then click it again before you can actually type" symptom.
New `windows/focus.rs` with `FocusTarget { Layout(Weak<Window>), Layer(WlSurface, app_id), X11(WlSurface) }`. `Windows` now holds one `focus_target: Option<FocusTarget>` as the single source of truth; `activated` survives only as a reconciliation cache for the xdg `Activated` state and is never set by hand. `set_focus` takes one `Option<FocusTarget>` and is the only entry point for changing focus: it brings the target to the front (`z_promote` + desktop stacking), refreshes the MRU and stores the target, and keyboard focus plus activation are applied from it on the next `focus()`. `focus()` resolves a baseline (the active layout's window, which carries `Activated`) and an overlay (a focused layer/X11 surface that takes the keyboard over the baseline without de-activating it), mirroring the old precedence but from one field, so keyboard focus follows focus by construction. `Layers::focus` is removed and X11 no longer rides inside it; the exclusive-keyboard layer path and `reap_layer` drive `focus_target` directly, and every click/touch/activation site collapses to `set_focus(Some(FocusTarget::…))`.
surface_at popup tie-break. When a layout hit is a popup or subsurface, its `wl_surface` is not tracked in `toplevel_z_order`, so the layout-vs-X11 z compare resolved to `None` and the X window underneath wrongly won — clicking a GTK menu (e.g. Firefox's) over an X11 window pressed the X window instead of the menu item. The tie-break now compares the owning toplevel's root z, taken from the hit's `FocusTarget::Layout` weak, so the popup's parent stacking decides.
Raise and focus on every window interaction, matching standard desktop behaviour. Client-driven (un)maximize, the SSD maximize/minimize/close buttons and the maximize keybind now bring the window to the front in both the render z-order and the hit-test stacking through a new `raise_toplevel` helper; previously only the stacking was updated, so an unmaximised window could stay visually behind another. Starting a move or resize — including a press on the resize edge — now routes through `set_focus`, so the window comes to the front and takes the keyboard before the drag instead of being resized or moved while it stays behind.
Input robustness around grabs and drags. A press under an active pointer grab (Wayland popup, drag-and-drop or explicit client grab) is routed to the grab instead of forge's own surface_at handling, so a click cannot leak to a window underneath a grabbing popup and a click outside the popup dismisses it cleanly. Only the press is blocked, never the release, so an in-flight move/resize drag or topbar swipe always reaches its end handler and can never stay glued to the cursor if a grab appears mid-gesture. `on_touch_up` now ends any active move/resize drag before its other early-return paths (armed SSD button, topbar swipe, app switcher) and drops a stale armed button, fixing a race where pressing a second, overlapping window left the drag running forever after release.
fix(input): keep the primary touch slot when migrating a drag across surfaces
A touch drag started on an overlay that hides mid-gesture (e.g. the app launcher when dropping an icon onto the dock or the homescreen) froze: it neither moved nor dropped. Destroying the origin surface migrated the drag state (long_press_fired / long_press_origin) and touch_focus to the main surface, but not its primary_touch_id; subsequent touch motion/up events then fell through the auxiliary path and never reached the gesture machine, leaving on_drag_move and on_drop uncalled.
reconcile_overlays and discard_overlay now adopt the destroyed overlay's primary_touch_id when a drag is in flight, so the rest of the touch sequence keeps driving the main surface. Touch-only; the mouse already migrated correctly via pointer_focus.
ltk: add a chassis module for full-screen ambient surfaces
New `src/chassis.rs`, re-exported from the crate root, gathers the scaffolding that every full-screen ambient surface — greeter, lock screen, kiosk — otherwise repeats by hand over the existing theme and `WallpaperBundle` primitives. `set_default_theme(mode)` finds, installs and activates the `default` theme document, returning the failure message instead of exiting so the caller decides how to abort. `theme_logo_rgba(size)` decodes the active theme's horizontal logo to RGBA, and `theme_icon_tinted(name, size, tint)` loads a symbolic theme icon and tints it. `branding_bundle_or_solid(name)` resolves a theme branding image (`"wallpaper"`, `"lockscreen"`, …) to a `WallpaperBundle`, falling back to a solid fill of the palette background when the theme ships none; `wallpaper_bundle_or_solid()` is the `"wallpaper"` convenience. `backdrop(content, &wallpaper, w, h)` stacks content over the wallpaper resolved for the surface size. No new capability — thin convenience over what the theme module and `WallpaperBundle` already expose — but it removes the per-application `load_theme_logo` / `build_wallpaper_bundle` / theme-bootstrap duplication.
ltk: animatable, input-transparent child surfaces via App::subsurfaces()
New `App::subsurfaces() -> Vec<SubsurfaceSpec<Msg>>` (default empty) describes input-transparent child surfaces composited over the main surface, with `SubsurfaceSpec { id, view, x, y, content_version }` and the stable `SubsurfaceId`. The motivating use is a slide/reveal that tracks a finger without the per-frame full-screen CPU re-raster a single-surface opacity or translate would cost: the content buffer is rasterised once and the compositor moves it.
`SubcompositorState` is bound in `event_loop/run.rs` from the compositor's `wl_compositor` (absent → `App::subsurfaces` silently degrades to none); `delegate_subcompositor!` is added on `AppData`, which gains a `subcompositor` binding and a `subsurfaces` map. New `event_loop/subsurface.rs` reconciles the live subsurfaces against the specs: each spec becomes a `wl_subsurface` sized to the main surface with an empty input region, so all pointer/touch falls through to the parent and the host keeps a single gesture/input model. The content — its own SHM pool and `Canvas`, drawn through the existing `DrawCtx` / `layout_and_draw` path — is rasterised only when the surface size or the spec's `content_version` changes; a position-only change emits `wl_subsurface.set_position` and commits the child surface, then a bare parent commit for placement. Committing the child is deliberate: desync subsurface state (the position) is applied on the child surface's own commit, not the parent's, so without it the move is queued but never lands. Positions are given in layout (physical) pixels and divided by the surface scale for the logical `set_position`.
The reconcile pass runs on every run-loop iteration rather than being gated behind a main-surface redraw, so a finger-driven move repositions at input-event rate, decoupled from the frame-callback cadence that paces full redraws — without this the subsurface only moved when the main surface happened to redraw, so a drag over a static background froze the panel in place.
2026-05-29 23:28:48 +02:00
2026-05-10 09:58:23 +02:00
2026-05-10 09:58:23 +02:00
2026-05-10 09:58:23 +02:00
2026-05-10 09:58:23 +02:00
2026-05-10 09:58:23 +02:00
2026-05-10 09:58:23 +02:00

ltk

ltk is a public Rust UI toolkit for Wayland applications.

It is developed by Liberux as part of the Eydos stack, where it powers shell and application surfaces, but it is published as a reusable library for third-party developers building their own Wayland software.

Being written in Rust is also part of the project's value proposition:

  • memory safety without a garbage collector
  • predictable resource lifetimes through ownership and borrowing
  • good control over allocations and data movement in rendering-heavy code
  • a strong fit for low-level UI, graphics, and system-integration work

For a Wayland toolkit, that combination is useful in practice: it reduces an entire class of memory-management bugs common in lower-level UI stacks while still allowing tight control over performance-sensitive paths.

What It Is

ltk is a lightweight, declarative toolkit with an Elm-shaped model:

  • implement App
  • return an Element<Msg> tree from view()
  • update your state in update()
  • run the event loop with ltk::run(app)

The runtime handles layout, drawing, input dispatch, focus, overlays, and backend selection between GLES and software rendering.

What It Is Not

ltk is not:

  • a browser UI toolkit
  • a cross-platform desktop toolkit
  • a general-purpose web-style framework

Today it is specifically a Wayland toolkit. If you are building native Wayland applications, panels, launchers, lock screens, or other shell-adjacent surfaces, it is in scope. If you need Windows, macOS, or browser targets, it is not.

Project Status

ltk is a public library intended for third-party use, but it is still shaped by real production needs inside the Liberux / Eydos ecosystem.

That means:

  • the API is usable for external applications today
  • the project is optimized first for native Wayland workloads
  • some advanced APIs are still more shell-oriented than app-oriented
  • public documentation and examples are present, but the project is not trying to present itself as a cross-platform beginner toolkit

If you are evaluating ltk for a third-party application, the right mental model is "public Wayland toolkit with production consumers" rather than "experimental demo crate".

Why Third Parties Might Use It

ltk is designed around a few practical goals:

  • low idle wakeups and event-driven redraws
  • partial redraws and damage tracking
  • a simple declarative tree instead of retained widgets
  • direct support for normal windows, layer-shell, and ext-session-lock surfaces
  • a runtime-free core (ltk::core::UiSurface) for embedding layout and drawing without ltk::run()

This makes it especially relevant for:

  • Wayland applications
  • mobile-first Linux shells
  • launchers and dashboards
  • greeters and lock screens
  • compositor-side or embedded UI surfaces

Quick Start

Add ltk to your Cargo.toml:

[dependencies]
ltk = { path = "../ltk" }

Minimal app:

use ltk::{ App, Element, button, column, spacer, text };

#[derive(Clone)]
enum Msg
{
    Increment,
}

struct CounterApp
{
    value: u32,
}

impl App for CounterApp
{
    type Message = Msg;

    fn view( &self ) -> Element<Msg>
    {
        column::<Msg>()
            .padding( 32.0 )
            .spacing( 16.0 )
            .center_y( true )
            .push( text( "Hello from ltk" ).size( 28.0 ) )
            .push( text( format!( "Count: {}", self.value ) ).size( 18.0 ) )
            .push( spacer() )
            .push( button( "Increment" ).on_press( Msg::Increment ) )
            .into()
    }

    fn update( &mut self, msg: Msg )
    {
        match msg
        {
            Msg::Increment => self.value += 1,
        }
    }
}

fn main()
{
    ltk::run( CounterApp { value: 0 } );
}

Requirements

ltk currently assumes:

  • Rust 1.85 or newer (the toolchain shipped with Debian stable; declared as rust-version in Cargo.toml).
  • A running Wayland session — there is no X11 backend.
  • System headers for libwayland, libegl and libxkbcommon at compile time. On Debian / Ubuntu:
    sudo apt-get install libwayland-dev libegl-dev libxkbcommon-dev pkg-config
    
  • A usable system font (fonts-sora, fonts-liberation, fonts-dejavu, …). If none is installed ltk falls back to an embedded Sora Regular build with a stderr warning.
  • A theme named default, installed system-wide (the ltk-theme-default Debian package drops it under /usr/share/ltk/themes/default/) or exposed through LTK_THEMES_DIR for development.

Rendering backend selection is automatic:

  • GLES when EGL is available (every modern Wayland compositor).
  • Software fallback otherwise.
  • Set LTK_FORCE_SOFTWARE=1 to force the software path even when EGL is available — useful for headless test runs and for diagnosing driver-specific bugs.

For development inside this repository:

export LTK_THEMES_DIR="$PWD/themes"
cargo run --example showcase

Examples

Useful entry points in this repository:

  • cargo run --example showcase
  • cargo run --example widgets
  • cargo run --example inputs
  • cargo run --example scroll
  • cargo run --example combo
  • cargo run --example dialog
  • cargo run --example sliders
  • cargo run --example pickers
  • cargo run --example mini_shell

In general:

  • start with showcase for a regular app window
  • use widgets to see the core controls
  • use mini_shell if you need overlays, theme switching, or shell-style composition

Public API Overview

Most applications should start with this subset:

  • App
  • Element<Msg>
  • widgets such as button, text, text_edit, image
  • layouts such as column, row, stack, grid, spacer
  • Color
  • run

More advanced APIs are available when needed:

  • overlays()
  • shell_mode() and layer-shell controls
  • set_channel_sender() and poll_external()
  • gesture hooks such as on_swipe_*
  • core::UiSurface
  • runtime theme APIs

Windows and Shell Surfaces

By default, ltk creates a regular xdg-shell window.

That is the right starting point for:

  • normal applications
  • internal tools
  • prototypes

Switch to layer-shell only when you are building shell surfaces such as:

  • top bars
  • docks
  • homescreens
  • notifications
  • greeters
  • lock screens

For a screen locker, use ShellMode::SessionLock instead of layer-shell: it presents an ext-session-lock-v1 surface that the compositor keeps on top of everything until the app returns true from requested_exit(), which makes the runtime call unlock and lift the lock.

Performance Notes

ltk is designed to sleep when idle and redraw only on real work.

The main rules for downstream applications are:

  • keep view() pure and cheap
  • do not perform I/O inside view()
  • use poll_interval() sparingly
  • return true from is_animating() only while something is actually moving
  • cache decoded images and expensive derived state in your app

The library already provides:

  • event-driven redraw scheduling
  • per-surface invalidation
  • partial redraws for interaction-only changes
  • GPU and software backends behind the same widget API

Backend Differences

The public API is the same across backends, but visual parity is not perfect yet. The widget tree, layout, hit-testing, text, images, fills, strokes, clipping and gradients all paint identically on both paths. The gap is in the shadow / backdrop pipeline.

Effects that currently render only on the GLES backend, and are silent no-ops on the Software backend:

  • Outer drop shadows (Canvas::fill_shadow_outer) — themed surfaces that declare a Shadow slot show the soft halo on GLES and a flat fill on software.
  • Inner / inset shadows (Canvas::fill_shadow_inset) — InsetShadow slots paint nothing on software.
  • Inset shadow blend modesPlusLighter, Multiply, Screen and Overlay are GLES-only; the GLES Overlay path snapshots the framebuffer and computes the CSS Overlay formula in-shader, which has no software equivalent today.

Calls to these APIs are safe on both backends — they simply produce a flatter appearance under software. No widget panics, returns an error, or skips unrelated drawing.

If your application leans heavily on shadows or inset effects, validate both rendering paths before shipping. Force the software path with:

LTK_FORCE_SOFTWARE=1 cargo run --example showcase

Closing this gap (porting the shadow / inset-shadow pipeline to tiny-skia) is on the post-v0.1 roadmap.

Documentation

File When to read it
docs/onboarding.md First hour with the library — environment, first app, what to ignore at first.
docs/architecture.md Runtime model, overlays, animation, theming, performance and where the cost of a frame lives.
docs/widgets.md Per-widget catalogue: what each one is, when to use it, minimal example, see-also.
docs/theming.md JSON theme schema, slot conventions, runtime APIs.
docs/cookbook.md Concrete recipes — slide-in panels, password fields, runtime theme toggle, channel-driven state, embedding without ltk::run.
cargo doc --open Per-item rustdoc for the public API.
SECURITY.md How to report a vulnerability and what is in / out of scope.
CONTRIBUTING.md Build, test, code style, patch shape.

Recommended reading order for a new contributor:

  1. run examples/showcase.rs
  2. read docs/onboarding.md
  3. browse docs/widgets.md for the catalogue
  4. dip into docs/cookbook.md when you hit a specific shape
  5. open docs/architecture.md once you need overlays, animations, or runtime theming.

Relationship to Liberux and Eydos

Liberux is the promoter and primary maintainer of ltk.

The project exists because Eydos needs a native Wayland toolkit for its own shell and application stack, but ltk is intentionally published as a public library rather than kept as a private internal component. Third-party developers are part of the intended audience.

That origin matters because it explains the current priorities:

  • strong Wayland focus
  • support for layer-shell and shell-style overlays
  • attention to mobile power usage
  • theming and runtime surfaces that fit an operating system environment

License

This project is licensed under LGPL-2.1-only.

That means third parties can use ltk in their own applications, including proprietary ones, subject to the obligations of the GNU Lesser General Public License v2.1. If you are planning a commercial or closed-source product, read the license text carefully and make sure your distribution model complies with it.

See LICENSE.

Third-party assets

ltk's default theme bundles two third-party asset sets that travel under their own licences. Anyone redistributing the toolkit (or a binary that embeds the default theme) must propagate the attributions below.

The remaining artwork in the default theme — wallpapers, lockscreens, launcher logo, brand-mark variants and per-application icons — is original to Liberux Labs and travels under the toolkit's own LGPL-2.1-only licence.

The full Debian-style declaration of every asset and its licence lives in debian/copyright; that is the file the .deb ships under /usr/share/doc/libltk*/copyright.

Contributing

Patches and bug reports are welcome. Read CONTRIBUTING.md for the practical mechanics: build prerequisites, how to run tests, the project's Modified Allman code style, and what shape a pull request should take.

For security-sensitive issues see SECURITY.md — please do not file those through the public issue tracker.

If you are evaluating ltk for a third-party product and are unsure whether your use case is in scope, open a discussion before writing code. That is especially useful when you are:

  • missing an app-facing example,
  • blocked by a shell-oriented assumption in the API,
  • trying to understand whether a given platform target is realistic.
Description
Liberux ToolKit
Readme LGPL-2.1 6 MiB
Languages
Rust 97.7%
RenderScript 2%
Shell 0.2%
Makefile 0.1%