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

+130
View File
@@ -0,0 +1,130 @@
///| Draw one window in `style` over a flat grey backdrop and return the frame (window geometry at
/// (40, 60), 200 x 100, an opaque white client).
fn deco_frame(
style : @scene.WindowStyle,
theme : @scene.ThemeTokens,
focused~ : Bool = true,
maximized~ : Bool = false,
hover~ : Int = 0,
pressed~ : Int = 0,
) -> @renderer.Pixmap {
let scene = @scene.SceneGraph::new(320, 220)
scene.background_ops = [@scene.DrawOp::FillRect(@scene.Rect::new(0, 0, 320, 220), @scene.Rgba::new(128, 128, 128, 255), 0)]
let g = @scene.Rect::new(40, 60, 200, 100)
let (insets, deco_ops) = @scene.build_window_decoration(
style,
{ title: "Files", app_id: "org.kde.dolphin", focused, maximized, hover, pressed },
g.w + 2 * style.frame_side(),
g.h + style.frame_top() + style.frame_side(),
theme,
fn(s, size, bold) { @renderer.text_width(s, size, bold, false) },
)
let px : Array[Byte] = Array(capacity=200 * 100 * 4)
for _i = 0; _i < 200 * 100 * 4; _i = _i + 1 {
px.push(b'\xff')
}
scene.windows.push({
id: 1UL,
title: "Files",
app_id: "org.kde.dolphin",
focused,
fullscreen: false,
geometry: g,
deco_insets: insets,
deco_ops,
surface: Some({ width: 200, height: 100, stride: 800, format: 0, bytes: Bytes::from_array(px), host_id: 0U }),
})
@renderer.render_scene(scene)
}
///|
fn px_of(p : @renderer.Pixmap, x : Int, y : Int) -> @scene.Rgba {
p.pixel(x, y).unwrap()
}
///|
fn darker(a : @scene.Rgba, b : @scene.Rgba) -> Bool {
a.r.to_int() < b.r.to_int()
}
///|
test "flat frame: 38px title bar, 1px outline, hairline, kit colours (light and dark)" {
let style = @scene.WindowStyle::Flat
assert_eq((style.frame_top(), style.frame_side()), (38, 1))
let light = deco_frame(style, @scene.ThemeTokens::moon_day())
// Frame outer box: (39, 22) to (241, 161). Outline (#DADADE), title fill (#F6F6F7), hairline.
assert_eq(px_of(light, 120, 22), @scene.Rgba::from_hex("#DADADE"))
assert_eq(px_of(light, 120, 23), @scene.Rgba::from_hex("#F6F6F7"))
assert_eq(px_of(light, 44, 27), @scene.Rgba::from_hex("#F6F6F7"))
assert_eq(px_of(light, 120, 59), @scene.Rgba::from_hex("#DADADE"))
assert_eq(px_of(light, 39, 100), @scene.Rgba::from_hex("#DADADE"))
assert_eq(px_of(light, 240, 100), @scene.Rgba::from_hex("#DADADE"))
assert_eq(px_of(light, 120, 160), @scene.Rgba::from_hex("#DADADE"))
// The client starts right under the hairline.
assert_eq(px_of(light, 120, 60), @scene.Rgba::new(255, 255, 255, 255))
// Rounded top corners: the corner pixel is backdrop (with shadow), not frame.
assert_true(px_of(light, 39, 22).r.to_int() < 128)
let dark = deco_frame(style, @scene.ThemeTokens::moon_night())
assert_eq(px_of(dark, 120, 23), @scene.Rgba::from_hex("#1C1C1F"))
assert_eq(px_of(dark, 120, 22), @scene.Rgba::from_hex("#3A3A40"))
}
///|
test "flat frame: soft shadow all round, stronger focused, none maximized" {
let style = @scene.WindowStyle::Flat
let theme = @scene.ThemeTokens::moon_day()
let grey = @scene.Rgba::new(128, 128, 128, 255)
let f = deco_frame(style, theme)
// Left, right, above and below the frame, fading out by 16px.
for p in [(37, 100), (243, 100), (120, 20), (120, 163), (37, 163), (243, 163)] {
assert_true(darker(px_of(f, p.0, p.1), grey))
}
assert_true(darker(px_of(f, 37, 100), px_of(f, 30, 100)))
assert_eq(px_of(f, 20, 100), grey)
assert_eq(px_of(f, 120, 2), grey)
let unfocused = deco_frame(style, theme, focused=false)
assert_true(darker(px_of(f, 37, 100), px_of(unfocused, 37, 100)))
let maxed = deco_frame(style, theme, maximized=true)
assert_eq(px_of(maxed, 37, 100), grey)
// Square corners when maximized.
assert_eq(px_of(maxed, 39, 22), @scene.Rgba::from_hex("#DADADE"))
}
///|
test "flat frame: buttons are flat at rest, filled on hover and press, close turns red" {
let style = @scene.WindowStyle::Flat
let theme = @scene.ThemeTokens::moon_day()
let outer_w = 202
let buttons = style.buttons(outer_w)
assert_eq(buttons.map(b => b.0), [1, 2, 3])
// 24px buttons 4px apart, 8px from the right edge, centred in the title bar.
assert_eq(buttons[2].1, @scene.Rect::new(outer_w - 32, 7, 24, 24))
assert_eq(buttons[1].1.x, outer_w - 60)
assert_eq(style.button_at(outer_w, outer_w - 20, 19), 3)
assert_eq(style.button_at(outer_w, outer_w - 48, 19), 2)
assert_eq(style.button_at(outer_w, outer_w - 76, 19), 1)
assert_eq(style.button_at(outer_w, 40, 19), 0)
// Close button corner (inside its 6px radius): title colour at rest, red on hover, darker red
// pressed. Frame origin is (39, 22).
let (cx, cy) = (39 + buttons[2].1.x + 3, 22 + 7 + 12)
let rest = deco_frame(style, theme)
assert_eq(px_of(rest, cx, cy), @scene.Rgba::from_hex("#F6F6F7"))
assert_eq(px_of(deco_frame(style, theme, hover=3), cx, cy), @scene.Rgba::from_hex("#D12D3A"))
assert_eq(px_of(deco_frame(style, theme, pressed=3), cx, cy), @scene.Rgba::from_hex("#B8232F"))
let (mx, my) = (39 + buttons[1].1.x + 2, 22 + 7 + 12)
assert_eq(px_of(deco_frame(style, theme, hover=2), mx, my), @scene.Rgba::from_hex("#EDEDEF"))
assert_eq(px_of(deco_frame(style, theme, pressed=2), mx, my), @scene.Rgba::from_hex("#DEDEE2"))
}
///|
test "breeze frame keeps its 32px title bar and offset shadow" {
let style = @scene.WindowStyle::Breeze
assert_eq((style.frame_top(), style.frame_side()), (32, 2))
let f = deco_frame(style, @scene.ThemeTokens::moon_night())
let grey = @scene.Rgba::new(128, 128, 128, 255)
// Shadow 4px right / 6px down only: none to the left or above.
assert_true(darker(px_of(f, 244, 100), grey))
assert_true(darker(px_of(f, 120, 165), grey))
assert_eq(px_of(f, 36, 100), grey)
assert_eq(px_of(f, 120, 26), grey)
}
+3 -17
View File
@@ -772,23 +772,9 @@ pub fn render_scene(scene : @scene.SceneGraph) -> Pixmap {
// 2. Windows layer (bottom-to-top)
for win in scene.windows {
if !win.fullscreen {
let (top, right, bottom, left) = win.deco_insets
let outer_x = win.geometry.x - left
let outer_y = win.geometry.y - top
let outer_w = win.geometry.w + left + right
let outer_h = win.geometry.h + top + bottom
// Subtle drop shadow. The window covers most of it, so only the strips that stick out
// (right and bottom) are blended instead of the whole shadow rectangle.
let shadow = @scene.Rect::new(outer_x + 4, outer_y + 6, outer_w, outer_h)
let shadow_col = @scene.Rgba::new(0, 0, 0, 80)
fill_rounded_rect(pixmap, shadow, shadow_col, 8, Some(@scene.Rect::new(outer_x + outer_w, outer_y, 4, outer_h + 6)))
fill_rounded_rect(pixmap, shadow, shadow_col, 8, Some(@scene.Rect::new(outer_x, outer_y + outer_h, outer_w + 4, 6)))
// The title bar is slightly translucent when unfocused, so keep the shadow under it.
fill_rounded_rect(pixmap, shadow, shadow_col, 8, Some(@scene.Rect::new(outer_x, outer_y, outer_w, top + 2)))
// Breeze SSD decoration draw-ops
draw_ops(pixmap, win.deco_ops, outer_x, outer_y)
let (top, _, _, left) = win.deco_insets
// The frame: title bar, outline, buttons and its shadow (`@scene.build_window_decoration`).
draw_ops(pixmap, win.deco_ops, win.geometry.x - left, win.geometry.y - top)
}
// Client wl_shm surface