Each pill now shows the icon the app's .desktop file names (Icon=), looked up in the freedesktop icon themes, instead of the letter tile. The tile stays as the fallback for windows with no app id, no desktop file or no icon the host can read. - WIT: a new `icons` capability (`app-icon(app-id) -> u32`, a handle, never a path or pixels) and an `image(image-op)` draw op (appended, so existing modules keep their ABI). taskbar-widget and plasmoid-host import `icons`. Host raster gains `load-image(path)` and a `draw-image` op; the plasmoids host gets an icons table (6: app id, handle). - Compositor (shell/icons.mbt): window app id -> desktop file (resolve_app_id, so StartupWMClass and last-dotted-part matches work) -> Icon= -> theme lookup (XDG data dirs, ~/.icons, flatpak exports; hicolor, Adwaita, breeze; 48/64/32 px PNG first, then scalable SVG when the host can draw it, then other sizes, then /usr/share/pixmaps). Absolute Icon= paths are used as they are. Results are cached per app id; the table is published only when a module imports `icons`. - wasm host (host-wasm): PNG via the png crate, SVG via resvg (rendered sharp at each size), PNGs area-averaged to the drawn size; loads cached by path. - Native build: a small PNG decoder (compositor/renderer/png.mbt: inflate + filters, 1-16 bit, palettes with tRNS) and the Image op in the software renderer. SVG-only icons fall back to the tile there. The wasmer stub serves `icons.app-icon` from the same table. - Tests: PNG decoder fixtures (all filters, fixed/dynamic/stored blocks, palette), image scaling and drawing, icon lookup order, Icon= parsing, task module icon-or-tile (native and wasmtime), host raster PNG+SVG loading and drawing. Checked end to end with the wasm host: foot's hicolor icon shows on its pill. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DPL5hhmtDt52EjaW8jevGU
This commit is contained in:
53 files changed
+2284
-473
No files matched your search
@@ -10,6 +10,8 @@ priv struct DesktopApp {
|
||||
command : String
|
||||
/// StartupWMClass: the app id its windows carry when that is not the desktop file's name.
|
||||
wm_class : String
|
||||
/// Icon=: an icon theme name ("firefox") or an absolute path.
|
||||
icon : String
|
||||
}
|
||||
|
||||
///| Directories scanned, lowest priority first (later ones override by file name).
|
||||
@@ -66,6 +68,7 @@ fn parse_desktop(id : String, text : String, have_terminal : Bool) -> DesktopApp
|
||||
let mut terminal = false
|
||||
let mut kind = "Application"
|
||||
let mut wm_class = ""
|
||||
let mut icon = ""
|
||||
for raw in text.split("\n") {
|
||||
let line = raw.trim(chars=" \r\t").to_string()
|
||||
if line.length() == 0 || line.has_prefix("#") {
|
||||
@@ -93,6 +96,7 @@ fn parse_desktop(id : String, text : String, have_terminal : Bool) -> DesktopApp
|
||||
"NoDisplay" | "Hidden" => if val == "true" { hidden = true }
|
||||
"Terminal" => terminal = val == "true"
|
||||
"StartupWMClass" => wm_class = val
|
||||
"Icon" => icon = val
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
@@ -113,7 +117,7 @@ fn parse_desktop(id : String, text : String, have_terminal : Bool) -> DesktopApp
|
||||
_ => "Other"
|
||||
}
|
||||
let comment = if comment.length() > 0 { comment } else { generic }
|
||||
Some({ id, name, comment, category, command, wm_class })
|
||||
Some({ id, name, comment, category, command, wm_class, icon })
|
||||
}
|
||||
|
||||
///| Scan every applications dir; later dirs override earlier ones, result sorted by name.
|
||||
@@ -169,6 +173,11 @@ test "parse_desktop keeps StartupWMClass" {
|
||||
Some(a) => assert_eq(a.wm_class, "Code")
|
||||
None => fail("expected entry")
|
||||
}
|
||||
let t2 = "[Desktop Entry]\nType=Application\nName=Files\nExec=nautilus\nIcon=org.gnome.Nautilus\n[Desktop Action w]\nIcon=other\n"
|
||||
match parse_desktop("org.gnome.Nautilus", t2, true) {
|
||||
Some(a) => assert_eq(a.icon, "org.gnome.Nautilus")
|
||||
None => fail("expected entry")
|
||||
}
|
||||
}
|
||||
|
||||
///|
|
||||
|
||||
Reference in new issue
Block a user