moon-plasma / moonplasma / MoonPlasma / Moon Plasma become chandra / Chandra everywhere: the WIT package (chandra:desktop, chandra:host, chandra:wm), the MoonBit module (chandra/desktop) and generated bindings, the Rust host, identifiers (ChandraCompositor), the session script (chandra-session) and desktop entry (chandra.desktop), config and data paths ($XDG_CONFIG_HOME/chandra, share/chandra/modules), env vars (CHANDRA_*), UI strings, docs and tests. The test fixture components are rebuilt against the renamed WIT. Saved panel.edn and state.edn are still read from the old $XDG_CONFIG_HOME/moon-plasma until the first save writes the new copy. The remote repository keeps its experiments/moon-plasma name for now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DPL5hi3L9oVBoRd373Qr4n
This commit is contained in:
323 files changed
+1055
-1013
No files matched your search
+37
-37
@@ -1,12 +1,12 @@
|
||||
//! Native host for the moon-plasma compositor component.
|
||||
//! Native host for the chandra compositor component.
|
||||
//!
|
||||
//! The compositor is a wasm component (build/compositor.wasm) that imports exactly one
|
||||
//! interface, `moonplasma:host/sys` (wit/host/sys.wit): sockets, memfd, poll, spawn, files, time.
|
||||
//! interface, `chandra:host/sys` (wit/host/sys.wit): sockets, memfd, poll, spawn, files, time.
|
||||
//! This program is the other side of that interface. The component only ever holds integer
|
||||
//! handles; every real file descriptor lives here.
|
||||
//!
|
||||
//! moon-plasma-host [--component PATH] [-- compositor args...]
|
||||
//! moon-plasma-host build/compositor.wasm --socket /run/user/1000/wayland-moon-0 --window
|
||||
//! chandra-host [--component PATH] [-- compositor args...]
|
||||
//! chandra-host build/compositor.wasm --socket /run/user/1000/wayland-moon-0 --window
|
||||
|
||||
use std::ffi::CString;
|
||||
use std::io::Read;
|
||||
@@ -28,13 +28,13 @@ wasmtime::component::bindgen!({
|
||||
// Draw operations are compared to reuse the cached wallpaper.
|
||||
additional_derives: [PartialEq],
|
||||
with: {
|
||||
"moonplasma:desktop/types@0.1.0": plasmoid::ph::moonplasma::desktop::types,
|
||||
"moonplasma:desktop/theme@0.1.0": plasmoid::ph::moonplasma::desktop::theme,
|
||||
"chandra:desktop/types@0.1.0": plasmoid::ph::chandra::desktop::types,
|
||||
"chandra:desktop/theme@0.1.0": plasmoid::ph::chandra::desktop::theme,
|
||||
},
|
||||
});
|
||||
|
||||
use moonplasma::host::font::Glyph;
|
||||
use moonplasma::host::sys::{Host, Received};
|
||||
use chandra::host::font::Glyph;
|
||||
use chandra::host::sys::{Host, Received};
|
||||
|
||||
#[derive(Default)]
|
||||
struct State {
|
||||
@@ -44,7 +44,7 @@ struct State {
|
||||
started: Option<std::time::Instant>,
|
||||
/// TTF faces loaded by the component (`font.load`), by slot, and their glyph cache.
|
||||
fonts: raster::Fonts,
|
||||
/// The framebuffer and client surfaces behind `moonplasma:host/raster`.
|
||||
/// The framebuffer and client surfaces behind `chandra:host/raster`.
|
||||
raster: raster::Raster,
|
||||
/// Runs the panel modules; set once the engine exists.
|
||||
pl: Option<plasmoid::Runtime>,
|
||||
@@ -123,10 +123,10 @@ impl State {
|
||||
}
|
||||
}
|
||||
|
||||
impl moonplasma::host::plasmoids::Host for State {
|
||||
fn load(&mut self, path: String) -> Result<moonplasma::host::plasmoids::Loaded, String> {
|
||||
impl chandra::host::plasmoids::Host for State {
|
||||
fn load(&mut self, path: String) -> Result<chandra::host::plasmoids::Loaded, String> {
|
||||
let l = self.pl().load(&path)?;
|
||||
Ok(moonplasma::host::plasmoids::Loaded {
|
||||
Ok(chandra::host::plasmoids::Loaded {
|
||||
handle: l.handle,
|
||||
id: l.info.id,
|
||||
name: l.info.name,
|
||||
@@ -141,27 +141,27 @@ impl moonplasma::host::plasmoids::Host for State {
|
||||
self.pl().unload(handle);
|
||||
}
|
||||
|
||||
fn set_tokens(&mut self, t: plasmoid::ph::moonplasma::desktop::theme::Tokens) {
|
||||
fn set_tokens(&mut self, t: plasmoid::ph::chandra::desktop::theme::Tokens) {
|
||||
self.pl().shared.borrow_mut().tokens = Some(t);
|
||||
}
|
||||
|
||||
fn render(
|
||||
&mut self,
|
||||
handle: u32,
|
||||
box_: plasmoid::ph::moonplasma::desktop::types::Size,
|
||||
) -> Vec<plasmoid::ph::moonplasma::desktop::types::DrawOp> {
|
||||
box_: plasmoid::ph::chandra::desktop::types::Size,
|
||||
) -> Vec<plasmoid::ph::chandra::desktop::types::DrawOp> {
|
||||
self.pl().render(handle, box_)
|
||||
}
|
||||
|
||||
fn popup(&mut self, handle: u32) -> Option<moonplasma::host::plasmoids::PopupSurface> {
|
||||
self.pl().popup(handle).map(|p| moonplasma::host::plasmoids::PopupSurface { box_: p.size, ops: p.ops })
|
||||
fn popup(&mut self, handle: u32) -> Option<chandra::host::plasmoids::PopupSurface> {
|
||||
self.pl().popup(handle).map(|p| chandra::host::plasmoids::PopupSurface { box_: p.size, ops: p.ops })
|
||||
}
|
||||
|
||||
fn on_event(
|
||||
&mut self,
|
||||
handle: u32,
|
||||
on_popup: bool,
|
||||
event: plasmoid::ph::moonplasma::desktop::types::InputEvent,
|
||||
event: plasmoid::ph::chandra::desktop::types::InputEvent,
|
||||
) -> bool {
|
||||
self.pl().on_event(handle, on_popup, event)
|
||||
}
|
||||
@@ -183,8 +183,8 @@ impl moonplasma::host::plasmoids::Host for State {
|
||||
self.pl().shared.borrow_mut().wallpaper = current;
|
||||
}
|
||||
|
||||
fn publish_system(&mut self, s: moonplasma::host::plasmoids::SystemSnapshot) {
|
||||
use plasmoid::ph::moonplasma::desktop::system::Snapshot;
|
||||
fn publish_system(&mut self, s: chandra::host::plasmoids::SystemSnapshot) {
|
||||
use plasmoid::ph::chandra::desktop::system::Snapshot;
|
||||
self.pl().shared.borrow_mut().system = Some(Snapshot {
|
||||
cpu_permille: s.cpu_permille,
|
||||
mem_used_kib: s.mem_used_kib,
|
||||
@@ -198,13 +198,13 @@ impl moonplasma::host::plasmoids::Host for State {
|
||||
});
|
||||
}
|
||||
|
||||
fn publish_windows(&mut self, wins: Vec<moonplasma::host::plasmoids::WindowEntry>) {
|
||||
fn publish_windows(&mut self, wins: Vec<chandra::host::plasmoids::WindowEntry>) {
|
||||
self.pl().shared.borrow_mut().windows =
|
||||
wins.into_iter().map(|w| (w.id, w.title, w.app_id, w.focused)).collect();
|
||||
}
|
||||
|
||||
fn next_request(&mut self) -> Option<moonplasma::host::plasmoids::Request> {
|
||||
use moonplasma::host::plasmoids::Request as R;
|
||||
fn next_request(&mut self) -> Option<chandra::host::plasmoids::Request> {
|
||||
use chandra::host::plasmoids::Request as R;
|
||||
use plasmoid::Req;
|
||||
let r = self.pl().shared.borrow_mut().requests.pop_front()?;
|
||||
Some(match r {
|
||||
@@ -239,8 +239,8 @@ impl moonplasma::host::plasmoids::Host for State {
|
||||
self.pl().picker_start()
|
||||
}
|
||||
|
||||
fn picker_poll(&mut self) -> moonplasma::host::plasmoids::PickerState {
|
||||
use moonplasma::host::plasmoids::PickerState as P;
|
||||
fn picker_poll(&mut self) -> chandra::host::plasmoids::PickerState {
|
||||
use chandra::host::plasmoids::PickerState as P;
|
||||
match self.pl().picker_poll() {
|
||||
None => P::Open,
|
||||
Some(None) => P::Cancelled,
|
||||
@@ -249,8 +249,8 @@ impl moonplasma::host::plasmoids::Host for State {
|
||||
}
|
||||
}
|
||||
|
||||
impl moonplasma::host::display::Host for State {
|
||||
fn open(&mut self) -> Option<moonplasma::host::display::Output> {
|
||||
impl chandra::host::display::Host for State {
|
||||
fn open(&mut self) -> Option<chandra::host::display::Output> {
|
||||
#[cfg(feature = "drm")]
|
||||
{
|
||||
kms::open()
|
||||
@@ -289,7 +289,7 @@ impl moonplasma::host::display::Host for State {
|
||||
#[cfg(not(feature = "drm"))]
|
||||
let _ = shape;
|
||||
}
|
||||
fn take_input(&mut self) -> Vec<moonplasma::host::display::SeatEvent> {
|
||||
fn take_input(&mut self) -> Vec<chandra::host::display::SeatEvent> {
|
||||
#[cfg(feature = "drm")]
|
||||
return kms::take_input();
|
||||
#[cfg(not(feature = "drm"))]
|
||||
@@ -301,7 +301,7 @@ impl moonplasma::host::display::Host for State {
|
||||
}
|
||||
}
|
||||
|
||||
impl moonplasma::host::font::Host for State {
|
||||
impl chandra::host::font::Host for State {
|
||||
fn load(&mut self, slot: u32, path: String) -> bool {
|
||||
self.fonts.load(slot, &path)
|
||||
}
|
||||
@@ -312,7 +312,7 @@ impl moonplasma::host::font::Host for State {
|
||||
}
|
||||
}
|
||||
|
||||
impl moonplasma::host::raster::Host for State {
|
||||
impl chandra::host::raster::Host for State {
|
||||
fn capture(&mut self, fd: i32, offset: i32, stride: i32, width: i32, height: i32, format: i32) -> u32 {
|
||||
if fd < 0 || offset < 0 || stride <= 0 || width <= 0 || height <= 0 {
|
||||
return 0;
|
||||
@@ -343,7 +343,7 @@ impl moonplasma::host::raster::Host for State {
|
||||
self.raster.release(id);
|
||||
}
|
||||
|
||||
fn submit(&mut self, f: moonplasma::host::raster::Frame) {
|
||||
fn submit(&mut self, f: chandra::host::raster::Frame) {
|
||||
self.raster.submit(&f, &mut self.fonts);
|
||||
}
|
||||
|
||||
@@ -353,7 +353,7 @@ impl moonplasma::host::raster::Host for State {
|
||||
|
||||
fn export_memfd(&mut self) -> i32 {
|
||||
let data = self.raster.to_argb8888();
|
||||
let Ok(name) = CString::new("moon-plasma-frame") else { return -1 };
|
||||
let Ok(name) = CString::new("chandra-frame") else { return -1 };
|
||||
unsafe {
|
||||
let fd = libc::memfd_create(name.as_ptr(), libc::MFD_CLOEXEC);
|
||||
if fd < 0 {
|
||||
@@ -730,11 +730,11 @@ fn main() -> Result<()> {
|
||||
}
|
||||
};
|
||||
let mut linker: Linker<State> = Linker::new(&engine);
|
||||
moonplasma::host::sys::add_to_linker::<State, HasSelf<State>>(&mut linker, |s| s)?;
|
||||
moonplasma::host::font::add_to_linker::<State, HasSelf<State>>(&mut linker, |s| s)?;
|
||||
moonplasma::host::raster::add_to_linker::<State, HasSelf<State>>(&mut linker, |s| s)?;
|
||||
moonplasma::host::display::add_to_linker::<State, HasSelf<State>>(&mut linker, |s| s)?;
|
||||
moonplasma::host::plasmoids::add_to_linker::<State, HasSelf<State>>(&mut linker, |s| s)?;
|
||||
chandra::host::sys::add_to_linker::<State, HasSelf<State>>(&mut linker, |s| s)?;
|
||||
chandra::host::font::add_to_linker::<State, HasSelf<State>>(&mut linker, |s| s)?;
|
||||
chandra::host::raster::add_to_linker::<State, HasSelf<State>>(&mut linker, |s| s)?;
|
||||
chandra::host::display::add_to_linker::<State, HasSelf<State>>(&mut linker, |s| s)?;
|
||||
chandra::host::plasmoids::add_to_linker::<State, HasSelf<State>>(&mut linker, |s| s)?;
|
||||
let mut store = Store::new(&engine, State::default());
|
||||
store.data_mut().pl = Some(plasmoid::Runtime::new(&engine)?);
|
||||
let compositor = Compositor::instantiate(&mut store, &component, &linker)?;
|
||||
|
||||
Reference in new issue
Block a user