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
@@ -27,7 +27,7 @@ pub(all) struct HostPopup {
|
||||
}
|
||||
|
||||
///|
|
||||
pub(all) struct MoonPlasmaCompositor {
|
||||
pub(all) struct ChandraCompositor {
|
||||
/// Open popups, oldest first (the last is topmost).
|
||||
popups : Array[HostPopup]
|
||||
server : @wayland.WaylandServer
|
||||
@@ -74,12 +74,12 @@ pub(all) struct MoonPlasmaCompositor {
|
||||
}
|
||||
|
||||
///|
|
||||
pub fn MoonPlasmaCompositor::new(
|
||||
pub fn ChandraCompositor::new(
|
||||
socket_path : String,
|
||||
theme : @scene.ThemeTokens,
|
||||
output_w : Int,
|
||||
output_h : Int,
|
||||
) -> MoonPlasmaCompositor? {
|
||||
) -> ChandraCompositor? {
|
||||
ignore(@font.install()) // Adwaita Mono; keeps the bitmap font if it's missing
|
||||
let server = match @wayland.WaylandServer::listen(socket_path, output_w, output_h) {
|
||||
Some(s) => s
|
||||
@@ -141,7 +141,7 @@ fn work_area_for(w : Int, h : Int, theme : @scene.ThemeTokens) -> @wm.Rect {
|
||||
|
||||
///| The output changed size (the nested window was resized, maximized or made fullscreen):
|
||||
/// lay the desktop out for the new size, so nothing is drawn past the edge and cropped away.
|
||||
pub fn MoonPlasmaCompositor::resize(self : MoonPlasmaCompositor, w : Int, h : Int) -> Unit {
|
||||
pub fn ChandraCompositor::resize(self : ChandraCompositor, w : Int, h : Int) -> Unit {
|
||||
if w <= 0 || h <= 0 || (w == self.output_w && h == self.output_h) {
|
||||
return
|
||||
}
|
||||
@@ -158,7 +158,7 @@ pub fn MoonPlasmaCompositor::resize(self : MoonPlasmaCompositor, w : Int, h : In
|
||||
}
|
||||
|
||||
///|
|
||||
pub fn MoonPlasmaCompositor::close(self : MoonPlasmaCompositor) -> Unit {
|
||||
pub fn ChandraCompositor::close(self : ChandraCompositor) -> Unit {
|
||||
for _, win in self.windows {
|
||||
release_snapshot(win.surface)
|
||||
}
|
||||
@@ -184,8 +184,8 @@ pub(all) struct FrameSig {
|
||||
}
|
||||
|
||||
///|
|
||||
fn MoonPlasmaCompositor::apply_actions(
|
||||
self : MoonPlasmaCompositor,
|
||||
fn ChandraCompositor::apply_actions(
|
||||
self : ChandraCompositor,
|
||||
actions : Array[@wm.WmAction],
|
||||
) -> Unit {
|
||||
for act in actions {
|
||||
@@ -236,7 +236,7 @@ fn MoonPlasmaCompositor::apply_actions(
|
||||
}
|
||||
|
||||
///| Send the size changes coalesced during a divider drag.
|
||||
fn MoonPlasmaCompositor::flush_configures(self : MoonPlasmaCompositor) -> Unit {
|
||||
fn ChandraCompositor::flush_configures(self : ChandraCompositor) -> Unit {
|
||||
for wid, win in self.windows {
|
||||
if win.cfg_dirty {
|
||||
win.cfg_dirty = false
|
||||
@@ -253,7 +253,7 @@ fn MoonPlasmaCompositor::flush_configures(self : MoonPlasmaCompositor) -> Unit {
|
||||
}
|
||||
|
||||
///|
|
||||
pub fn MoonPlasmaCompositor::step(self : MoonPlasmaCompositor) -> Unit {
|
||||
pub fn ChandraCompositor::step(self : ChandraCompositor) -> Unit {
|
||||
self.flush_configures()
|
||||
let events = self.server.poll_events()
|
||||
for ev in events {
|
||||
@@ -398,8 +398,8 @@ pub fn MoonPlasmaCompositor::step(self : MoonPlasmaCompositor) -> Unit {
|
||||
}
|
||||
|
||||
///|
|
||||
pub fn MoonPlasmaCompositor::set_layout_mode(
|
||||
self : MoonPlasmaCompositor,
|
||||
pub fn ChandraCompositor::set_layout_mode(
|
||||
self : ChandraCompositor,
|
||||
mode : @wm.LayoutMode,
|
||||
) -> Unit {
|
||||
self.layout_mode = mode
|
||||
@@ -416,7 +416,7 @@ pub fn MoonPlasmaCompositor::set_layout_mode(
|
||||
|
||||
///| Restore what the last session left (layout mode, recent apps) from state.edn. Call once,
|
||||
/// after turning `shell.persist` on; a no-op without persistence.
|
||||
pub fn MoonPlasmaCompositor::restore_state(self : MoonPlasmaCompositor) -> Unit {
|
||||
pub fn ChandraCompositor::restore_state(self : ChandraCompositor) -> Unit {
|
||||
let st = self.shell.load_state()
|
||||
self.shell.apply_state(st)
|
||||
match st.layout {
|
||||
@@ -428,8 +428,8 @@ pub fn MoonPlasmaCompositor::restore_state(self : MoonPlasmaCompositor) -> Unit
|
||||
}
|
||||
|
||||
///|
|
||||
fn MoonPlasmaCompositor::build_scene(
|
||||
self : MoonPlasmaCompositor,
|
||||
fn ChandraCompositor::build_scene(
|
||||
self : ChandraCompositor,
|
||||
) -> (@scene.SceneGraph, Bool) {
|
||||
self.flush_configures()
|
||||
let scene = @scene.SceneGraph::new(self.output_w, self.output_h)
|
||||
@@ -545,8 +545,8 @@ fn MoonPlasmaCompositor::build_scene(
|
||||
|
||||
///| Compose the desktop for the host rasteriser (the wasm compositor): the scene to draw, or None
|
||||
/// when nothing changed since the last one, so an idle desktop costs nothing to draw or present.
|
||||
pub fn MoonPlasmaCompositor::compose_scene(
|
||||
self : MoonPlasmaCompositor,
|
||||
pub fn ChandraCompositor::compose_scene(
|
||||
self : ChandraCompositor,
|
||||
) -> @scene.SceneGraph? {
|
||||
let (scene, changed) = self.build_scene()
|
||||
self.frame_changed = changed
|
||||
@@ -555,8 +555,8 @@ pub fn MoonPlasmaCompositor::compose_scene(
|
||||
|
||||
///| Compose the desktop and draw it with the software renderer (the native build and the tests).
|
||||
/// An unchanged desktop hands back the previous pixels instead of rasterising them again.
|
||||
pub fn MoonPlasmaCompositor::compose_frame(
|
||||
self : MoonPlasmaCompositor,
|
||||
pub fn ChandraCompositor::compose_frame(
|
||||
self : ChandraCompositor,
|
||||
) -> @renderer.Pixmap {
|
||||
let (scene, changed) = self.build_scene()
|
||||
match self.last_frame {
|
||||
@@ -578,8 +578,8 @@ pub fn MoonPlasmaCompositor::compose_frame(
|
||||
///|
|
||||
/// Compose the current desktop GUI frame and present it onto a wasi-gfx
|
||||
/// `SurfaceFrameBufferContext`.
|
||||
pub fn MoonPlasmaCompositor::present_to_gfx(
|
||||
self : MoonPlasmaCompositor,
|
||||
pub fn ChandraCompositor::present_to_gfx(
|
||||
self : ChandraCompositor,
|
||||
ctx : @gfx.SurfaceFrameBufferContext,
|
||||
) -> @renderer.Pixmap {
|
||||
let pixmap = self.compose_frame()
|
||||
@@ -591,8 +591,8 @@ pub fn MoonPlasmaCompositor::present_to_gfx(
|
||||
|
||||
///|
|
||||
/// Process pending wasi-gfx surface input events (pointer clicks for focus).
|
||||
pub fn MoonPlasmaCompositor::handle_gfx_events(
|
||||
self : MoonPlasmaCompositor,
|
||||
pub fn ChandraCompositor::handle_gfx_events(
|
||||
self : ChandraCompositor,
|
||||
surface : @gfx.Surface,
|
||||
) -> Unit {
|
||||
let downs = surface.drain_pointer_down()
|
||||
@@ -624,7 +624,7 @@ pub fn MoonPlasmaCompositor::handle_gfx_events(
|
||||
|
||||
|
||||
///| Content origin of a window or popup.
|
||||
fn MoonPlasmaCompositor::origin_of(self : MoonPlasmaCompositor, wid : UInt64) -> (Int, Int) {
|
||||
fn ChandraCompositor::origin_of(self : ChandraCompositor, wid : UInt64) -> (Int, Int) {
|
||||
match self.windows.get(wid) {
|
||||
Some(win) => (win.geometry.x, win.geometry.y)
|
||||
None => {
|
||||
@@ -640,7 +640,7 @@ fn MoonPlasmaCompositor::origin_of(self : MoonPlasmaCompositor, wid : UInt64) ->
|
||||
}
|
||||
|
||||
///| Absolute rectangle of a popup, nudged to stay on screen.
|
||||
fn MoonPlasmaCompositor::popup_rect(self : MoonPlasmaCompositor, p : HostPopup) -> @scene.Rect {
|
||||
fn ChandraCompositor::popup_rect(self : ChandraCompositor, p : HostPopup) -> @scene.Rect {
|
||||
let (w, h) = match p.surface {
|
||||
Some(s) => (s.width, s.height)
|
||||
None => (p.w, p.h)
|
||||
@@ -654,7 +654,7 @@ fn MoonPlasmaCompositor::popup_rect(self : MoonPlasmaCompositor, p : HostPopup)
|
||||
}
|
||||
|
||||
///|
|
||||
fn MoonPlasmaCompositor::origin_of_parent(self : MoonPlasmaCompositor, p : HostPopup) -> (Int, Int) {
|
||||
fn ChandraCompositor::origin_of_parent(self : ChandraCompositor, p : HostPopup) -> (Int, Int) {
|
||||
if p.parent == p.id {
|
||||
(0, 0)
|
||||
} else {
|
||||
@@ -663,7 +663,7 @@ fn MoonPlasmaCompositor::origin_of_parent(self : MoonPlasmaCompositor, p : HostP
|
||||
}
|
||||
|
||||
///| Top-most popup under (x, y).
|
||||
fn MoonPlasmaCompositor::popup_at(self : MoonPlasmaCompositor, x : Int, y : Int) -> HostPopup? {
|
||||
fn ChandraCompositor::popup_at(self : ChandraCompositor, x : Int, y : Int) -> HostPopup? {
|
||||
let mut i = self.popups.length() - 1
|
||||
while i >= 0 {
|
||||
let p = self.popups[i]
|
||||
@@ -677,7 +677,7 @@ fn MoonPlasmaCompositor::popup_at(self : MoonPlasmaCompositor, x : Int, y : Int)
|
||||
}
|
||||
|
||||
///| The toplevel a popup chain hangs off (for returning keyboard focus).
|
||||
fn MoonPlasmaCompositor::popup_root(self : MoonPlasmaCompositor, wid : UInt64) -> UInt64? {
|
||||
fn ChandraCompositor::popup_root(self : ChandraCompositor, wid : UInt64) -> UInt64? {
|
||||
let mut cur = wid
|
||||
let mut n = 0
|
||||
while n < 16 {
|
||||
@@ -700,7 +700,7 @@ fn MoonPlasmaCompositor::popup_root(self : MoonPlasmaCompositor, wid : UInt64) -
|
||||
}
|
||||
|
||||
///| Forget a popup (and any popups hanging off it); give keyboard focus back to its window.
|
||||
fn MoonPlasmaCompositor::close_popup(self : MoonPlasmaCompositor, wid : UInt64) -> Unit {
|
||||
fn ChandraCompositor::close_popup(self : ChandraCompositor, wid : UInt64) -> Unit {
|
||||
let mut found = false
|
||||
for p in self.popups {
|
||||
if p.id == wid {
|
||||
@@ -735,7 +735,7 @@ fn MoonPlasmaCompositor::close_popup(self : MoonPlasmaCompositor, wid : UInt64)
|
||||
}
|
||||
|
||||
///| Send pointer enter/motion for a popup under the pointer.
|
||||
fn MoonPlasmaCompositor::pointer_into_popup(self : MoonPlasmaCompositor, p : HostPopup, time_ms : UInt, motion : Bool) -> Unit {
|
||||
fn ChandraCompositor::pointer_into_popup(self : ChandraCompositor, p : HostPopup, time_ms : UInt, motion : Bool) -> Unit {
|
||||
let r = self.popup_rect(p)
|
||||
let lx = self.ptr_x - r.x.to_double()
|
||||
let ly = self.ptr_y - r.y.to_double()
|
||||
@@ -750,7 +750,7 @@ fn MoonPlasmaCompositor::pointer_into_popup(self : MoonPlasmaCompositor, p : Hos
|
||||
}
|
||||
|
||||
///| Move keyboard focus (wl_keyboard leave/enter + current modifiers).
|
||||
fn MoonPlasmaCompositor::set_kbd_focus(self : MoonPlasmaCompositor, wid : UInt64?) -> Unit {
|
||||
fn ChandraCompositor::set_kbd_focus(self : ChandraCompositor, wid : UInt64?) -> Unit {
|
||||
if self.kbd_win == wid {
|
||||
return
|
||||
}
|
||||
@@ -769,7 +769,7 @@ fn MoonPlasmaCompositor::set_kbd_focus(self : MoonPlasmaCompositor, wid : UInt64
|
||||
}
|
||||
|
||||
///| Top-most window under (x, y): (id, in client area). The titlebar counts as the window but not the client.
|
||||
fn MoonPlasmaCompositor::window_at(self : MoonPlasmaCompositor, x : Int, y : Int) -> (UInt64, Bool)? {
|
||||
fn ChandraCompositor::window_at(self : ChandraCompositor, x : Int, y : Int) -> (UInt64, Bool)? {
|
||||
let order = self.wm.stacking_order()
|
||||
let mut i = order.length() - 1
|
||||
while i >= 0 {
|
||||
@@ -793,8 +793,8 @@ fn MoonPlasmaCompositor::window_at(self : MoonPlasmaCompositor, x : Int, y : Int
|
||||
///| Resize zone under (x, y) on a floating window: its corners (12px) and left/right/bottom
|
||||
/// edges. The first window whose outer box contains the point decides; tiled windows resize
|
||||
/// through the dividers instead.
|
||||
fn MoonPlasmaCompositor::resize_at(
|
||||
self : MoonPlasmaCompositor,
|
||||
fn ChandraCompositor::resize_at(
|
||||
self : ChandraCompositor,
|
||||
x : Int,
|
||||
y : Int,
|
||||
) -> (UInt64, @wm.DragMode)? {
|
||||
@@ -852,8 +852,8 @@ fn MoonPlasmaCompositor::resize_at(
|
||||
|
||||
///| Title-bar button under (x, y) for window `wid`: 1 minimize, 2 maximize, 3 close, 0 none.
|
||||
/// Mirrors the layout in `build_breeze_decoration` (18px buttons, 8px apart, 10px from the right edge).
|
||||
fn MoonPlasmaCompositor::title_button_at(
|
||||
self : MoonPlasmaCompositor,
|
||||
fn ChandraCompositor::title_button_at(
|
||||
self : ChandraCompositor,
|
||||
wid : UInt64,
|
||||
x : Int,
|
||||
y : Int,
|
||||
@@ -887,8 +887,8 @@ fn MoonPlasmaCompositor::title_button_at(
|
||||
}
|
||||
|
||||
///| Activate the title-bar button `btn` of window `wid`.
|
||||
fn MoonPlasmaCompositor::press_title_button(
|
||||
self : MoonPlasmaCompositor,
|
||||
fn ChandraCompositor::press_title_button(
|
||||
self : ChandraCompositor,
|
||||
wid : UInt64,
|
||||
btn : Int,
|
||||
) -> Unit {
|
||||
@@ -920,14 +920,14 @@ fn MoonPlasmaCompositor::press_title_button(
|
||||
|
||||
///| Focus a window and bring it to the front through the window manager, so its stacking
|
||||
/// order (not just the drawing) changes.
|
||||
fn MoonPlasmaCompositor::activate_window(self : MoonPlasmaCompositor, wid : UInt64) -> Unit {
|
||||
fn ChandraCompositor::activate_window(self : ChandraCompositor, wid : UInt64) -> Unit {
|
||||
self.apply_actions(
|
||||
self.wm.handle_request(wid, @wm.WindowRequest::Activate, self.work_area),
|
||||
)
|
||||
}
|
||||
|
||||
///| Restore a minimized window (or focus a visible one) from its task-bar pill.
|
||||
fn MoonPlasmaCompositor::activate_task(self : MoonPlasmaCompositor, wid : UInt64) -> Unit {
|
||||
fn ChandraCompositor::activate_task(self : ChandraCompositor, wid : UInt64) -> Unit {
|
||||
let minimized = match self.wm.windows.get(wid) {
|
||||
Some(r) => r.minimized
|
||||
None => return
|
||||
@@ -943,7 +943,7 @@ fn MoonPlasmaCompositor::activate_task(self : MoonPlasmaCompositor, wid : UInt64
|
||||
}
|
||||
|
||||
///| Carry out what panel modules asked for: focus a window, switch layout.
|
||||
fn MoonPlasmaCompositor::run_shell_actions(self : MoonPlasmaCompositor) -> Unit {
|
||||
fn ChandraCompositor::run_shell_actions(self : ChandraCompositor) -> Unit {
|
||||
for a in self.shell.take_actions() {
|
||||
match a {
|
||||
@shell.ShellAction::FocusWindow(wid) => self.activate_task(wid)
|
||||
@@ -960,8 +960,8 @@ fn MoonPlasmaCompositor::run_shell_actions(self : MoonPlasmaCompositor) -> Unit
|
||||
}
|
||||
|
||||
///| Tiling divider under (x, y), with a few pixels of slack either side.
|
||||
fn MoonPlasmaCompositor::handle_at(
|
||||
self : MoonPlasmaCompositor,
|
||||
fn ChandraCompositor::handle_at(
|
||||
self : ChandraCompositor,
|
||||
x : Int,
|
||||
y : Int,
|
||||
) -> @wm.SplitHandle? {
|
||||
@@ -982,7 +982,7 @@ fn MoonPlasmaCompositor::handle_at(
|
||||
}
|
||||
|
||||
///|
|
||||
fn MoonPlasmaCompositor::leave_pointer(self : MoonPlasmaCompositor) -> Unit {
|
||||
fn ChandraCompositor::leave_pointer(self : ChandraCompositor) -> Unit {
|
||||
match self.ptr_win {
|
||||
Some(w) => {
|
||||
self.server.pointer_leave(w)
|
||||
@@ -1025,8 +1025,8 @@ fn key_name(code : UInt, shift : Bool) -> String {
|
||||
|
||||
///| Route host input: shell (launcher) first, then the window under the pointer
|
||||
/// / the keyboard-focused window.
|
||||
pub fn MoonPlasmaCompositor::handle_input(
|
||||
self : MoonPlasmaCompositor,
|
||||
pub fn ChandraCompositor::handle_input(
|
||||
self : ChandraCompositor,
|
||||
ev : @nested.InputEvent,
|
||||
time_ms : UInt,
|
||||
) -> Unit {
|
||||
@@ -1307,7 +1307,7 @@ pub fn MoonPlasmaCompositor::handle_input(
|
||||
|
||||
///| Cursor shape (wp_cursor_shape_v1 value) for the current pointer position: shell UI
|
||||
/// decides over the launcher; a client window decides inside its client area; otherwise default.
|
||||
pub fn MoonPlasmaCompositor::desired_cursor(self : MoonPlasmaCompositor) -> UInt {
|
||||
pub fn ChandraCompositor::desired_cursor(self : ChandraCompositor) -> UInt {
|
||||
let shell_shape = self.shell.cursor_at(self.ptr_x.to_int(), self.ptr_y.to_int())
|
||||
if shell_shape != 0U {
|
||||
return shell_shape
|
||||
|
||||
Reference in new issue
Block a user