feat(gfx): integrate wasi-gfx for loading and presenting GUI
CI / test (push) Successful in 24s

This commit is contained in:
Antigravity committed 2026-11-25 02:54:03 +00:00
1 parent ccb809bdc3
commit 7caadb3f7f
59 files changed
+7495 -16

No files matched your search

+22 -2
View File
@@ -1,10 +1,11 @@
///| Standalone native MoonBit Wayland compositor entrypoint.
///| Standalone native MoonBit Wayland compositor entrypoint with wasi-gfx presentation.
///|
fn main {
let args = @env.args()
let mut socket_path = "/tmp/wayland-moon-0"
let mut theme_path = "config/themes/moon-night.json"
let mut gfx_out = ""
let width = 1280
let height = 720
@@ -17,6 +18,9 @@ fn main {
} else if a == "--theme" && i + 1 < args.length() {
theme_path = args[i + 1]
i = i + 2
} else if a == "--gfx-out" && i + 1 < args.length() {
gfx_out = args[i + 1]
i = i + 2
} else {
i = i + 1
}
@@ -33,11 +37,27 @@ fn main {
@scene.ThemeTokens::moon_night()
}
let gfx_surface = @gfx.Surface::new({
width: Some(width),
height: Some(height),
})
let gfx_ctx = @gfx.SurfaceFrameBufferContext::new(gfx_surface)
match @host.MoonPlasmaCompositor::new(socket_path, theme, width, height) {
Some(comp) => {
println("moon-plasma compositor listening on " + socket_path)
if gfx_out.length() > 0 {
let pixmap = comp.present_to_gfx(gfx_ctx)
let png = @renderer.encode_png(pixmap)
ignore(@sys.write_file_bytes(gfx_out, png))
comp.close()
println("wasi-gfx frame written to " + gfx_out)
return
}
println("moon-plasma compositor listening on " + socket_path + " (wasi-gfx surface active)")
while true {
comp.step()
comp.handle_gfx_events(gfx_surface)
ignore(comp.present_to_gfx(gfx_ctx))
@sys.sleep_ms(16)
}
}
+2
View File
@@ -3,6 +3,8 @@ import {
"moonbitlang/core/env",
"moonplasma/desktop/compositor/sys" @sys,
"moonplasma/desktop/compositor/scene" @scene,
"moonplasma/desktop/compositor/renderer" @renderer,
"moonplasma/desktop/compositor/gfx" @gfx,
"moonplasma/desktop/compositor/host" @host,
}