nandi/jolt-nativepublic Fork 0
4f920afa410da72bfdb7a07d7faa0264c7bb8a08
Commits
Clone
git clone https://git.rickub.com/nandi/jolt-native.git
git clone ssh://git@rickub.com/nandi/jolt-native.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

README.md · 65 lines · 3.3 KBmarkdown Blame HistoryRaw
glimmer-cosmic: a libcosmic backend for glimmer (spike) 6a3304d nandi 8d ago1# glimmer-cosmic
2
3The **libcosmic** backend for glimmer — a spike. The same hiccup that
4[glimmer-vidya](../glimmer-vidya) paints with egui and [glimmer-tui](../glimmer-tui)
5paints in a terminal, painted with COSMIC's widgets and theme through
6[`crates/jolt-cosmic`](../../crates/jolt-cosmic).
7
8```bash
9cargo build --release -p jolt-cosmic
10LD_LIBRARY_PATH=../../target/release jolt counter
11LD_LIBRARY_PATH=../../target/release jolt smoke # non-interactive, quits itself
12```
13
14## What is the same
15
16The tree half is glimmer-vidya's. Nodes are integer handles in a Rust arena,
17props are written across by name, handlers stay on the jolt side and are found
18by node id when an event comes back, and a widget writes its new value into its
19own props so a control that ignores its event still works.
20
21## What is not: who owns the loop
22
23egui lets its caller drive frames. libcosmic does not: `cosmic::app::run` takes
24the main thread (winit insists) and keeps it until the window closes. So the
25loop is inverted:
26
27```
28main thread cosmic_run ──────────────────────────────────── returns on close
29 ▲ wake(tree) │ click / change / toggled
30worker (future) mount → commit → wait ─ drain, dispatch, timers → commit → wait …
31```
32
33* The reconciler runs on a worker, which is the "UI thread" as glimmer sees it:
34 `schedule` queues onto it, handlers and timers run on it.
35* Its edits land in the arena under a mutex, but libcosmic paints a snapshot
36 taken at `cosmic_tree_commit`, once per pass. A reconcile half-way through a
37 patch is never on screen, and a pass that changed nothing commits nothing.
38* The worker sleeps in `cosmic_wait` until there is an event, a `schedule`, a
39 due timer or a close — an idle window costs neither side anything.
40* Every call but `cosmic_run` is safe from any thread, which is not true of
41 libvidya.
42
43## Spike limits
44
45* Tags: `:window` `:box`/`:hbox`/`:vbox` `:page` `:card` `:frame` `:scroll`
Paint the rest of frq's tags in glimmer-cosmic 7703c75 nandi 8d ago46 `:label` `:title` `:title-2` `:dim-label` `:button` `:link` `:checkbutton`
47 `:entry` `:separator` `:spacer` `:progress` `:status` `:spinner` `:image`
48 `:avatar` `:emoji` `:reaction`. Anything else paints as a column.
49* Layout follows glimmer-jvui: a container fills its parent's cross axis,
50 `:fill-height` takes what is left, `:width-request 0` is no request, and
51 `:margin`/`:margin-top``:spacing` `:align` are read.
52* `:scroll` fills both ways, follows new rows while `:stick-to-bottom` and the
53 reader is at the end, jumps when `:scroll-to-bottom` changes, keeps its place
54 by `:scroll-key` across a remount, reports `"end"`/`"away"` on `:on-change`,
55 and moves to a row that sets `:scroll-here` — by the row's index, since there
56 is no layout to ask, so it is close rather than exact in a list of rows of
57 different heights.
58* Events: `click`, `toggled`, `change`, `activate`, `hover`, `unhover`.
59* Not yet: `:image {:feed …}` (live frames; the slot is drawn empty), a
60 wrapping `:hbox {:wrap true}`, `:on-rows` `:on-paste-empty` `:on-key` on an
61 entry, `:max-rows` (the entry is one line).
glimmer-cosmic: a libcosmic backend for glimmer (spike) 6a3304d nandi 8d ago62* One window per process — winit cannot make a second event loop — so there is
63 no REPL `start!`/`stop!` yet, and no headless test beyond the arena's own
64 Rust tests.
65* libcosmic is MPL-2.0 and a git dependency; see `crates/jolt-cosmic/Cargo.toml`.