Task manager: show an app icon on each window's pill
CI / test (push) Failing after 18s

Each pill now starts with the app's icon: the same coloured tile with a
letter that the dock draws for that app id, so an app looks the same in
both. The app id comes from windows.all (the task-bar rows carry only
titles); windows without one fall back to a title-keyed tile. Pills
narrower than 72px show just the centred icon.

The tile drawing moves into lib/dock (app_icon, app_glyph) and the dock
uses it too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hm1XqzhrA4N8FyhuRa
This commit is contained in:
Claude committed 2026-11-25 18:31:41 +00:00
1 parent 46780c399b
commit 9a25d70f77
5 files changed
+105 -12

No files matched your search

+42 -9
View File
@@ -82,6 +82,47 @@ pub fn tile_color(id : String) -> @types.Color {
@ui.color(r, g, b, 255)
}
///| The letter on an app's icon tile when the app catalog's glyph isn't at hand (the task manager
/// only knows a window's app id): the first letter of the id's last dotted part, so
/// `org.gnome.Nautilus` -> "N" and `foot` -> "F". Falls back to `fallback`'s first letter, then "?".
pub fn app_glyph(app_id : String, fallback : String) -> String {
let parts = app_id.split(".").to_array()
let mut i = parts.length() - 1
while i >= 0 {
for c in parts[i] {
if c.is_ascii_alphabetic() || c.is_ascii_digit() {
return c.to_string().to_upper()
}
}
i = i - 1
}
for c in fallback {
if c != ' ' {
return c.to_string().to_upper()
}
}
"?"
}
///| An app's icon: a rounded tile `s` pixels square centred on (cx, cy) in the app's colour, with
/// its glyph in white. Shared by the dock and the task manager so an app looks the same in both.
pub fn app_icon(
cx : Int,
cy : Int,
s : Int,
id : String,
glyph : String,
hover~ : Bool = false,
) -> Array[@types.DrawOp] {
let white = @ui.color(255, 255, 255, 255)
let c = tile_color(id)
let fill = if hover { @ui.lerp_color(c, white, 1, 5) } else { c }
[
@ui.fill_rect(@ui.rect(cx - s / 2, cy - s / 2, s, s), fill, radius=s / 4),
@ui.text(cx, cy, glyph, s * 11 / 20, white, align=CENTER, bold=true),
]
}
///| Draw the dock into `size`. `hover` is the hovered tile index or -1.
pub fn render(
size : @types.Size,
@@ -102,18 +143,10 @@ pub fn render(
)
return ops
}
let white = @ui.color(255, 255, 255, 255)
for i = 0; i < n; i = i + 1 {
let s = tile_size(i, hover, h)
let cx = pad + i * pitch(h) + base_size(h) / 2
let x = cx - s / 2
let y = (h - s) / 2
let c = tile_color(apps[i].id)
let fill = if i == hover { @ui.lerp_color(c, white, 1, 5) } else { c }
ops.push(@ui.fill_rect(@ui.rect(x, y, s, s), fill, radius=s / 4))
ops.push(
@ui.text(cx, h / 2, apps[i].glyph, s * 11 / 20, white, align=CENTER, bold=true),
)
ops.append(app_icon(cx, h / 2, s, apps[i].id, apps[i].glyph, hover=i == hover))
}
ops
}