diff --git a/CHANGELOG.md b/CHANGELOG.md
index b81dcd8..98603e6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,8 @@ All notable changes will be documented here. The format follows [Keep a Changelo
### Added
+- `FAD-0502` Application-row slice: asynchronous validated local PNG icons with text fallback, playing/idle/muted state, and accessible mixed-volume help. Output-device controls remain pending.
+
- `FAD-0202` Secure local PNG icon resolution with trusted XDG roots, bounded caching, and traversal, symlink, malformed-file, and size protections.
- `FAD-0203` Flatpak-first canonical identity from bounded sandbox metadata and exported host desktop entries.
- `FAD-0204` Optional Snap identity from corroborated wrapper metadata without invoking or depending on Snap tooling.
diff --git a/README.md b/README.md
index 4336ad5..ddd70ff 100644
--- a/README.md
+++ b/README.md
@@ -89,7 +89,9 @@ dotnet run --project src/Fadrio.Cli -- profile clear xdg:firefox
The override appears in subsequent `apps` output while the canonical ID remains unchanged.
-Launch the in-development mixer with `dotnet run --project src/Fadrio.UI`. Its application rows reflect the live PipeWire snapshot and use the same application-wide volume/mute command path as the CLI. Output-device controls, icons, tray behavior, and UI polish remain on the roadmap.
+Launch the in-development mixer with `dotnet run --project src/Fadrio.UI`. Its application rows reflect the live PipeWire snapshot and use the same application-wide volume/mute command path as the CLI. Application rows load validated local PNG icons asynchronously, fall back to an initial when artwork is missing or invalid, and show playback/mute state. Mixed-volume controls explain that an adjustment sets every owned stream to the same level. Output-device controls, tray behavior, and UI polish remain on the roadmap.
+
+[See the current application-row screenshot](docs/screenshots/fad-0502-application-icon.png), captured with an isolated silent fixture and the normal host fonts.
[See the first live-row screenshot](docs/screenshots/fad-0501-live-fixture.png), captured with a controlled, silent PipeWire fixture rather than a user's applications.
diff --git a/ROADMAP.md b/ROADMAP.md
index 8413e22..7d2cc50 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -181,6 +181,10 @@ Canonical ticket format:
- [x] `FAD-0501` `P0` Connect immutable mixer snapshots and commands to the Avalonia view models.
- [ ] `FAD-0502` `P1` Build accessible output and logical-application rows with mixed-volume state.
+ - Status: In progress
+ - Scope: Validated asynchronous local application icons, readable fallback/activity states, and mixed-volume help are the current application-row slice. Output-device rows remain pending.
+ - Acceptance: Accessible logical-application and output rows, verified mixed-volume behavior, local icon fallback, and rendered keyboard/mouse checks.
+ - Evidence: `docs/development/qualifying-application-rows.md`; this slice does not complete output control or REL-00006.
- [x] `FAD-0503` `P1` Add stable sorting, interaction freeze, empty, unavailable, and reconnect states.
- Scope: Deterministic active-row ordering and pointer/keyboard interaction freeze; connected-empty versus unavailable states and reconnect-safe commands. Persistent pinned/inactive rows remain FAD-0303.
- Acceptance: Rows are reused, structural changes wait until gesture end, removed targets disable immediately, queued commands are discarded on disconnect, and rendered controls recover after an isolated daemon restart.
diff --git a/docs/design/icons.md b/docs/design/icons.md
index 650fe94..880fa41 100644
--- a/docs/design/icons.md
+++ b/docs/design/icons.md
@@ -5,3 +5,5 @@ Icon resolution order is user override, desktop entry, PipeWire icon name, local
Bundled icons require editable source and known licensing. Runtime-resolved installed icons are not automatically redistributable repository assets. Cap file size and dimensions, allow only supported local formats, and never download icons from the network in v1.
The current local resolver accepts PNG files only. It searches configured XDG icon roots with a bounded, deterministic traversal, rejects URLs and paths outside those trusted roots (including symlink escapes), and validates the PNG signature and dimensions before copying it. Cached files live under `$XDG_CACHE_HOME/fadrio/icons/`, are keyed by source path plus modification signature, and are pruned by both entry count and total bytes. Vector decoding and rasterization remain out of scope until they can use a reviewed decoder.
+
+The application UI loads these validated PNGs on background workers, limits parallel loads to two, and decodes thumbnails with both dimensions bounded by 64 pixels. Missing or undecodable artwork shows the first Unicode text element of the application name. Detached rows cancel obsolete loads and dispose their bitmaps. SVG-only installed icons use the fallback.
diff --git a/docs/dev-diaries/003-icons-that-cannot-crash-the-mixer.md b/docs/dev-diaries/003-icons-that-cannot-crash-the-mixer.md
new file mode 100644
index 0000000..76e5edb
--- /dev/null
+++ b/docs/dev-diaries/003-icons-that-cannot-crash-the-mixer.md
@@ -0,0 +1,48 @@
+> Status: Draft; not published.
+> Suggested community: r/Fadrio; flair: Development Update.
+> Website slug: fadrio-dev-diary-03-icons-that-cannot-crash-the-mixer
+> Image: docs/screenshots/fad-0502-application-icon.png (actual isolated silent fixture).
+
+# Fadrio Dev Diary #3 — An icon should not be able to crash a mixer
+
+Fadrio is the Linux application mixer I want to use myself: one recognizable application, one slider, and one mute action, even when that application owns several playback streams. This update makes those rows easier to recognize. It also found a surprisingly enthusiastic failure mode for a tiny PNG.
+
+## From identity to something you can recognize
+
+The resolver already knew where to find trusted local application icons. The window now actually uses them. Each row loads its validated PNG in the background, shows the application name beside it, and falls back to a readable initial when the artwork is missing or invalid.
+
+The loading path keeps the existing rules: local XDG roots only, bounded file sizes and dimensions, a bounded disk cache, and no downloading. Only two searches/decodes run at once. The decoded thumbnail fits inside 64 × 64 pixels, including unusually tall or wide images. When a row disappears or its icon changes, obsolete work is canceled and replaced bitmaps are disposed.
+
+There is a deliberate limitation here: this path currently supports PNG. An installed application with only an SVG icon gets the fallback. A missing icon should be a small visual inconvenience, not a reason to make the audio controls disappear.
+
+## The PNG that had a header and very little ambition
+
+For the rendered regression check, I copied the first 24 bytes of a valid PNG and left out the actual image data. The existing resolver accepted the signature and dimensions. Avalonia.Skia 12.1.2 then attempted to use a null codec and threw a `NullReferenceException`.
+
+That originally took down the window. The UI now contains that specific decoder failure at the decode boundary and displays the initial instead. The real desktop check then drags the slider and toggles mute on the same fixture. This is why I want visual tests alongside unit tests: a plausible image header and a working mixer are different achievements.
+
+The icon has been relieved of its responsibilities as application supervisor.
+
+## What “mixed” means when one application has several streams
+
+The row also shows a textual playback/mute state. `Playing` comes from the existing stream activity state; it is not a new signal meter. `Muted` does not depend on spotting a different color.
+
+For multiple streams with different levels, the row retains the mixed-volume label. The tooltip and accessibility help now explain the action: moving the slider sets **every owned stream to the same level**. It does not silently preserve a ratio or invent a separate routing policy. Backend refreshes still reuse the same row objects, and an active gesture keeps its position while other applications change.
+
+## What I actually checked
+
+The local build passes **109 managed tests**, including 23 UI cases, plus two native tests, six Python roadmap/synchronization tests, and the isolated PipeWire integration scenario. Formatting and roadmap checks also pass.
+
+In the actual 360 × 680 Avalonia window on this GNOME Wayland desktop through XWayland, the isolated silent fixture reaches 37% with a drag and 10% with Home plus ten Right keys. The mute button works. The controls remain usable after the damaged icon, and work again after stopping the private PipeWire daemon during a drag and restarting it.
+
+The screenshot shows that controlled fixture and Fadrio's own icon. It is not a mockup or somebody's private application list.
+
+Normal host-font startup also reached the window today. The previous startup stall did not reproduce, so I am keeping that investigation open rather than pretending to have found its cause. No host fonts were removed or restricted.
+
+## Still an alpha, still development work
+
+This is an application-row slice in FAD-0502. Output-device controls, tray/single-instance behavior, pinned/inactive rows and durable volume policies still need work. The broader KDE, native Wayland, scaling and screen-reader qualification matrix remains open. There is no new supported binary release from this change.
+
+The implementation is under review; this diary is a draft for the website and Reddit, not a release announcement.
+
+For a daily mixer, which missing behavior would you prioritize next: remembered application levels, pinned controls for applications that are currently silent, or quick access from the tray?
diff --git a/docs/development/qualifying-application-rows.md b/docs/development/qualifying-application-rows.md
new file mode 100644
index 0000000..09e4cbb
--- /dev/null
+++ b/docs/development/qualifying-application-rows.md
@@ -0,0 +1,31 @@
+# FAD-0502 application-row slice
+
+Recorded on 2026-10-06 on the local GNOME Wayland desktop through XWayland. This is application-row progress; output-device controls and the REL-00006 desktop matrix remain open.
+
+## Behavior
+
+Rows display the resolved identity's local PNG icon, or the first Unicode text element of the application name when artwork is missing, rejected, or undecodable. The existing local resolver enforces trusted XDG roots, source/dimension limits, and bounded disk caching. No network access or SVG decoder is added. Two concurrent background loads are allowed; decoded thumbnails fit within 64 x 64 pixels. Reference changes and row detachment cancel obsolete loads, clear the old image, and dispose replaced or stale bitmaps. Backend snapshots do not wait for artwork.
+
+The fallback adds no tab stop; application name, slider and mute remain the usable controls. Long names have a tooltip. Mixed-volume help is available both as a tooltip and automation help text: a slider adjustment sets every owned stream to the same level. Playing/Idle reflects the existing backend stream state, not measured signal amplitude; Muted is explicit text. Screen-reader conformance remains unqualified.
+
+A header-only PNG passed the resolver's header check but caused Avalonia.Skia 12.1.2 to dereference a null codec in `ImmutableBitmap`. The UI contains that specific exception at the decode boundary, uses the text fallback, and keeps the row usable. The desktop harness retains this real malformed-input regression; it is not a synthetic claim that all image decoders are safe.
+
+## Local validation
+
+- `FADRIO_RUN_PIPEWIRE_INTEGRATION=1 ./scripts/test.sh`: 109 managed tests, two native tests, and isolated PipeWire integration passed.
+- Seven additional UI cases cover icon/reference refresh on a reused row, Unicode fallback, activity/mute state, and mixed-volume explanation after adjustment. The UI suite has 23 cases.
+- Six Python roadmap/synchronization tests, roadmap audit, formatting verification, and whitespace check passed.
+- `./scripts/test-ui-interactions.sh` with default `FADRIO_UI_FONT_MODE=host`: rendered icon, 37% drag, Home + ten Right keys to 10%, mute, usable controls after a header-only icon, disconnect during drag, and controls after isolated daemon restart.
+- The native bridge and Core dependencies are unchanged. No ordinary host audio is modified by the harness.
+
+
+
+
+
+The screenshots show the actual 360 x 680 Avalonia window with a silent, controlled `Fadrio Fixture` stream and the project's own licensed icon, not third-party application artwork or a design mockup.
+
+## Startup observation and limits
+
+The normal host-font configuration reached the mixer in the bounded local checks; the retained harness records whole-second window readiness in `startup.txt`. There are 2,773 entries in this host's current `fc-list` output. No fonts or host caches were removed or restricted. The old BUG-00004 stall did not reproduce, so its original root cause remains unknown and the ticket stays open. Rider could list configurations but reported that its debug launch did not start; the direct window/trace and harness are the runtime evidence here.
+
+The harness locates the slider from its actual rendered track with Python Pillow, rather than assuming fixed font metrics. It asks GNOME to activate the owned window through `_NET_ACTIVE_WINDOW`, verifies X keyboard focus, explicitly focuses the recreated slider, and polls observed backend state with a bounded timeout after asynchronous commands. Direct X input-focus assignment alone produced intermittent keyboard-probe failures. The harness defaults to inherited host fonts. `FADRIO_UI_FONT_MODE=fixture` is an explicit process-local alternative for fixture diagnosis. A screenshot/control result is not KDE, native Wayland, fractional scaling, packaged installation, or long-running qualification. PNG-only loading means some installed SVG-only icons use the fallback. Unchanged references are loaded on attach/reference change; file watching for already displayed artwork is not implemented in this slice.
diff --git a/docs/development/qualifying-ui-interactions.md b/docs/development/qualifying-ui-interactions.md
index 2068f0b..d337f18 100644
--- a/docs/development/qualifying-ui-interactions.md
+++ b/docs/development/qualifying-ui-interactions.md
@@ -33,12 +33,12 @@ After a normal local build, close other Fadrio windows and run:
./scripts/test-ui-interactions.sh
```
-This optional developer harness requires an X11/XWayland display, DejaVu fonts, X11/XTest libraries, `xwininfo`, `xprop`, `ffmpeg`, PipeWire tools, Python and .NET. It injects mouse/keyboard events into the exact Fadrio window whose process ownership it verifies. Do not interact with the desktop while it runs. It restores the prior pointer/focus and terminates only its owned processes. Its private runtime/data/cache directory is retained with logs and screenshots; the path is printed at exit. It is not part of headless CI or the supported-desktop matrix.
+This optional developer harness requires an X11/XWayland display, DejaVu fonts, X11/XTest libraries, `xwininfo`, `xprop`, `ffmpeg`, PipeWire tools, Python with Pillow and .NET. It injects mouse/keyboard events into the exact Fadrio window whose process ownership it verifies. Do not interact with the desktop while it runs. It restores the prior pointer/focus and terminates only its owned processes. Its private runtime/data/cache directory is retained with logs and screenshots; the path is printed at exit. It is not part of headless CI or the supported-desktop matrix.
-The fixture intentionally sets a process-local minimal Fontconfig configuration. It does not change host fonts or ship a restricted-font workaround in the app.
+The harness now defaults to the inherited host Fontconfig configuration. Set `FADRIO_UI_FONT_MODE=fixture` explicitly for the process-local minimal font fixture. It never changes host fonts. Current evidence is in [qualifying-application-rows.md](qualifying-application-rows.md).
## Open qualification limits
-- `BUG-00004`: normal launch with this host's full Fontconfig configuration stalled before `App.Initialize`, consuming a CPU core. The startup trace showed font/cache enumeration. A restricted process-local DejaVu configuration allowed the window to open; a software-rendering attempt did not resolve normal startup. This isolates a useful investigation path, not a proven upstream cause or a production fix. Default host-font startup is unqualified.
+- Historical `BUG-00004` observation (2026-09-27): normal launch with this host's full Fontconfig configuration stalled before `App.Initialize`, consuming a CPU core. The startup trace showed font/cache enumeration. A restricted process-local DejaVu configuration allowed the window to open; a software-rendering attempt did not resolve normal startup. This isolates a useful investigation path, not a proven upstream cause or a production fix. Default host-font startup is unqualified.
- The checks above are XWayland, not native Wayland, KDE, screen-reader, fractional-scaling, packaged installation or long-running qualification. Those gates remain open.
- Output control, icons, persistence of pinned/inactive rows, tray integration and localization are still later roadmap work. No new release is justified by this slice alone.
diff --git a/docs/development/testing.md b/docs/development/testing.md
index e26faf3..9429de4 100644
--- a/docs/development/testing.md
+++ b/docs/development/testing.md
@@ -15,4 +15,4 @@ The opt-in isolated PipeWire test is enabled with `FADRIO_RUN_PIPEWIRE_INTEGRATI
Browser qualification evidence and its reproducible checklist are documented in [qualifying-browser.md](qualifying-browser.md).
PipeWire restart and command-recovery evidence is documented in [qualifying-reconnect.md](qualifying-reconnect.md).
Native ownership and sanitizer coverage is documented in [native-sanitizers.md](native-sanitizers.md).
-Rendered mixer gesture/reconnect evidence and the opt-in desktop test are documented in [qualifying-ui-interactions.md](qualifying-ui-interactions.md). That check uses process-local fixture fonts; it does not qualify the separately tracked full-host-font startup issue.
+Rendered mixer gesture/reconnect evidence and the opt-in desktop test are documented in [qualifying-ui-interactions.md](qualifying-ui-interactions.md). That check now defaults to host fonts and covers malformed application-icon fallback; see [the current row qualification](qualifying-application-rows.md). The original font-startup cause and the wider desktop matrix remain open.
diff --git a/docs/screenshots/fad-0502-application-icon.png b/docs/screenshots/fad-0502-application-icon.png
new file mode 100644
index 0000000..5f64666
Binary files /dev/null and b/docs/screenshots/fad-0502-application-icon.png differ
diff --git a/docs/screenshots/fad-0502-icon-fallback.png b/docs/screenshots/fad-0502-icon-fallback.png
new file mode 100644
index 0000000..a84e559
Binary files /dev/null and b/docs/screenshots/fad-0502-icon-fallback.png differ
diff --git a/scripts/test-ui-interactions.sh b/scripts/test-ui-interactions.sh
index ea43c2f..59463d8 100755
--- a/scripts/test-ui-interactions.sh
+++ b/scripts/test-ui-interactions.sh
@@ -5,6 +5,7 @@ cd "$repository_root"
for command in xwininfo xprop ffmpeg pipewire pw-cat dotnet rg python3; do
command -v "$command" >/dev/null 2>&1 || { echo "Missing $command" >&2; exit 77; }
done
+python3 -c 'from PIL import Image' >/dev/null 2>&1 || { echo 'Python Pillow is required for rendered slider location.' >&2; exit 77; }
[[ -n "${DISPLAY:-}" ]] || { echo 'An X11/XWayland display is required.' >&2; exit 77; }
if xwininfo -root -tree | rg '"Fadrio"' >/dev/null; then
echo 'Close the existing Fadrio test window before running.' >&2
@@ -27,7 +28,14 @@ export PIPEWIRE_RUNTIME_DIR="$fadrio_fixture_dir"
export PIPEWIRE_REMOTE=pipewire-0
export XDG_DATA_HOME="$fadrio_fixture_dir/share"
export XDG_CACHE_HOME="$fadrio_fixture_dir/cache"
-export FONTCONFIG_FILE="$repository_root/tests/fixtures/fonts/ui-test-fontconfig.conf"
+case "${FADRIO_UI_FONT_MODE:-host}" in
+ host) ;;
+ fixture) export FONTCONFIG_FILE="$repository_root/tests/fixtures/fonts/ui-test-fontconfig.conf" ;;
+ *) echo 'FADRIO_UI_FONT_MODE must be host or fixture.' >&2; exit 2 ;;
+esac
+printf 'font_mode=%s\n' "${FADRIO_UI_FONT_MODE:-host}" >"$fadrio_fixture_dir/startup.txt"
+mkdir -p "$XDG_DATA_HOME/icons"
+cp "$repository_root/assets/branding/raster/fadrio-app-icon-monochrome.png" "$XDG_DATA_HOME/icons/fadrio-fixture.png"
export LD_LIBRARY_PATH="$PWD/build/native"
pipewire -c "$PWD/tests/fixtures/pipewire/fadrio-test.conf" >"$fadrio_fixture_dir/pipewire.log" 2>&1 &
fadrio_fixture_pipewire_pid=$!
@@ -37,26 +45,43 @@ for _ in {1..100}; do
done
[[ -S "$fadrio_fixture_dir/pipewire-0" ]]
pw-cat --playback --target 0 --rate 48000 --channels 2 --format s16 \
- -P '{ application.name = "Fadrio Fixture" application.id = "dev.fglabs.Fadrio.UiFixture" }' \
+ -P '{ application.name = "Fadrio Fixture" application.id = "dev.fglabs.Fadrio.UiFixture" application.icon-name = "fadrio-fixture" }' \
- "$fadrio_fixture_dir/stream.log" 2>&1 &
fadrio_fixture_stream_pid=$!
+fadrio_fixture_started=$SECONDS
env -u WAYLAND_DISPLAY dotnet "$PWD/src/Fadrio.UI/bin/Debug/net10.0/fadrio.dll" >"$fadrio_fixture_dir/ui.log" 2>&1 &
fadrio_fixture_ui_pid=$!
fadrio_fixture_window=""
-for _ in {1..100}; do
+for _ in {1..300}; do
fadrio_fixture_window=$(xwininfo -root -tree | awk '/"Fadrio"/ && !/mutter/ {if (!found) print $1; found=1}')
[[ -n "$fadrio_fixture_window" ]] && break
sleep .1
done
[[ -n "$fadrio_fixture_window" ]]
+printf 'window_ready_seconds=%s\n' "$((SECONDS - fadrio_fixture_started))" >>"$fadrio_fixture_dir/startup.txt"
xprop -id "$fadrio_fixture_window" _NET_WM_PID | rg -F "= $fadrio_fixture_ui_pid" >/dev/null
sleep 1
ffmpeg -hide_banner -loglevel error -f x11grab -window_id "$fadrio_fixture_window" \
-video_size 360x680 -i "$DISPLAY" -frames:v 1 "$fadrio_fixture_dir/before.png"
+export FADRIO_UI_REFERENCE_CAPTURE="$fadrio_fixture_dir/before.png"
python3 "$repository_root/scripts/ui-interaction-probe.py" "$fadrio_fixture_window" "$PWD"
ffmpeg -hide_banner -loglevel error -f x11grab -window_id "$fadrio_fixture_window" \
-video_size 360x680 -i "$DISPLAY" -frames:v 1 "$fadrio_fixture_dir/mixer.png"
kill -0 "$fadrio_fixture_ui_pid"
+kill "$fadrio_fixture_stream_pid"
+wait "$fadrio_fixture_stream_pid" 2>/dev/null || true
+fadrio_fixture_stream_pid=""
+# A plausible PNG header with no pixel data must not break a mixer row.
+head -c 24 "$XDG_DATA_HOME/icons/fadrio-fixture.png" >"$XDG_DATA_HOME/icons/fadrio-broken.png"
+pw-cat --playback --target 0 --rate 48000 --channels 2 --format s16 \
+ -P '{ application.name = "Fadrio Fixture" application.id = "dev.fglabs.Fadrio.UiFixture" application.icon-name = "fadrio-broken" }' \
+ - >"$fadrio_fixture_dir/stream.log" 2>&1 &
+fadrio_fixture_stream_pid=$!
+sleep 2
+python3 "$repository_root/scripts/ui-interaction-probe.py" "$fadrio_fixture_window" "$PWD"
+ffmpeg -hide_banner -loglevel error -f x11grab -window_id "$fadrio_fixture_window" \
+ -video_size 360x680 -i "$DISPLAY" -frames:v 1 "$fadrio_fixture_dir/broken-icon.png"
+kill -0 "$fadrio_fixture_ui_pid"
python3 "$repository_root/scripts/ui-interaction-probe.py" "$fadrio_fixture_window" "$PWD" "$fadrio_fixture_pipewire_pid"
wait "$fadrio_fixture_pipewire_pid" 2>/dev/null || true
fadrio_fixture_pipewire_pid=""
@@ -75,7 +100,7 @@ sleep 3
ffmpeg -hide_banner -loglevel error -f x11grab -window_id "$fadrio_fixture_window" \
-video_size 360x680 -i "$DISPLAY" -frames:v 1 "$fadrio_fixture_dir/empty.png"
pw-cat --playback --target 0 --rate 48000 --channels 2 --format s16 \
- -P '{ application.name = "Fadrio Fixture" application.id = "dev.fglabs.Fadrio.UiFixture" }' \
+ -P '{ application.name = "Fadrio Fixture" application.id = "dev.fglabs.Fadrio.UiFixture" application.icon-name = "fadrio-fixture" }' \
- >"$fadrio_fixture_dir/stream.log" 2>&1 &
fadrio_fixture_stream_pid=$!
sleep 2
diff --git a/scripts/ui-interaction-probe.py b/scripts/ui-interaction-probe.py
index 5512350..7da96ed 100644
--- a/scripts/ui-interaction-probe.py
+++ b/scripts/ui-interaction-probe.py
@@ -5,9 +5,22 @@
import subprocess
import sys
import time
+from PIL import Image
window = int(sys.argv[1], 16)
root_path = sys.argv[2]
+with Image.open(os.environ['FADRIO_UI_REFERENCE_CAPTURE']).convert('RGB') as capture:
+ # Locate the long blue slider track in the actual rendering. Font metrics
+ # can move the row; fixed Y coordinates gave false results with host fonts.
+ candidates = []
+ for py in range(capture.height):
+ count = sum(1 for px in range(30, capture.width - 30)
+ if (lambda rgb: rgb[2] > rgb[0] + 60 and rgb[1] > rgb[0] + 30)(capture.getpixel((px, py))))
+ if count > 150:
+ candidates.append(py)
+ assert candidates, 'No rendered slider track found'
+ slider_y = candidates[len(candidates) // 2]
+mute_y = slider_y + 48
x = c.CDLL('libX11.so.6')
t = c.CDLL('libXtst.so.6')
x.XOpenDisplay.restype = c.c_void_p
@@ -24,6 +37,18 @@
x.XKeysymToKeycode.argtypes = [c.c_void_p, c.c_ulong]
x.XKeysymToKeycode.restype = c.c_uint
x.XQueryPointer.argtypes = [c.c_void_p, c.c_ulong, c.POINTER(c.c_ulong), c.POINTER(c.c_ulong), c.POINTER(c.c_int), c.POINTER(c.c_int), c.POINTER(c.c_int), c.POINTER(c.c_int), c.POINTER(c.c_uint)]
+x.XInternAtom.argtypes = [c.c_void_p, c.c_char_p, c.c_int]
+x.XInternAtom.restype = c.c_ulong
+
+class ClientMessage(c.Structure):
+ _fields_ = [('type', c.c_int), ('serial', c.c_ulong), ('send_event', c.c_int),
+ ('display', c.c_void_p), ('window', c.c_ulong),
+ ('message_type', c.c_ulong), ('format', c.c_int), ('data', c.c_long * 5)]
+
+class Event(c.Union):
+ _fields_ = [('message', ClientMessage), ('padding', c.c_long * 24)]
+
+x.XSendEvent.argtypes = [c.c_void_p, c.c_ulong, c.c_int, c.c_long, c.POINTER(Event)]
t.XTestFakeMotionEvent.argtypes = [c.c_void_p, c.c_int, c.c_int, c.c_int, c.c_ulong]
t.XTestFakeButtonEvent.argtypes = [c.c_void_p, c.c_uint, c.c_int, c.c_ulong]
t.XTestFakeKeyEvent.argtypes = [c.c_void_p, c.c_uint, c.c_int, c.c_ulong]
@@ -55,49 +80,76 @@ def key(name):
x.XFlush(d)
time.sleep(.08)
+def activate():
+ # Ask the window manager to activate the owned window. Merely assigning
+ # X input focus can leave GNOME's active-window state on the prior app.
+ event = Event()
+ event.message.type = 33 # ClientMessage
+ event.message.display = d
+ event.message.window = window
+ event.message.message_type = x.XInternAtom(d, b'_NET_ACTIVE_WINDOW', 0)
+ event.message.format = 32
+ event.message.data[0] = 2 # pager/test activation request
+ x.XSendEvent(d, root, 0, (1 << 20) | (1 << 19), c.byref(event))
+ x.XFlush(d)
+ time.sleep(.3)
+ focus = c.c_ulong()
+ focus_revert = c.c_int()
+ x.XGetInputFocus(d, c.byref(focus), c.byref(focus_revert))
+ assert focus.value == window, f'Owned window did not receive keyboard focus: {focus.value:#x}'
+
def state():
output = subprocess.check_output(['dotnet', root_path + '/src/Fadrio.Cli/bin/Debug/net10.0/fadrioctl.dll', 'apps'], text=True)
assert 'Application: Fadrio Fixture' in output, output
return int(re.search(r'Volume: (\d+)%', output)[1]), 'Muted: true' in output
+def wait_state(predicate):
+ # UI commands run on a worker and PipeWire reports them asynchronously.
+ deadline = time.monotonic() + 10
+ observed = state()
+ while not predicate(observed) and time.monotonic() < deadline:
+ time.sleep(.1)
+ observed = state()
+ assert predicate(observed), observed
+ return observed
+
try:
- x.XRaiseWindow(d, window)
- x.XSetInputFocus(d, window, 2, 0)
- x.XFlush(d)
+ activate()
time.sleep(.5)
x.XTranslateCoordinates(d, window, root, 0, 0, c.byref(origin_x), c.byref(origin_y), c.byref(child))
if len(sys.argv) > 3:
# The shell passes only its own isolated daemon PID.
- move(73, 281)
+ move(73, slider_y)
button(1)
- move(100, 281)
+ move(100, slider_y)
os.kill(int(sys.argv[3]), signal.SIGTERM)
time.sleep(1)
- move(146, 281)
+ move(146, slider_y)
button(0)
print('Disconnected the isolated daemon during an active drag', flush=True)
sys.exit(0)
- assert state()[0] == 100
- move(314, 281)
+ wait_state(lambda observed: observed[0] == 100)
+ move(314, slider_y)
button(1)
- for px in [290, 265, 240, 215, 190, 165, 146]: move(px, 281)
+ for px in [290, 265, 240, 215, 190, 165, 146]: move(px, slider_y)
button(0)
- volume, muted = state()
- assert 35 <= volume <= 45, (volume, muted)
+ volume, muted = wait_state(lambda observed: 35 <= observed[0] <= 45)
print('Rendered slider drag reached', volume, 'percent', flush=True)
# Reassert focus after the separate CLI probe; the desktop may redirect it.
- x.XSetInputFocus(d, window, 2, 0)
- x.XFlush(d)
- time.sleep(.15)
+ activate()
+ # A recreated row has a new control; focus that slider explicitly before
+ # testing its keys, rather than relying on desktop activation history.
+ move(146, slider_y)
+ button(1)
+ button(0)
key('Home')
for _ in range(10): key('Right')
- volume, muted = state()
- assert volume == 10, (volume, muted)
+ volume, muted = wait_state(lambda observed: observed[0] == 10)
print('Keyboard Home + ten Right keys reached 10 percent', flush=True)
- move(62, 327)
+ move(62, mute_y)
button(1)
button(0)
- assert state()[1]
+ wait_state(lambda observed: observed[1])
print('Rendered mute button muted the isolated stream', flush=True)
finally:
t.XTestFakeButtonEvent(d, 1, 0, 0)
diff --git a/src/Fadrio.UI/Controls/ApplicationIcon.cs b/src/Fadrio.UI/Controls/ApplicationIcon.cs
new file mode 100644
index 0000000..7ed3098
--- /dev/null
+++ b/src/Fadrio.UI/Controls/ApplicationIcon.cs
@@ -0,0 +1,133 @@
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Media;
+using Avalonia.Media.Imaging;
+using Fadrio.Core;
+using Fadrio.Infrastructure;
+
+namespace Fadrio.UI.Controls;
+
+/// Loads only validated local icons, without blocking the dispatcher.
+public sealed class ApplicationIcon : UserControl
+{
+ public static readonly StyledProperty ReferenceProperty =
+ AvaloniaProperty.Register(nameof(Reference));
+ public static readonly StyledProperty FallbackProperty =
+ AvaloniaProperty.Register(nameof(Fallback), "?");
+
+ private static readonly LocalIconResolver Resolver = new();
+ // Bound simultaneous icon-tree searches and decodes across all rows.
+ private static readonly SemaphoreSlim LoadGate = new(2);
+ private readonly Image _image = new() { Stretch = Stretch.Uniform };
+ private readonly TextBlock _fallback = new()
+ {
+ FontSize = 16,
+ HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Center,
+ VerticalAlignment = Avalonia.Layout.VerticalAlignment.Center
+ };
+ private CancellationTokenSource? _request;
+ private Bitmap? _bitmap;
+ private bool _attached;
+
+ public ApplicationIcon()
+ {
+ IsHitTestVisible = false;
+ Content = new Grid { Children = { _fallback, _image } };
+ }
+
+ public IconReference? Reference
+ {
+ get => GetValue(ReferenceProperty);
+ set => SetValue(ReferenceProperty, value);
+ }
+
+ public string Fallback
+ {
+ get => GetValue(FallbackProperty);
+ set => SetValue(FallbackProperty, value);
+ }
+
+ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
+ {
+ base.OnPropertyChanged(change);
+ if (change.Property == FallbackProperty) _fallback.Text = Fallback;
+ if (change.Property == ReferenceProperty && _attached) Reload();
+ }
+
+ protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
+ {
+ base.OnAttachedToVisualTree(e);
+ _attached = true;
+ _fallback.Text = Fallback;
+ Reload();
+ }
+
+ protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
+ {
+ _attached = false;
+ Clear();
+ base.OnDetachedFromVisualTree(e);
+ }
+
+ private void Clear()
+ {
+ _request?.Cancel();
+ _request = null;
+ _image.Source = null;
+ _bitmap?.Dispose();
+ _bitmap = null;
+ _fallback.IsVisible = true;
+ }
+
+ private async void Reload()
+ {
+ Clear();
+ if (Reference is not { } reference) return;
+ using var request = new CancellationTokenSource();
+ _request = request;
+ Bitmap? loaded = null;
+ try
+ {
+ loaded = await Task.Run(async () =>
+ {
+ await LoadGate.WaitAsync(request.Token).ConfigureAwait(false);
+ try
+ {
+ var resolved = await Resolver.ResolveAsync(reference, request.Token).ConfigureAwait(false);
+ if (resolved is null) return null;
+ request.Token.ThrowIfCancellationRequested();
+ using FileStream stream = File.OpenRead(resolved.Path);
+ // Bound both dimensions, including extremely tall or wide PNGs.
+ try
+ {
+ return resolved.Width >= resolved.Height
+ ? Bitmap.DecodeToWidth(stream, 64)
+ : Bitmap.DecodeToHeight(stream, 64);
+ }
+ catch (NullReferenceException)
+ {
+ // Avalonia.Skia 12.1.2 dereferences a null codec for a
+ // header-only PNG. Contain that decoder failure here.
+ return null;
+ }
+ }
+ finally { LoadGate.Release(); }
+ }, request.Token);
+ if (request.IsCancellationRequested || !_attached || !ReferenceEquals(_request, request)) return;
+ _bitmap = loaded;
+ loaded = null;
+ _image.Source = _bitmap;
+ _fallback.IsVisible = _bitmap is null;
+ }
+ catch (Exception exception) when (exception is IOException or UnauthorizedAccessException
+ or ArgumentException or InvalidOperationException or NotSupportedException or OperationCanceledException)
+ {
+ // Missing, changing, or undecodable artwork is a normal fallback condition.
+ }
+ finally
+ {
+ loaded?.Dispose();
+ if (ReferenceEquals(_request, request)) _request = null;
+ }
+ }
+}
diff --git a/src/Fadrio.UI/MainWindow.axaml b/src/Fadrio.UI/MainWindow.axaml
index b4513e3..0fce288 100644
--- a/src/Fadrio.UI/MainWindow.axaml
+++ b/src/Fadrio.UI/MainWindow.axaml
@@ -26,16 +26,26 @@
-
-
-
+
+
+
+
-
+
+
+
+
diff --git a/src/Fadrio.UI/ViewModels/MainWindowViewModel.cs b/src/Fadrio.UI/ViewModels/MainWindowViewModel.cs
index 43c116d..5934a4d 100644
--- a/src/Fadrio.UI/ViewModels/MainWindowViewModel.cs
+++ b/src/Fadrio.UI/ViewModels/MainWindowViewModel.cs
@@ -122,6 +122,8 @@ public sealed class ApplicationRowViewModel : INotifyPropertyChanged
private readonly Func _setVolume;
private readonly Func _setMute;
private string _displayName = string.Empty;
+ private IconReference? _icon;
+ private bool _isAudible;
private double _volume;
private bool _isMuted;
private bool _isMixedVolume;
@@ -162,6 +164,7 @@ private set
{
OnPropertyChanged(nameof(VolumeControlLabel));
OnPropertyChanged(nameof(MuteControlLabel));
+ OnPropertyChanged(nameof(IconFallback));
}
}
}
@@ -186,6 +189,18 @@ public double Volume
}
}
public string VolumeLabel => IsMixedVolume ? $"{Volume:0}% mixed" : $"{Volume:0}%";
+ public IconReference? Icon { get => _icon; private set => SetField(ref _icon, value); }
+ public string IconFallback => string.IsNullOrWhiteSpace(DisplayName)
+ ? "?" : System.Globalization.StringInfo.GetNextTextElement(DisplayName.Trim()).ToUpperInvariant();
+ public bool IsAudible
+ {
+ get => _isAudible;
+ private set { if (SetField(ref _isAudible, value)) OnPropertyChanged(nameof(ActivityLabel)); }
+ }
+ public string ActivityLabel => IsMuted ? "Muted" : IsAudible ? "Playing" : "Idle";
+ public string VolumeDescription => IsMixedVolume
+ ? "Streams have different levels. Moving this slider sets every stream to the same level."
+ : "Controls every playback stream belonging to this application.";
public bool IsMuted
{
get => _isMuted;
@@ -195,10 +210,22 @@ private set
{
OnPropertyChanged(nameof(MuteLabel));
OnPropertyChanged(nameof(MuteControlLabel));
+ OnPropertyChanged(nameof(ActivityLabel));
+ }
+ }
+ }
+ public bool IsMixedVolume
+ {
+ get => _isMixedVolume;
+ private set
+ {
+ if (SetField(ref _isMixedVolume, value))
+ {
+ OnPropertyChanged(nameof(VolumeLabel));
+ OnPropertyChanged(nameof(VolumeDescription));
}
}
}
- public bool IsMixedVolume { get => _isMixedVolume; private set { if (SetField(ref _isMixedVolume, value)) OnPropertyChanged(nameof(VolumeLabel)); } }
public bool CanControl
{
get => _canControl;
@@ -233,6 +260,8 @@ internal void Update(RuntimeApplication application, bool canControl)
try
{
DisplayName = application.Identity.DisplayName;
+ Icon = application.Identity.Icon;
+ IsAudible = application.IsAudible;
if (!IsInteracting && !_sendingVolume && !_preserveVolumeOnNextUpdate)
{
Volume = application.EffectiveVolume * 100;
diff --git a/tests/Fadrio.UI.Tests/MainWindowViewModelTests.cs b/tests/Fadrio.UI.Tests/MainWindowViewModelTests.cs
index 49db0fb..daf42f6 100644
--- a/tests/Fadrio.UI.Tests/MainWindowViewModelTests.cs
+++ b/tests/Fadrio.UI.Tests/MainWindowViewModelTests.cs
@@ -295,6 +295,74 @@ public void MixedSessionsShowAnHonestCombinedValue()
private static MixerSnapshot Snapshot(params RuntimeApplication[] apps) => new(apps, 1);
+ [Fact]
+ public void IconOverridesRefreshTheExistingRowAndMissingIconsHaveTextFallback()
+ {
+ var viewModel = new MainWindowViewModel();
+ RuntimeApplication app = App("xdg:firefox", "Firefox", 0.5f);
+ viewModel.ApplySnapshot(Snapshot(new RuntimeApplication(
+ app.Identity with { Icon = new("firefox") }, app.Sessions)));
+ ApplicationRowViewModel row = Assert.Single(viewModel.Applications);
+ Assert.Equal(new IconReference("firefox"), row.Icon);
+ Assert.Equal("F", row.IconFallback);
+ var notifications = new List();
+ row.PropertyChanged += (_, args) => notifications.Add(args.PropertyName);
+
+ viewModel.ApplySnapshot(Snapshot(App("xdg:firefox", " Browser", 0.5f)));
+
+ Assert.Same(row, Assert.Single(viewModel.Applications));
+ Assert.Null(row.Icon);
+ Assert.Equal("B", row.IconFallback);
+ Assert.Contains(nameof(row.Icon), notifications);
+ Assert.Contains(nameof(row.IconFallback), notifications);
+ }
+
+ [Theory]
+ [InlineData("", "?")]
+ [InlineData(" ", "?")]
+ [InlineData("🎵 Music", "🎵")]
+ [InlineData("e\u0301cho", "E\u0301")]
+ public void FallbackPreservesUnicodeTextElements(string name, string expected)
+ {
+ var viewModel = new MainWindowViewModel();
+ viewModel.ApplySnapshot(Snapshot(App("xdg:example", name, 0.5f)));
+ Assert.Equal(expected, Assert.Single(viewModel.Applications).IconFallback);
+ }
+
+ [Fact]
+ public void ActivityTracksBackendStateAndMuteWithoutClaimingMeasuredAudioLevels()
+ {
+ var viewModel = new MainWindowViewModel();
+ viewModel.SetBackendAvailable(true);
+ RuntimeApplication app = App("xdg:music", "Music", 0.5f);
+ viewModel.ApplySnapshot(Snapshot(app));
+ ApplicationRowViewModel row = Assert.Single(viewModel.Applications);
+ Assert.Equal("Idle", row.ActivityLabel);
+
+ viewModel.ApplySnapshot(Snapshot(new RuntimeApplication(app.Identity,
+ app.Sessions.Select(session => session with { Active = true }))));
+ Assert.Equal("Playing", row.ActivityLabel);
+ row.ToggleMuteCommand.Execute(null);
+ Assert.Equal("Muted", row.ActivityLabel);
+
+ viewModel.ApplySnapshot(Snapshot(new RuntimeApplication(app.Identity,
+ app.Sessions.Select(session => session with { Active = true, Volume = 0 }))));
+ Assert.Equal("Idle", row.ActivityLabel);
+ }
+
+ [Fact]
+ public void MixedVolumeHelpExplainsAbsoluteFanOutAndClearsAfterUserAdjustment()
+ {
+ var viewModel = new MainWindowViewModel();
+ viewModel.SetBackendAvailable(true);
+ viewModel.ApplySnapshot(Snapshot(App("xdg:browser", "Browser", 0.2f, 0.8f)));
+ ApplicationRowViewModel row = Assert.Single(viewModel.Applications);
+ Assert.Contains("different levels", row.VolumeDescription, StringComparison.Ordinal);
+ row.Volume = 40;
+ Assert.Equal("40%", row.VolumeLabel);
+ Assert.DoesNotContain("different levels", row.VolumeDescription, StringComparison.Ordinal);
+ }
+
private static RuntimeApplication App(string id, string name, params float[] volumes) => new(
new ApplicationIdentity { Id = new(id), DisplayName = name },
volumes.Select((volume, index) => new AudioSession