CI / test (push) Successful in 2m28s
--x11 shows the desktop on the X server in $DISPLAY: a resizable window under a window manager (--fullscreen asks it for fullscreen), or the whole screen when no window manager runs, following xrandr resizes. compositor/x11 is a pure X11 wire-protocol client (no libX11/xcb), so it runs in the wasm compositor on both hosts and in the native build. Frames go through MIT-SHM 1.2 (ShmAttachFd of the host frame memfd, paced by ShmCompletion), with a core PutImage fallback. The keymap given to clients is the X server's own (xkbcomp -xkb $DISPLAY -); X auto-repeat is dropped, modifier/lock state comes from X's modifier map; MIT-MAGIC-COOKIE-1 auth. chandra-session --x11 (and the new "Chandra (X11)" xsessions entry) runs it as the login session; --login-session gives an X11 session what --drm implied (power actions, polkit agent, system theme). just run-x11. Docs: docs/x11.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DPL5hhLFs4VtHV26G1iyeo
55 lines
1.9 KiB
MoonBit
55 lines
1.9 KiB
MoonBit
///|
|
|
test "parse_display: local displays only" {
|
|
assert_eq(@x11.parse_display(":0"), Some((0, 0)))
|
|
assert_eq(@x11.parse_display(":1.2"), Some((1, 2)))
|
|
assert_eq(@x11.parse_display("unix:10"), Some((10, 0)))
|
|
assert_eq(@x11.parse_display("localhost:10.0"), None)
|
|
assert_eq(@x11.parse_display(""), None)
|
|
assert_eq(@x11.parse_display(":"), None)
|
|
}
|
|
|
|
///| One Xauthority entry: family, address, display number, auth name, data (big-endian lengths).
|
|
fn xauth_entry(family : Int, addr : String, num : String, data : Array[Byte]) -> Array[Byte] {
|
|
let out : Array[Byte] = []
|
|
fn field(b : Array[Byte]) -> Unit {
|
|
out.push(((b.length() >> 8) & 0xFF).to_byte())
|
|
out.push((b.length() & 0xFF).to_byte())
|
|
for c in b {
|
|
out.push(c)
|
|
}
|
|
}
|
|
|
|
fn text(s : String) -> Array[Byte] {
|
|
let b : Array[Byte] = []
|
|
for c in s {
|
|
b.push(c.to_int().to_byte())
|
|
}
|
|
b
|
|
}
|
|
|
|
out.push(((family >> 8) & 0xFF).to_byte())
|
|
out.push((family & 0xFF).to_byte())
|
|
field(text(addr))
|
|
field(text(num))
|
|
field(text("MIT-MAGIC-COOKIE-1"))
|
|
field(data)
|
|
out
|
|
}
|
|
|
|
///|
|
|
test "xauth_cookie: picks this host's entry for the display" {
|
|
let file : Array[Byte] = []
|
|
file.append(xauth_entry(256, "otherhost", "0", [b'\x01']))
|
|
file.append(xauth_entry(256, "rig", "1", [b'\x02']))
|
|
file.append(xauth_entry(256, "rig", "0", [b'\x03', b'\x04']))
|
|
let f = Bytes::from_array(file)
|
|
assert_eq(@x11.xauth_cookie(f, 0, "rig").to_array(), [b'\x03', b'\x04'])
|
|
assert_eq(@x11.xauth_cookie(f, 1, "rig").to_array(), [b'\x02'])
|
|
// No entry for this host: any local one for the display.
|
|
assert_eq(@x11.xauth_cookie(f, 0, "elsewhere").to_array(), [b'\x01'])
|
|
assert_eq(@x11.xauth_cookie(f, 7, "rig").length(), 0)
|
|
// FamilyWild (xauth's "ffff" entries, as Docker setups write) matches any host.
|
|
let wild = Bytes::from_array(xauth_entry(0xFFFF, "", "0", [b'\x09']))
|
|
assert_eq(@x11.xauth_cookie(wild, 0, "rig").to_array(), [b'\x09'])
|
|
}
|