Window frames in the style of V's Flatkit Aurorae theme, the classic frame as a setting
CI / test (push) Canceled after 52s

The default frame now follows codegod100/kde aurorae (Flatkit / Flatkit Dark): the kit's
neutral title bar, a 1px outline with 10px top corners, a hairline under the title, a soft
16px shadow all round, a centred title and 24px flat buttons with hover and pressed fills
(close turns red). 38px title bar, 1px border. Maximized: no shadow, square corners.

- scene: WindowStyle (frame sizes, button layout, hit test) and build_window_decoration;
  the shadow is part of the decoration ops, so the three rasterisers lost their own offset
  shadow and redraw 18px around a changed window.
- host: the frame size follows the style (work area, wm title-bar room, CSD client boxes,
  hit zones, screenshots); title-bar buttons track hover, show pressed, act on release.
- Settings > Session > Flat window frames (off: the old Breeze-like frame), saved as
  :window-style :breeze; an unknown value is logged.
- docs/window-frames.md; tests for both styles' pixels, button states and switching.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hmKDDLLES2aBrrnPxT
This commit is contained in:
Claude committed 2026-11-26 04:09:38 +00:00
1 parent 2c2ce3f913
commit 14acc5d42e
20 files changed
+1005 -142

No files matched your search

+2 -2
View File
@@ -14,7 +14,7 @@ Traditional Wayland compositors (KWin, Sway, Mutter) bundle device management, W
| Layer | Responsibility | Implementation | Trust Level |
| :--- | :--- | :--- | :--- |
| **Host (Mechanism)** | Event loop, Wayland binary wire protocol server (`wl_display`, `wl_registry`, `wl_compositor`, `wl_shm`, `xdg_wm_base`, `zxdg_decoration_manager_v1`, `wl_seat`, `wl_output`), SHM memory mapping, retained scene graph & damage tracker, ARGB8888 software rasterizer & PNG encoder, minimal POSIX C FFI (`compositor/sys/sys_stub.c`) | **MoonBit** (`compositor/` compiled with `--target native`) | Trusted Computing Base (TCB) |
| **Policy & Components** | Window placement, BSP tiling/floating/monocle layouts, focus policy, hit-testing/input routing, Breeze SSD decorations, panel layout, desktop background, widgets | **MoonBit** (`lib/wm/`, `lib/*`, and Wasm components `components/*` via `wit-bindgen moonbit`) | Modular policy packages & sandboxed Wasm components |
| **Policy & Components** | Window placement, BSP tiling/floating/monocle layouts, focus policy, hit-testing/input routing, server-side window frames (docs/window-frames.md), panel layout, desktop background, widgets | **MoonBit** (`lib/wm/`, `lib/*`, and Wasm components `components/*` via `wit-bindgen moonbit`) | Modular policy packages & sandboxed Wasm components |
```mermaid
flowchart TB
@@ -201,7 +201,7 @@ compositor/
│ ├── wire.mbt # WireWriter / WireReader (u32, i32, str, array, msg framing)
│ └── server.mbt # WaylandServer, wl_shm, xdg_wm_base, zxdg_decoration_manager_v1
├── scene/ # Pure MoonBit retained scene graph & damage tracker
│ └── scene.mbt # ThemeTokens, SceneGraph, DamageTracker, Breeze SSD & shell ops
│ └── scene.mbt # ThemeTokens, SceneGraph, DamageTracker, window frames (WindowStyle) & shell ops
├── renderer/ # Pure MoonBit software rasterizer & encoders
│ ├── renderer.mbt # Pixmap, SrcOver blending, rounded rects, 5x7 font, shm blit, PNG/PPM
│ └── renderer_test.mbt # Unit tests (wasm + native)
+3
View File
@@ -61,3 +61,6 @@ most ~30 frames a second however often it asks.
the project files (`smooth-anim/anim-bench.sh`) runs a headless 1920x1080 session with four
windows, opens and closes the overview six times and runs Live Starfield, and prints frame
rates, frame gaps and raster times from that trace.
Window frames, their shadow included, are draw ops from `@scene.build_window_decoration`
(docs/window-frames.md): plain spans, redrawn only when the window or what is above it changes.
+71
View File
@@ -0,0 +1,71 @@
# 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), the MoonBit host (wasmhost/bin/raster.mbt) and the Rust host
(host-wasm/src/raster.rs) 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).