glimmer-cosmic
The libcosmic backend for glimmer — a spike. The same hiccup that
glimmer-vidya paints with egui and glimmer-tui
paints in a terminal, painted with COSMIC's widgets and theme through
crates/jolt-cosmic.
cargo build --release -p jolt-cosmic
LD_LIBRARY_PATH=../../target/release jolt counter
LD_LIBRARY_PATH=../../target/release jolt smoke # non-interactive, quits itself
What is the same
The tree half is glimmer-vidya's. Nodes are integer handles in a Rust arena,
props are written across by name, handlers stay on the jolt side and are found
by node id when an event comes back, and a widget writes its new value into its
own props so a control that ignores its event still works.
What is not: who owns the loop
egui lets its caller drive frames. libcosmic does not: cosmic::app::run takes
the main thread (winit insists) and keeps it until the window closes. So the
loop is inverted:
main thread cosmic_run ──────────────────────────────────── returns on close
▲ wake(tree) │ click / change / toggled
worker (future) mount → commit → wait ─ drain, dispatch, timers → commit → wait …
- The reconciler runs on a worker, which is the "UI thread" as glimmer sees it:
schedulequeues onto it, handlers and timers run on it. - Its edits land in the arena under a mutex, but libcosmic paints a snapshot
taken atcosmic_tree_commit, once per pass. A reconcile half-way through a
patch is never on screen, and a pass that changed nothing commits nothing. - The worker sleeps in
cosmic_waituntil there is an event, aschedule, a
due timer or a close — an idle window costs neither side anything. - Every call but
cosmic_runis safe from any thread, which is not true of
libvidya.
Spike limits
- Tags:
:window:box/:hbox/:vbox:page:card:frame:scroll
:label:title:title-2:dim-label:button:checkbutton:entry
:separator:spacer:progress. Anything else paints as a column. - Events:
click,toggled,change,activate. - One window per process — winit cannot make a second event loop — so there is
no REPLstart!/stop!yet, and no headless test beyond the arena's own
Rust tests. - libcosmic is MPL-2.0 and a git dependency; see
crates/jolt-cosmic/Cargo.toml.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
|