feat(theme): per-app accent: pm gives window manifest accent before app runs (display ACCENT, refused after BUFFER); theme::with_accent keeps hue, shifts lightness until contrast passes, else theme accent; tally pink

This commit is contained in:
2026-10-28 13:40:38 +01:00
parent 6827e1455d
commit 2b82f052ae
14 changed files with 158 additions and 16 deletions

View File

@@ -232,3 +232,23 @@ fn init_switches_the_theme_and_every_window_hears_of_it() {
let bogus = w::pack_name(b"Nope");
assert_eq!(s.handle_call(0, [w::SET_THEME, bogus[0], bogus[1], bogus[2]], None).0[0], MALFORMED);
}
#[test]
fn only_the_launcher_sets_an_accent_and_it_is_in_the_theme() {
let mut s = server();
let app = open(&mut s, 2, b"Tally");
let other = open(&mut s, 3, b"Snake");
let pink = 0xe91e63;
assert_eq!(s.handle_call(app, [w::ACCENT, pink, 0, 0], None).0[0], w::OK);
assert_eq!(s.handle_call(app, [w::ACCENT, 0x00ff00, 0, 0], None).0[0], MALFORMED, "once");
// The app starts: too late for it to choose one itself.
s.handle_call(other, [w::BUFFER, 0, 0, 0], None);
assert_eq!(s.handle_call(other, [w::ACCENT, pink, 0, 0], None).0[0], MALFORMED);
let accent = |s: &mut Srv, badge| {
let r = s.handle_call(badge, [w::THEME, 0, 0, 0], None).0;
// Colour 3, the top of the theme's second word.
theme::Rgba::rgb((r[3] >> 32) as u32 & 0xff_ffff)
};
assert_eq!(accent(&mut s, other), theme::Theme::WHIMSY_DARK.accent);
assert_eq!(accent(&mut s, app), theme::with_accent(theme::Theme::WHIMSY_DARK, theme::Rgba::rgb(pink as u32)).accent);
}