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
@@ -3,19 +3,19 @@
|
||||
/// Needs the modules: run scripts/build-modules.sh (just test does).
|
||||
|
||||
///| Rectangle of the panel module `id` (file stem), as last drawn.
|
||||
fn rect_of(comp : @host.MoonPlasmaCompositor, id : String) -> @scene.Rect {
|
||||
fn rect_of(comp : @host.ChandraCompositor, id : String) -> @scene.Rect {
|
||||
comp.shell.slot_rect(comp.shell.slot_of(id))
|
||||
}
|
||||
|
||||
///| Centre of the panel module `id`.
|
||||
fn center_of(comp : @host.MoonPlasmaCompositor, id : String) -> (Double, Double) raise {
|
||||
fn center_of(comp : @host.ChandraCompositor, id : String) -> (Double, Double) raise {
|
||||
let r = rect_of(comp, id)
|
||||
assert_true(r.w > 0)
|
||||
((r.x + r.w / 2).to_double(), (r.y + r.h / 2).to_double())
|
||||
}
|
||||
|
||||
///| Move to (x, y), press and release `btn`, then draw a frame.
|
||||
fn click_at(comp : @host.MoonPlasmaCompositor, x : Int, y : Int, t : UInt, btn? : UInt = 272U) -> Unit {
|
||||
fn click_at(comp : @host.ChandraCompositor, x : Int, y : Int, t : UInt, btn? : UInt = 272U) -> Unit {
|
||||
comp.handle_input(@nested.InputEvent::PointerMove(x.to_double(), y.to_double()), t)
|
||||
comp.handle_input(@nested.InputEvent::PointerButton(btn, true), t + 1U)
|
||||
comp.handle_input(@nested.InputEvent::PointerButton(btn, false), t + 2U)
|
||||
@@ -23,16 +23,16 @@ fn click_at(comp : @host.MoonPlasmaCompositor, x : Int, y : Int, t : UInt, btn?
|
||||
}
|
||||
|
||||
///| Click the centre of panel module `id`.
|
||||
fn click_module(comp : @host.MoonPlasmaCompositor, id : String, t : UInt) -> Unit raise {
|
||||
fn click_module(comp : @host.ChandraCompositor, id : String, t : UInt) -> Unit raise {
|
||||
let (x, y) = center_of(comp, id)
|
||||
click_at(comp, x.to_int(), y.to_int(), t)
|
||||
}
|
||||
|
||||
///| A fresh compositor with the default panel and a first frame drawn.
|
||||
fn new_comp(tag : String) -> @host.MoonPlasmaCompositor {
|
||||
fn new_comp(tag : String) -> @host.ChandraCompositor {
|
||||
let socket_path = "/tmp/wayland-moon-" + tag + "-" + @sys.getpid().to_string() + ".sock"
|
||||
let theme = @scene.ThemeTokens::moon_night()
|
||||
let comp = @host.MoonPlasmaCompositor::new(socket_path, theme, 1280, 720).unwrap()
|
||||
let comp = @host.ChandraCompositor::new(socket_path, theme, 1280, 720).unwrap()
|
||||
ignore(comp.compose_frame())
|
||||
comp
|
||||
}
|
||||
@@ -80,7 +80,7 @@ test "host input reaches the focused client and the launcher popup opens" {
|
||||
@sys.getpid().to_string() +
|
||||
".sock"
|
||||
let theme = @scene.ThemeTokens::moon_night()
|
||||
let comp = @host.MoonPlasmaCompositor::new(socket_path, theme, 1280, 720).unwrap()
|
||||
let comp = @host.ChandraCompositor::new(socket_path, theme, 1280, 720).unwrap()
|
||||
let (c, shm, surf, xdg, _tl, _deco) = open_and_configure_client(
|
||||
comp, socket_path, "T", "t",
|
||||
)
|
||||
@@ -169,7 +169,7 @@ test "dragging the divider between two tiled windows resizes them" {
|
||||
@sys.getpid().to_string() +
|
||||
".sock"
|
||||
let theme = @scene.ThemeTokens::moon_night()
|
||||
let comp = @host.MoonPlasmaCompositor::new(socket_path, theme, 1280, 720).unwrap()
|
||||
let comp = @host.ChandraCompositor::new(socket_path, theme, 1280, 720).unwrap()
|
||||
let _a = open_and_configure_client(comp, socket_path, "A", "a")
|
||||
let _b = open_and_configure_client(comp, socket_path, "B", "b")
|
||||
let left = comp.windows.get(1UL).unwrap().geometry
|
||||
@@ -196,7 +196,7 @@ test "the layout module opens a popup to pick Tiling, Monocle or Floating" {
|
||||
@sys.getpid().to_string() +
|
||||
".sock"
|
||||
let theme = @scene.ThemeTokens::moon_night()
|
||||
let comp = @host.MoonPlasmaCompositor::new(socket_path, theme, 1280, 720).unwrap()
|
||||
let comp = @host.ChandraCompositor::new(socket_path, theme, 1280, 720).unwrap()
|
||||
let _a = open_and_configure_client(comp, socket_path, "A", "a")
|
||||
let _b = open_and_configure_client(comp, socket_path, "B", "b")
|
||||
ignore(comp.compose_frame())
|
||||
@@ -237,7 +237,7 @@ test "title-bar buttons minimize, maximize and close windows" {
|
||||
@sys.getpid().to_string() +
|
||||
".sock"
|
||||
let theme = @scene.ThemeTokens::moon_night()
|
||||
let comp = @host.MoonPlasmaCompositor::new(socket_path, theme, 1280, 720).unwrap()
|
||||
let comp = @host.ChandraCompositor::new(socket_path, theme, 1280, 720).unwrap()
|
||||
let (c, _shm, _surf, _xdg, tl, _deco) = open_and_configure_client(comp, socket_path, "A", "a")
|
||||
let _b = open_and_configure_client(comp, socket_path, "B", "b")
|
||||
ignore(comp.compose_frame())
|
||||
@@ -282,7 +282,7 @@ test "the task list module focuses the window whose pill is clicked" {
|
||||
@sys.getpid().to_string() +
|
||||
".sock"
|
||||
let theme = @scene.ThemeTokens::moon_night()
|
||||
let comp = @host.MoonPlasmaCompositor::new(socket_path, theme, 1280, 720).unwrap()
|
||||
let comp = @host.ChandraCompositor::new(socket_path, theme, 1280, 720).unwrap()
|
||||
let _a = open_and_configure_client(comp, socket_path, "A", "a")
|
||||
let _b = open_and_configure_client(comp, socket_path, "B", "b")
|
||||
ignore(comp.compose_frame())
|
||||
@@ -376,7 +376,7 @@ test "tapping Super toggles the launcher; Super+key does not" {
|
||||
///|
|
||||
test "the panel is saved to panel.edn and restored" {
|
||||
// Never touch the user's real config: only run when a scratch dir is provided.
|
||||
if @sys.getenv("MOON_PLASMA_TEST_CONFIG") == "1" {
|
||||
if @sys.getenv("CHANDRA_TEST_CONFIG") == "1" {
|
||||
let theme = @scene.ThemeTokens::moon_night()
|
||||
let a = @shell.DesktopShell::new("x")
|
||||
a.persist = true
|
||||
@@ -510,7 +510,7 @@ test "Desktop Pulse reads live machine and window state through its granted inte
|
||||
@sys.getpid().to_string() +
|
||||
".sock"
|
||||
let theme = @scene.ThemeTokens::moon_night()
|
||||
let comp = @host.MoonPlasmaCompositor::new(socket_path, theme, 1280, 720).unwrap()
|
||||
let comp = @host.ChandraCompositor::new(socket_path, theme, 1280, 720).unwrap()
|
||||
let _a = open_and_configure_client(comp, socket_path, "A", "a")
|
||||
let _b = open_and_configure_client(comp, socket_path, "B", "b")
|
||||
ignore(comp.compose_frame())
|
||||
@@ -548,7 +548,7 @@ test "Desktop Pulse reads live machine and window state through its granted inte
|
||||
test "the desktop card can be dragged across the wallpaper" {
|
||||
let socket_path = "/tmp/wayland-moon-desk-" + @sys.getpid().to_string() + ".sock"
|
||||
let theme = @scene.ThemeTokens::moon_night()
|
||||
let comp = @host.MoonPlasmaCompositor::new(socket_path, theme, 1280, 720).unwrap()
|
||||
let comp = @host.ChandraCompositor::new(socket_path, theme, 1280, 720).unwrap()
|
||||
ignore(comp.compose_frame())
|
||||
// Default: top-right, 24px in. Grab it by its body.
|
||||
let gx = 1280 - 260 - 24 + 40
|
||||
@@ -570,7 +570,7 @@ test "the desktop card can be dragged across the wallpaper" {
|
||||
test "an xdg_popup (right-click menu) is placed, drawn, clickable and dismissed from outside" {
|
||||
let socket_path = "/tmp/wayland-moon-popup-" + @sys.getpid().to_string() + ".sock"
|
||||
let theme = @scene.ThemeTokens::moon_night()
|
||||
let comp = @host.MoonPlasmaCompositor::new(socket_path, theme, 1280, 720).unwrap()
|
||||
let comp = @host.ChandraCompositor::new(socket_path, theme, 1280, 720).unwrap()
|
||||
let (c, shm, surf, xdg, _tl, _deco) = open_and_configure_client(comp, socket_path, "T", "t")
|
||||
commit_shm_frame(comp, c, shm, surf, xdg, 1UL)
|
||||
let win = comp.windows.get(1UL).unwrap().geometry
|
||||
@@ -726,7 +726,7 @@ fn data_device_for(c : TestWaylandClient) -> (UInt, UInt) {
|
||||
test "copy in one client, paste in another" {
|
||||
let socket_path = "/tmp/wayland-moon-clip-" + @sys.getpid().to_string() + ".sock"
|
||||
let theme = @scene.ThemeTokens::moon_night()
|
||||
let comp = @host.MoonPlasmaCompositor::new(socket_path, theme, 1280, 720).unwrap()
|
||||
let comp = @host.ChandraCompositor::new(socket_path, theme, 1280, 720).unwrap()
|
||||
let (a, _, _, _, _, _) = open_and_configure_client(comp, socket_path, "A", "a")
|
||||
let (b, _, _, _, _, _) = open_and_configure_client(comp, socket_path, "B", "b")
|
||||
let (mgr_a, dev_a) = data_device_for(a)
|
||||
@@ -782,7 +782,7 @@ test "dragging a title bar moves the window and floats it" {
|
||||
@sys.getpid().to_string() +
|
||||
".sock"
|
||||
let theme = @scene.ThemeTokens::moon_night()
|
||||
let comp = @host.MoonPlasmaCompositor::new(socket_path, theme, 1280, 720).unwrap()
|
||||
let comp = @host.ChandraCompositor::new(socket_path, theme, 1280, 720).unwrap()
|
||||
let _a = open_and_configure_client(comp, socket_path, "A", "a")
|
||||
let _b = open_and_configure_client(comp, socket_path, "B", "b")
|
||||
let g0 = comp.windows.get(2UL).unwrap().geometry
|
||||
@@ -806,7 +806,7 @@ test "dragging a floating window's corner resizes it" {
|
||||
@sys.getpid().to_string() +
|
||||
".sock"
|
||||
let theme = @scene.ThemeTokens::moon_night()
|
||||
let comp = @host.MoonPlasmaCompositor::new(socket_path, theme, 1280, 720).unwrap()
|
||||
let comp = @host.ChandraCompositor::new(socket_path, theme, 1280, 720).unwrap()
|
||||
let _a = open_and_configure_client(comp, socket_path, "A", "a")
|
||||
let _b = open_and_configure_client(comp, socket_path, "B", "b")
|
||||
// Float window 2 by dragging its title bar a little.
|
||||
@@ -861,7 +861,7 @@ fn read_state_edn() -> String {
|
||||
"" => @sys.getenv("HOME") + "/.config"
|
||||
c => c
|
||||
}
|
||||
let raw = @sys.read_file_bytes(dir + "/moon-plasma/state.edn")
|
||||
let raw = @sys.read_file_bytes(dir + "/chandra/state.edn")
|
||||
let sb = StringBuilder::new()
|
||||
for i = 0; i < raw.length(); i = i + 1 {
|
||||
sb.write_char(Int::unsafe_to_char(raw[i].to_int())) // the file is ASCII
|
||||
@@ -875,14 +875,14 @@ fn write_state_edn(text : String) -> Unit {
|
||||
"" => @sys.getenv("HOME") + "/.config"
|
||||
c => c
|
||||
}
|
||||
ignore(@sys.mkdir_p(dir + "/moon-plasma"))
|
||||
ignore(@sys.write_file_bytes(dir + "/moon-plasma/state.edn", @sys.str_to_utf8_bytes(text)))
|
||||
ignore(@sys.mkdir_p(dir + "/chandra"))
|
||||
ignore(@sys.write_file_bytes(dir + "/chandra/state.edn", @sys.str_to_utf8_bytes(text)))
|
||||
}
|
||||
|
||||
///|
|
||||
test "the layout mode and recent apps are saved to state.edn and restored; other keys survive" {
|
||||
// Never touch the user's real config: only run when the test runner gave us a scratch dir.
|
||||
if @sys.getenv("MOON_PLASMA_TEST_CONFIG") == "1" {
|
||||
if @sys.getenv("CHANDRA_TEST_CONFIG") == "1" {
|
||||
write_state_edn(";; hand-written\n{:note \"keep me\" :layout :tiling}\n")
|
||||
let a = new_comp("state-a")
|
||||
a.shell.persist = true
|
||||
@@ -915,7 +915,7 @@ test "the layout mode and recent apps are saved to state.edn and restored; other
|
||||
|
||||
///|
|
||||
test "the desktop card position is saved when dropped and restored" {
|
||||
if @sys.getenv("MOON_PLASMA_TEST_CONFIG") == "1" {
|
||||
if @sys.getenv("CHANDRA_TEST_CONFIG") == "1" {
|
||||
write_state_edn("{:note \"keep\"}\n")
|
||||
let a = new_comp("card-a")
|
||||
a.shell.persist = true
|
||||
@@ -939,7 +939,7 @@ test "the desktop card position is saved when dropped and restored" {
|
||||
test "clicking a floating window brings it in front of the others" {
|
||||
let socket_path = "/tmp/wayland-moon-z-" + @sys.getpid().to_string() + ".sock"
|
||||
let theme = @scene.ThemeTokens::moon_night()
|
||||
let comp = @host.MoonPlasmaCompositor::new(socket_path, theme, 1280, 720).unwrap()
|
||||
let comp = @host.ChandraCompositor::new(socket_path, theme, 1280, 720).unwrap()
|
||||
ignore(open_and_configure_client(comp, socket_path, "A", "a"))
|
||||
ignore(open_and_configure_client(comp, socket_path, "B", "b"))
|
||||
comp.set_layout_mode(@wm.LayoutMode::Floating)
|
||||
@@ -958,11 +958,11 @@ test "clicking a floating window brings it in front of the others" {
|
||||
|
||||
///|
|
||||
test "a window dragged somewhere reopens there, saved per app in state.edn" {
|
||||
if @sys.getenv("MOON_PLASMA_TEST_CONFIG") == "1" {
|
||||
if @sys.getenv("CHANDRA_TEST_CONFIG") == "1" {
|
||||
write_state_edn("{:note \"keep\"}\n")
|
||||
let sock1 = "/tmp/wayland-moon-wp1-" + @sys.getpid().to_string() + ".sock"
|
||||
let theme = @scene.ThemeTokens::moon_night()
|
||||
let a = @host.MoonPlasmaCompositor::new(sock1, theme, 1280, 720).unwrap()
|
||||
let a = @host.ChandraCompositor::new(sock1, theme, 1280, 720).unwrap()
|
||||
a.shell.persist = true
|
||||
a.set_layout_mode(@wm.LayoutMode::Floating)
|
||||
ignore(open_and_configure_client(a, sock1, "T", "org.test.app"))
|
||||
@@ -980,7 +980,7 @@ test "a window dragged somewhere reopens there, saved per app in state.edn" {
|
||||
assert_true(text.contains(":note \"keep\""))
|
||||
// A new session: the same app opens where it was left.
|
||||
let sock2 = "/tmp/wayland-moon-wp2-" + @sys.getpid().to_string() + ".sock"
|
||||
let b = @host.MoonPlasmaCompositor::new(sock2, theme, 1280, 720).unwrap()
|
||||
let b = @host.ChandraCompositor::new(sock2, theme, 1280, 720).unwrap()
|
||||
b.shell.persist = true
|
||||
b.restore_state()
|
||||
ignore(open_and_configure_client(b, sock2, "T", "org.test.app"))
|
||||
@@ -995,7 +995,7 @@ test "a window dragged somewhere reopens there, saved per app in state.edn" {
|
||||
test "alt-tab switches to the previous window, tab again goes further back, escape cancels" {
|
||||
let socket_path = "/tmp/wayland-moon-alt-" + @sys.getpid().to_string() + ".sock"
|
||||
let theme = @scene.ThemeTokens::moon_night()
|
||||
let comp = @host.MoonPlasmaCompositor::new(socket_path, theme, 1280, 720).unwrap()
|
||||
let comp = @host.ChandraCompositor::new(socket_path, theme, 1280, 720).unwrap()
|
||||
ignore(open_and_configure_client(comp, socket_path, "A", "a"))
|
||||
ignore(open_and_configure_client(comp, socket_path, "B", "b"))
|
||||
ignore(open_and_configure_client(comp, socket_path, "C", "c"))
|
||||
@@ -1047,7 +1047,7 @@ test "alt-tab switches to the previous window, tab again goes further back, esca
|
||||
test "compose_scene hands the host a scene only when something changed" {
|
||||
let socket_path = "/tmp/wayland-moon-scene-" + @sys.getpid().to_string() + ".sock"
|
||||
let theme = @scene.ThemeTokens::moon_night()
|
||||
let comp = @host.MoonPlasmaCompositor::new(socket_path, theme, 1280, 720).unwrap()
|
||||
let comp = @host.ChandraCompositor::new(socket_path, theme, 1280, 720).unwrap()
|
||||
// The first scene is always drawn; the wallpaper and the desktop card are split out of it.
|
||||
match comp.compose_scene() {
|
||||
Some(sg) => {
|
||||
@@ -1079,7 +1079,7 @@ test "compose_scene hands the host a scene only when something changed" {
|
||||
test "super+d minimizes every window to show the desktop, and again brings them back" {
|
||||
let socket_path = "/tmp/wayland-moon-supd-" + @sys.getpid().to_string() + ".sock"
|
||||
let theme = @scene.ThemeTokens::moon_night()
|
||||
let comp = @host.MoonPlasmaCompositor::new(socket_path, theme, 1280, 720).unwrap()
|
||||
let comp = @host.ChandraCompositor::new(socket_path, theme, 1280, 720).unwrap()
|
||||
ignore(open_and_configure_client(comp, socket_path, "A", "a"))
|
||||
ignore(open_and_configure_client(comp, socket_path, "B", "b"))
|
||||
ignore(comp.compose_frame())
|
||||
@@ -1123,7 +1123,7 @@ test "super+d minimizes every window to show the desktop, and again brings them
|
||||
}
|
||||
|
||||
///| Click (x, y) without drawing, then return the next scene's wallpaper op count (0: no new scene).
|
||||
fn click_wallpaper_ops(comp : @host.MoonPlasmaCompositor, x : Int, y : Int, t : UInt) -> Int {
|
||||
fn click_wallpaper_ops(comp : @host.ChandraCompositor, x : Int, y : Int, t : UInt) -> Int {
|
||||
comp.handle_input(@nested.InputEvent::PointerMove(x.to_double(), y.to_double()), t)
|
||||
comp.handle_input(@nested.InputEvent::PointerButton(272U, true), t + 1U)
|
||||
comp.handle_input(@nested.InputEvent::PointerButton(272U, false), t + 2U)
|
||||
@@ -1162,7 +1162,7 @@ test "the wallpaper module lists the wallpapers and switches the desktop to the
|
||||
|
||||
///|
|
||||
test "the chosen wallpaper is saved to state.edn and restored" {
|
||||
if @sys.getenv("MOON_PLASMA_TEST_CONFIG") == "1" {
|
||||
if @sys.getenv("CHANDRA_TEST_CONFIG") == "1" {
|
||||
write_state_edn("{:note \"keep\"}\n")
|
||||
let a = new_comp("wall-a")
|
||||
a.shell.persist = true
|
||||
@@ -1184,3 +1184,29 @@ test "the chosen wallpaper is saved to state.edn and restored" {
|
||||
assert_eq(c.shell.wallpaper_sel, 0)
|
||||
}
|
||||
}
|
||||
|
||||
///|
|
||||
test "state saved by a build from before the rename to Chandra is still read" {
|
||||
if @sys.getenv("CHANDRA_TEST_CONFIG") == "1" {
|
||||
let dir = match @sys.getenv("XDG_CONFIG_HOME") {
|
||||
"" => @sys.getenv("HOME") + "/.config"
|
||||
c => c
|
||||
}
|
||||
@sys.unlink(dir + "/chandra/state.edn")
|
||||
ignore(@sys.mkdir_p(dir + "/moon-plasma"))
|
||||
ignore(
|
||||
@sys.write_file_bytes(
|
||||
dir + "/moon-plasma/state.edn",
|
||||
@sys.str_to_utf8_bytes("{:layout :monocle}\n"),
|
||||
),
|
||||
)
|
||||
let c = new_comp("state-legacy")
|
||||
c.shell.persist = true
|
||||
c.restore_state()
|
||||
assert_eq(c.layout_mode, @wm.LayoutMode::Monocle)
|
||||
// The next save goes to the new place.
|
||||
c.shell.save_state()
|
||||
assert_true(read_state_edn().contains(":layout :monocle"))
|
||||
@sys.unlink(dir + "/moon-plasma/state.edn")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user