Files
chandra/docs/window-frames.md
Claude 41c6ec1135
CI / test (push) Canceled after 0s
Remove the Rust host (host-wasm)
The MoonBit host (wasmhost/, build/wasmhost) is the only host now. Gone:
host-wasm/ (Rust on the wasmtime crate, ~5,700 lines incl. Cargo.lock),
the run-rust, run-drm-rust and host-wasm recipes, and `just install --rust`
(both the recipe and session/install.py now stop with an error naming the
removal instead of quietly ignoring the flag). remote-build.sh builds and
pulls build/wasmhost. README, wasmhost/README and docs no longer describe a
second host, apart from short history notes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hiBxpbLoeUM9xfZayq
2026-11-26 04:19:19 +00:00

71 lines
4.4 KiB
Markdown

# Window frames
Chandra draws the frame (title bar, outline, buttons, shadow) around every window that lets it:
apps that ask for server-side decorations through `zxdg_decoration_manager_v1`, and GTK 3 apps
through `org_kde_kwin_server_decoration`. Windows that draw their own frame (GTK 4, GNOME apps,
Chrome with its own title bar) get none; they fill the frame's box instead (see `client_rect`
in compositor/host/compositor.mbt).
## Styles
Settings > Session > **Flat window frames** picks one of two styles. It is saved in state.edn as
`:window-style :breeze` when off; absent (or `:flat`) is the flat frame. An unknown value is
logged (`chandra: state.edn: unknown :window-style ...`) and the flat frame is used.
**Flat** (the default) follows V's Flatkit Aurorae theme for KWin,
[codegod100/kde aurorae/](https://github.com/codegod100/kde/tree/main/aurorae) (its colours and
sizes are in `generate.py` and `Flatkitrc`):
| | Flatkit (light) | Flatkit Dark |
|---|---|---|
| Title bar | `#F6F6F7` | `#1C1C1F` |
| Outline, hairline under the title | `#DADADE` | `#3A3A40` |
| Title text focused / unfocused | `#1E1E22` / `#66666E` | `#EDEDF0` / `#A0A0A8` |
| Button hover / pressed | `#EDEDEF` / `#DEDEE2` | `#323237` / `#3C3C42` |
| Close hover / pressed (white glyph) | `#D12D3A` / `#B8232F` | `#E5484D` / `#EC5F63` |
| Shadow opacity focused / unfocused | 0.20 / 0.11 | 0.45 / 0.28 |
- 38px tall: the 1px outline, 36px of title bar, the 1px hairline. 1px outline left, right and
below (Aurorae's "Tiny" border size). Top corners round with a 10px radius, bottom ones square.
- A soft 16px shadow all round, falling off like the theme's gradients (`SHADOW_STOPS`).
- Title centred on the bar (bold, one point under the theme's font size) while it fits between
the buttons on both sides; otherwise shortened with ".." and left-aligned.
- Minimize, maximize (restore when maximized) and close on the right: 24px, 4px apart, 8px from
the edge, 1.5px line glyphs. No fill at rest; the hover fill under the pointer, the pressed
fill while held; close turns red. A press shows pressed and acts on the release over the
same button (moving off first cancels), as in KWin.
- Maximized: no shadow and square corners.
- Light or dark follows the Dark mode switch (the theme's surface brightness).
What differs from the theme under KWin: glyphs and outlines aren't antialiased (Chandra's
rasteriser draws whole pixels; a faint second line stands in for the half pixel); a maximized
window keeps the 38px bar and its 1px outline (Aurorae shrinks the bar to 34px and drops the
outline); the title uses Chandra's UI font rather than Inter SemiBold; there are no keep
above/below, on all desktops, shade or help buttons; the shadow is drawn in 2px bands.
**Breeze** is the frame Chandra had before: 32px title bar in the theme's surface colour, a 2px
outline in the accent colour when focused, 18px round buttons (close red), a shadow offset 4px
right and 6px down. Hover and pressed show as a ring around the button.
## Where it lives
- `compositor/scene/scene.mbt`: `WindowStyle` (frame sizes, button layout and hit test,
`button_at`) and `build_window_decoration`, which returns the frame as draw ops in the frame's
own coordinates, shadow included. Every host draws them as they are: the software renderer
(compositor/renderer) and the MoonBit host (wasmhost/bin/raster.mbt) have no shadow of their own and redraw `SHADOW_PAD` (18px) around a
window that changed.
- `compositor/host/compositor.mbt`: `window_style` (the style in use; `frame_top()`,
`frame_side()`, `frame_rect()`), `sync_window_style` (applies the setting: the work area, the
window manager's title-bar room, the tiled layout and client-decorated windows' sizes follow),
`title_button_at`, `title_button_hover`, `release_title_button`.
- Tests: compositor/renderer/decoration_test.mbt (pixels of both styles), compositor/host/
decoration_test.mbt (hover, press, cancel, switching styles, state.edn).
## Cost
The shadow and frame are plain spans (rectangles, a few rounded fills clipped to the corners),
about 70 draw ops per window. The hosts redraw a window's frame only when it changed (moved,
resized, focus or hover changed, or something above it moved); a client redrawing its buffer
redraws only its own area. Headless, a 1280x800 desktop with two tiled windows rasterises in the
same time with either style (5-8 ms a frame on the software renderer).