Nested window backend: run the compositor in a window on the host Wayland session
CI / test (push) Successful in 26s
CI / test (push) Successful in 26s
The compositor opens an xdg_toplevel on $WAYLAND_DISPLAY, presents frames via wl_shm with frame-callback pacing and forwards host pointer input to the gfx surface. just run now uses it (release build); run-headless keeps the old mode. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a265eebf02
commit
a1b85474f8
5 files changed
+455
-6
No files matched your search
+39
-2
@@ -6,6 +6,7 @@ fn main {
|
||||
let mut socket_path = "/tmp/wayland-moon-0"
|
||||
let mut theme_path = "config/themes/moon-night.json"
|
||||
let mut gfx_out = ""
|
||||
let mut windowed = false
|
||||
let width = 1280
|
||||
let height = 720
|
||||
|
||||
@@ -18,6 +19,9 @@ fn main {
|
||||
} else if a == "--theme" && i + 1 < args.length() {
|
||||
theme_path = args[i + 1]
|
||||
i = i + 2
|
||||
} else if a == "--window" {
|
||||
windowed = true
|
||||
i = i + 1
|
||||
} else if a == "--gfx-out" && i + 1 < args.length() {
|
||||
gfx_out = args[i + 1]
|
||||
i = i + 2
|
||||
@@ -53,11 +57,44 @@ fn main {
|
||||
println("wasi-gfx frame written to " + gfx_out)
|
||||
return
|
||||
}
|
||||
let nested = if windowed {
|
||||
let display = match @env.get_env_var("WAYLAND_DISPLAY") {
|
||||
Some(d) => d
|
||||
None => "wayland-0"
|
||||
}
|
||||
let rt = match @env.get_env_var("XDG_RUNTIME_DIR") {
|
||||
Some(d) => d
|
||||
None => "/tmp"
|
||||
}
|
||||
match @nested.NestedWindow::open(display, rt, "moon-plasma", "moon-plasma", width, height) {
|
||||
Some(n) => Some(n)
|
||||
None => {
|
||||
println("failed to open a window on the host Wayland display")
|
||||
comp.close()
|
||||
return
|
||||
}
|
||||
}
|
||||
} else {
|
||||
None
|
||||
}
|
||||
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))
|
||||
match nested {
|
||||
Some(n) => {
|
||||
if !n.poll(gfx_surface) {
|
||||
break
|
||||
}
|
||||
comp.handle_gfx_events(gfx_surface)
|
||||
if n.frame_ready() {
|
||||
n.present(comp.present_to_gfx(gfx_ctx))
|
||||
}
|
||||
}
|
||||
None => {
|
||||
comp.handle_gfx_events(gfx_surface)
|
||||
ignore(comp.present_to_gfx(gfx_ctx))
|
||||
}
|
||||
}
|
||||
@sys.sleep_ms(16)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
"moonplasma/desktop/compositor/renderer" @renderer,
|
||||
"moonplasma/desktop/compositor/gfx" @gfx,
|
||||
"moonplasma/desktop/compositor/host" @host,
|
||||
"moonplasma/desktop/compositor/nested" @nested,
|
||||
}
|
||||
|
||||
supported_targets = "-all+native"
|
||||
|
||||
Reference in new issue
Block a user