This commit is contained in:
1 parent
ccb809bdc3
commit
7caadb3f7f
59 files changed
+7495
-16
No files matched your search
@@ -366,3 +366,27 @@ pub struct WmState {
|
||||
}
|
||||
```
|
||||
All layout math (`compute_bsp_rects`, `insert_leaf`, `remove_leaf`, `focus_direction`, `hit_test_stack`) lives in `lib/wm/` as pure functions over `WmState`, unit-tested via `moon test` and integrated directly into `compositor/host/`.
|
||||
|
||||
---
|
||||
|
||||
## 9. `wasi-gfx` GUI Loading & Presentation Architecture
|
||||
|
||||
To load and present the `moon-plasma` GUI portably across both the native MoonBit compositor and WebAssembly/browser hosts, `moon-plasma` integrates the [wasi-gfx](https://wasi-gfx.dev/) WIT specification (`wasi-gfx:surface@0.2.0` and `wasi-gfx:frame-buffer@0.2.0`):
|
||||
|
||||
1. **WIT Contracts (`wit/gfx/`):**
|
||||
- `wit/gfx/deps/wasi-gfx-frame-buffer-0.2.0/frame-buffer.wit`: `wasi-gfx:frame-buffer/frame-buffer@0.2.0` (`buffer` resource with `get-with-copy` / `set-with-copy`).
|
||||
- `wit/gfx/deps/wasi-gfx-surface-0.2.0/surface.wit`: `wasi-gfx:surface/surface@0.2.0` (`surface` resource, `create-desc`, `resize-event`, `frame-event`, `pointer-event`, `key-event`, and `stream<...>` event channels).
|
||||
- `wit/gfx/deps/wasi-gfx-surface-0.2.0/surface-frame-buffer.wit`: `wasi-gfx:surface/surface-frame-buffer@0.2.0` (`context` resource binding a `surface` to `get-current-buffer()` + `present()`).
|
||||
- `wit/gfx/worlds.wit`: `moonplasma:gfx@0.2.0/gui-loader` world importing `wasi-gfx` and exporting `init-gui`, `render-frame`, `on-resize`, `on-pointer`, and `on-key`.
|
||||
|
||||
2. **MoonBit `wasi-gfx` GUI Component (`components/gfx-gui/`):**
|
||||
- Built with `wit-bindgen moonbit wit/gfx --world gui-loader` and `scripts/build-gfx.sh`.
|
||||
- Uses `@surface.Surface::surface`, `@sfb.Context::context`, `@scene.SceneGraph`, and `@renderer.render_scene` to render the desktop shell, Breeze-decorated windows, and launcher overlay into RGBA8888 pixel buffers and present them through `wasi-gfx`.
|
||||
|
||||
3. **Pure-MoonBit Native `wasi-gfx` Runtime (`compositor/gfx/`):**
|
||||
- Implements `Surface`, `FrameBuffer`, `SurfaceFrameBufferContext`, `present_pixmap`, and `present_scene` in pure MoonBit.
|
||||
- `MoonPlasmaCompositor::present_to_gfx` and `MoonPlasmaCompositor::handle_gfx_events` in `compositor/host/` connect the native Wayland compositor to `wasi-gfx` surfaces (also exposed via `--gfx-out <path.png>` in `compositor/bin/main.mbt`).
|
||||
|
||||
4. **JS / Browser `wasi-gfx` Host Adapter (`host/src/wasi-gfx.mjs`, `host/web/main.mjs`):**
|
||||
- Provides `WasiGfxSurface`, `WasiGfxBuffer`, `WasiGfxFrameBufferContext`, and `createWasiGfxHost()` for both `jco`-transpiled `wasi-gfx` components and the browser desktop shell (`host/web/main.mjs`), routing input streams and presenting RGBA8888 frames onto the `<canvas>`.
|
||||
|
||||
Reference in new issue
Block a user