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
@@ -130,6 +130,16 @@ pub fn wasmExportRender(p0 : Int, p1 : Int) -> Int {
|
||||
PopClip => {
|
||||
mbt_ffi_store8((iter_base) + 0, (6))
|
||||
|
||||
()
|
||||
}
|
||||
Image(payload6) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (7))
|
||||
mbt_ffi_store32((iter_base) + 4, ((payload6).rect).x)
|
||||
mbt_ffi_store32((iter_base) + 8, ((payload6).rect).y)
|
||||
mbt_ffi_store32((iter_base) + 12, (((payload6).rect).w).reinterpret_as_int())
|
||||
mbt_ffi_store32((iter_base) + 16, (((payload6).rect).h).reinterpret_as_int())
|
||||
mbt_ffi_store32((iter_base) + 20, ((payload6).image).reinterpret_as_int())
|
||||
|
||||
()
|
||||
}
|
||||
}
|
||||
@@ -160,6 +170,7 @@ pub fn wasmExportRenderPostReturn(p0 : Int) -> Unit {
|
||||
}
|
||||
5 => ()
|
||||
6 => ()
|
||||
7 => ()
|
||||
_ => panic()
|
||||
}
|
||||
|
||||
@@ -278,6 +289,16 @@ pub fn wasmExportPopup() -> Int {
|
||||
PopClip => {
|
||||
mbt_ffi_store8((iter_base) + 0, (6))
|
||||
|
||||
()
|
||||
}
|
||||
Image(payload8) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (7))
|
||||
mbt_ffi_store32((iter_base) + 4, ((payload8).rect).x)
|
||||
mbt_ffi_store32((iter_base) + 8, ((payload8).rect).y)
|
||||
mbt_ffi_store32((iter_base) + 12, (((payload8).rect).w).reinterpret_as_int())
|
||||
mbt_ffi_store32((iter_base) + 16, (((payload8).rect).h).reinterpret_as_int())
|
||||
mbt_ffi_store32((iter_base) + 20, ((payload8).image).reinterpret_as_int())
|
||||
|
||||
()
|
||||
}
|
||||
}
|
||||
@@ -316,6 +337,7 @@ pub fn wasmExportPopupPostReturn(p0 : Int) -> Unit {
|
||||
}
|
||||
5 => ()
|
||||
6 => ()
|
||||
7 => ()
|
||||
_ => panic()
|
||||
}
|
||||
|
||||
@@ -372,18 +394,28 @@ pub fn wasmExportOnEvent(p0 : Int, p1 : Int, p2 : Int, p3 : Int) -> Int {
|
||||
extern "wasm" fn mbt_ffi_store8(offset : Int, value : Int) =
|
||||
#|(func (param i32) (param i32) local.get 0 local.get 1 i32.store8)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load32(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_ptr2str(ptr : Int, len : Int) -> String =
|
||||
#|(func (param i32) (param i32) (result i32)
|
||||
#| local.get 0
|
||||
#| local.get 1 call $moonbit.init_array16
|
||||
#| local.get 0)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_free(position : Int) =
|
||||
#|(func (param i32) local.get 0 call $moonbit.decref)
|
||||
|
||||
///|
|
||||
#owned(str)
|
||||
extern "wasm" fn mbt_ffi_str2ptr(str : String) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0)
|
||||
extern "wasm" fn mbt_ffi_store32(offset : Int, value : Int) =
|
||||
#|(func (param i32) (param i32) local.get 0 local.get 1 i32.store)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load32(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load)
|
||||
extern "wasm" fn mbt_ffi_load8_u(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load8_u)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int =
|
||||
@@ -393,17 +425,7 @@ extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int =
|
||||
#| local.get 1)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load8_u(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load8_u)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_store32(offset : Int, value : Int) =
|
||||
#|(func (param i32) (param i32) local.get 0 local.get 1 i32.store)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_ptr2str(ptr : Int, len : Int) -> String =
|
||||
#|(func (param i32) (param i32) (result i32)
|
||||
#| local.get 0
|
||||
#| local.get 1 call $moonbit.init_array16
|
||||
#| local.get 0)
|
||||
#owned(str)
|
||||
extern "wasm" fn mbt_ffi_str2ptr(str : String) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0)
|
||||
|
||||
@@ -2,6 +2,7 @@ import {
|
||||
"chandra/desktop/interface/chandra/desktop/types" @types,
|
||||
"chandra/desktop/interface/chandra/desktop/theme" @theme,
|
||||
"chandra/desktop/interface/chandra/desktop/windows" @windows,
|
||||
"chandra/desktop/interface/chandra/desktop/icons" @icons,
|
||||
"chandra/desktop/lib/ui" @ui,
|
||||
"chandra/desktop/lib/dock" @dock,
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
///| Implementation of `chandra:desktop/plasmoid` for the task manager: one pill per open
|
||||
/// window, in the order the windows were opened (so the bar doesn't reshuffle when focus changes).
|
||||
/// Each pill starts with the app's icon (the same coloured tile the dock shows for that app id).
|
||||
/// Each pill starts with the app's icon: the one its .desktop file names, from the icon theme (the
|
||||
/// `icons` capability), else the coloured letter tile the dock shows for that app id.
|
||||
/// The focused window's pill is lit, a minimized window's is dimmed; a click focuses the window and
|
||||
/// restores it if it was minimized. When the bar is too narrow the pills shrink to fit, and below
|
||||
/// `icon_only_w` they show just the icon.
|
||||
@@ -33,6 +34,17 @@ fn app_ids() -> Map[UInt, String] {
|
||||
m
|
||||
}
|
||||
|
||||
///| The app's icon `s` pixels square centred on (cx, cy): its theme icon when the host has one,
|
||||
/// else the letter tile (keyed by the app id, or the title for windows without one).
|
||||
fn pill_icon(cx : Int, cy : Int, s : Int, app : String, title : String) -> Array[@types.DrawOp] {
|
||||
let handle = if app.length() > 0 { @icons.app_icon(app) } else { 0U }
|
||||
if handle != 0U {
|
||||
return [Image({ rect: @ui.rect(cx - s / 2, cy - s / 2, s, s), image: handle })]
|
||||
}
|
||||
let key = if app.length() > 0 { app } else { title }
|
||||
@dock.app_icon(cx, cy, s, key, @dock.app_glyph(app, title))
|
||||
}
|
||||
|
||||
///| The width the module was last drawn at, and the pill the pointer is over (-1: none).
|
||||
let last_w : Ref[Int] = { val: 300 }
|
||||
|
||||
@@ -147,14 +159,11 @@ pub fn render(size : @types.Size) -> Array[@types.DrawOp] {
|
||||
}
|
||||
let title = if win.title.length() > 0 { win.title } else { "(untitled)" }
|
||||
let app = ids.get(win.id).unwrap_or("")
|
||||
let glyph = @dock.app_glyph(app, title)
|
||||
// Windows without an app id still get a stable colour, keyed by their title.
|
||||
let key = if app.length() > 0 { app } else { title }
|
||||
let isz = icon_size(h)
|
||||
if pw < icon_only_w {
|
||||
ops.append(@dock.app_icon(x + pw / 2, h / 2, isz, key, glyph))
|
||||
ops.append(pill_icon(x + pw / 2, h / 2, isz, app, title))
|
||||
} else {
|
||||
ops.append(@dock.app_icon(x + 6 + isz / 2, h / 2, isz, key, glyph))
|
||||
ops.append(pill_icon(x + 6 + isz / 2, h / 2, isz, app, title))
|
||||
let tx = x + 6 + isz + 6
|
||||
ops.push(@ui.text(tx, h / 2, fit_text(title, fs, x + pw - 8 - tx), fs, fg, bold=focused))
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user