X11 backend: run Chandra on Xorg (NVIDIA's proprietary driver)
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
This commit is contained in:
Claude committed 2026-11-26 01:37:49 +00:00
1 parent 90fdda2455
commit e6be3825d0
14 files changed
+1777 -19

No files matched your search

+57 -4
View File
@@ -9,6 +9,8 @@ fn main {
let widgets : Array[String] = []
let mut windowed = false
let mut drm = false
let mut x11 = false
let mut fullscreen = false
let mut restore = true
let mut width = 1280
let mut height = 720
@@ -28,6 +30,12 @@ fn main {
} else if a == "--drm" {
drm = true
i = i + 1
} else if a == "--x11" {
x11 = true
i = i + 1
} else if a == "--fullscreen" {
fullscreen = true
i = i + 1
} else if a == "--no-restore" {
restore = false // don't reopen the apps of the last session
i = i + 1
@@ -71,6 +79,27 @@ fn main {
None
}
// X11 mode: a window (or the whole screen, without a window manager) on $DISPLAY.
let xwin = if x11 && !drm {
let display = match @env.get_env_var("DISPLAY") {
Some(d) => d
None => ":0"
}
match @x11.X11Window::open(display, "Chandra", "chandra", width, height, fullscreen) {
Some(x) => {
width = x.width
height = x.height
Some(x)
}
None => {
println("failed to open a window on the X display " + display)
return
}
}
} else {
None
}
let gfx_surface = @gfx.Surface::new({
width: Some(width),
height: Some(height),
@@ -175,10 +204,34 @@ fn main {
n.present(comp.present_to_gfx(gfx_ctx))
}
}
None => {
comp.handle_gfx_events(gfx_surface)
ignore(comp.present_to_gfx(gfx_ctx))
}
None =>
match xwin {
Some(x) => {
if !x.poll() {
break
}
if x.keymap.length() > 0 {
comp.server.set_keymap(x.keymap)
}
match x.take_resize() {
Some((nw, nh)) => comp.resize(nw, nh)
None => ()
}
ignore(x.take_redraw()) // every frame is presented here anyway
let now_ms = @env.now().to_uint()
for ev in x.take_input() {
comp.handle_input(ev, now_ms)
}
x.set_cursor_shape(comp.desired_cursor())
if x.frame_ready() {
x.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)
}