Overview (Exposé): every window side by side when the launcher opens, or alone on Super+W
CI / test (push) Successful in 1m35s

Opening the launcher (Super tap or its panel button) now also shows every window of the
workspace scaled down beside it, over the dimmed wallpaper, like GNOME's Activities overview:
a natural layout (rows, one scale, aspect ratios kept, never enlarged), minimized windows
dimmed, windows gliding in and out over 220 ms. Hover lights a window and shows a close
button; click brings it forward and closes the overview and launcher; middle-click closes the
window; Escape or a click on empty space closes it. Typing in the launcher's search fades the
windows whose title and app id don't match.

- compositor/host/overview.mbt: layout, area beside the launcher, hit testing, easing,
  input and draw ops; previews reuse the Alt+Tab thumbnails (10 fps refresh, nothing redrawn
  once settled).
- New shortcut "overview" (Super+W) in the shortcut table, rebindable in Settings > Shortcuts.
- chandra-ctl / control socket: "shortcut ID" runs any shortcut by id.
- Both renderers keep only one large scaled copy per image (a gliding preview is drawn at a
  new size every frame) and draw images up to 4096 px.
- Tests: layout packing and aspect ratio, balance, hit testing, animation, Super tap + click,
  Super+W + Escape/empty click, search filter, middle click, inspector, control command;
  screenshots of 1/4/9 windows in dark and light.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hgo3PfGPY8wwv21ZZS
This commit is contained in:
Claude committed 2026-11-26 00:24:16 +00:00
1 parent acf2daa399
commit 30f5e88639
15 files changed
+1321 -10

No files matched your search

+33 -2
View File
@@ -437,6 +437,14 @@ pub struct Images {
/// Biggest image side accepted from a file, and drawn.
const MAX_IMAGE: i32 = 1024;
/// The largest size an image is drawn at (a window preview gliding to its window's size).
const MAX_DRAW: i32 = 4096;
/// Sizes past which only one scaled copy of an image is cached (icons are drawn at a few small
/// sizes; previews at one large one, or a new one each frame while they move).
fn big_size(w: i32, h: i32) -> bool {
w * h > 128 * 128
}
fn decode_png(bytes: &[u8]) -> Option<ImageSrc> {
let mut dec = png::Decoder::new(std::io::Cursor::new(bytes));
@@ -563,7 +571,7 @@ impl Images {
/// Image `handle` at `w` x `h` (cached), or None for an unknown handle or a silly size.
fn sized(&self, handle: u32, w: i32, h: i32) -> Option<Rc<Vec<u8>>> {
if w <= 0 || h <= 0 || w > MAX_IMAGE || h > MAX_IMAGE {
if w <= 0 || h <= 0 || w > MAX_DRAW || h > MAX_DRAW {
return None;
}
let src = self.srcs.get((handle as usize).checked_sub(1)?)?;
@@ -575,7 +583,13 @@ impl Images {
ImageSrc::Pixels { w: sw, h: sh, rgba } => scale_rgba(rgba, *sw, *sh, w, h),
ImageSrc::Svg(tree) => render_svg(tree, w, h)?,
});
self.sized.borrow_mut().insert((handle, w, h), px.clone());
let mut sized = self.sized.borrow_mut();
// A large image is kept at one large size only: a window preview that glides (the
// overview) is drawn at a new size every frame.
if big_size(w, h) {
sized.retain(|k, _| k.0 != handle || !big_size(k.1, k.2));
}
sized.insert((handle, w, h), px.clone());
Some(px)
}
}
@@ -1212,6 +1226,23 @@ mod tests {
assert_eq!(px(&r, 0, 0), [0, 0, 255, 255]);
}
#[test]
fn a_large_image_is_cached_at_one_large_size_only() {
let mut imgs = Images::default();
let h = imgs.put_pixels(0, 2, 2, [200u8; 16].to_vec());
// Small sizes (icons) stay cached side by side.
assert!(imgs.sized(h, 16, 16).is_some());
assert!(imgs.sized(h, 48, 48).is_some());
// A preview gliding through sizes keeps one large copy (up to the draw limit).
for w in [300, 400, 500, 2000] {
assert!(imgs.sized(h, w, w / 2).is_some());
}
let keys: Vec<_> = imgs.sized.borrow().keys().cloned().collect();
assert_eq!(keys.len(), 3);
assert!(keys.contains(&(h, 2000, 1000)));
assert!(imgs.sized(h, 5000, 10).is_none());
}
#[test]
fn images_load_once_by_path_and_draw_scaled_png_and_svg() {
let dir = std::env::temp_dir().join(format!("chandra-img-{}", std::process::id()));