diff --git a/CHANGELOG.md b/CHANGELOG.md index 98603e6..d7a85e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ All notable changes will be documented here. The format follows [Keep a Changelo ### Changed +- `FAD-0502` Application controls now use a horizontally scrollable console with vertical percentage faders, aligned mute controls, logical application counts, and session-scoped System/Light/Dark selection (ADR-0003). + - `FAD-0205` XDG desktop-entry snapshots now refresh after debounced filesystem changes, advance a monotonic identity revision, and re-resolve active sessions once through the serialized mixer coordinator. - `FAD-0206` Ordinary `fadrioctl apps` output no longer exposes process IDs; raw process and node details live in the explicit advanced inspector. - `REL-00003` Visible XDG launchers now take precedence over hidden helpers when both have strong executable evidence; common `-bin` runtime names can match their launcher executable. diff --git a/README.md b/README.md index ddd70ff..abb5436 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Fadrio resolves PipeWire playback nodes into stable logical applications and gro - Stable fallback identities that never use PID. - Multi-session application grouping and application-wide volume/mute commands. - Managed reconnect supervision with generation isolation. -- Diagnostic CLI, SQLite-backed identity overrides, and the first live Avalonia application rows with volume and mute controls. +- Diagnostic CLI, SQLite-backed identity overrides, and a live Avalonia application console with vertical volume faders, mute controls, and session-scoped themes. ## Architecture @@ -91,7 +91,11 @@ The override appears in subsequent `apps` output while the canonical ID remains 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. +The current console uses vertical percentage faders and a horizontally scrollable bank of logical applications. Choose System, Light or Dark for the current session. + +![Current application console](docs/screenshots/fad-0502-console-dark.png) + +This actual 940 × 680 capture uses four controlled silent applications and five streams on a private PipeWire daemon, with normal host fonts. [Light theme](docs/screenshots/fad-0502-console-light.png), [narrow layout](docs/screenshots/fad-0502-console-narrow.png), and [qualification evidence](docs/development/qualifying-console-ui.md) are available. Reproduce with `./scripts/capture-console.sh` after building. [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 7d2cc50..dd7a994 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -182,9 +182,9 @@ 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. + - Scope: Application console with vertical percentage faders, session themes, logical counts, validated asynchronous local icons, readable fallback/activity states, and mixed-volume help. 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. + - Evidence: `docs/development/qualifying-application-rows.md` and `docs/development/qualifying-console-ui.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/TECH_SPEC.md b/TECH_SPEC.md index 6b91676..e411f18 100644 --- a/TECH_SPEC.md +++ b/TECH_SPEC.md @@ -1687,6 +1687,8 @@ Do not open to a dashboard. # 34. Main Mixer UI +> Active layout update (2026-10-07): the user selected a Voicemeeter-inspired application console. [ADR-0003](docs/decisions/ADR-0003-application-console-layout.md) supersedes the initial narrow-window geometry and horizontal row sliders below: default 940 x 680, horizontally arranged logical-application strips, vertical 0–100% faders, and scrolling at narrow widths. Application identity, command semantics and product scope are unchanged. The initial layout remains below as design history. + ## 34.1 Window form Default approximate size at 100% scale: diff --git a/docs/decisions/ADR-0003-application-console-layout.md b/docs/decisions/ADR-0003-application-console-layout.md new file mode 100644 index 0000000..d93c953 --- /dev/null +++ b/docs/decisions/ADR-0003-application-console-layout.md @@ -0,0 +1,21 @@ +# ADR-0003: Application console with vertical faders + +- Status: Accepted +- Date: 2026-10-07 +- Owner: `FAD-0502` + +## Context + +The user requested a Voicemeeter-like visual direction for an app they intend to use daily. Sections 34 and 40 of TECH_SPEC.md prescribe a narrow vertical utility and discourage imitation studio controls. The request authorizes a presentation change, while the application-centric model, dependency direction, volume semantics and product scope remain authoritative. + +The first-party Voicemeeter Banana screenshot (https://vb-audio.com/Voicemeeter/banana.htm) was reviewed for channel grouping, vertical faders, aligned mute controls and readable numeric levels. No artwork or source from that product is bundled. + +## Decision + +Default to a 940 x 680 application console, with fixed-width application strips arranged horizontally. Small windows and long application lists scroll instead of compressing controls. Each logical application retains one 0–100% fader, identity/icon, explicit playback/mute state and shared audio command path. The same row objects, interaction freeze, reconnect behavior and mixed-volume semantics remain in use. Provide System/Light/Dark theme selection for the current session. + +This deliberately changes the default geometry and row layout in TECH_SPEC.md sections 34/40. It does not introduce audio buses, DSP, routing, fake signal meters, dB gain labels, physical-input strips or unsupported output controls. The existing output-control placeholder is secondary footer text. Playback state continues to describe stream activity rather than measured signal amplitude. + +## Consequences + +The user gets a directly inspectable fader bank; keyboard tests and screenshots must qualify the vertical orientation, theme contrast and overflow behavior. The native ABI, Core, resolver and persistent schema are unchanged. Theme persistence, a compact layout mode, signal metering and the full supported-desktop/scaling matrix remain future work. diff --git a/docs/design/ui-system.md b/docs/design/ui-system.md index 6dfca59..4fe2783 100644 --- a/docs/design/ui-system.md +++ b/docs/design/ui-system.md @@ -1,7 +1,7 @@ # UI system -The default mixer is a narrow vertical utility, approximately 360 pixels wide with a 320-pixel minimum. It prioritizes output and logical applications, using the spacing scale 4, 8, 12, 16, 24, and 32. +The current mixer is a 940 x 680 application console, with a 420-pixel minimum width. Fixed-width logical-application strips arrange horizontally and scroll at small widths or with many applications. Each strip uses a vertical 0–100% fader, name/icon, textual activity state, large numeric level and an aligned mute action. The spacing scale is 4, 8, 12, 16, 24, and 32. See [ADR-0003](../decisions/ADR-0003-application-console-layout.md) for the user-requested change from the initial narrow utility. -System, light, and dark themes are required. The visual tone is calm, compact, readable, and tactile. Avoid graph-editor terminology, neon gamer styling, excessive cards, and faux studio-console decoration. +System, light, and dark themes can be selected in the header for the current session. The visual tone is calm, readable and tactile: slate surfaces, restrained green track fill, and visible fader handles. Voicemeeter's aligned channel layout is the visual reference; all controls must correspond to implemented application behavior. There are no decorative signal meters, fictitious bus buttons or dB gain values. Application rows eventually contain icon, name, volume, slider, mute, and contextual actions. PID and PipeWire node identifiers belong only in diagnostics. diff --git a/docs/dev-diaries/003-a-console-for-applications.md b/docs/dev-diaries/003-a-console-for-applications.md new file mode 100644 index 0000000..692570f --- /dev/null +++ b/docs/dev-diaries/003-a-console-for-applications.md @@ -0,0 +1,41 @@ +# Fadrio Dev Diary #3 — A console for applications + +I want Fadrio to be the Linux mixer I actually reach for while working and playing. The first working interface had one horizontal slider per application. It proved the plumbing, but I wanted something closer to the channel bank of a mixing console: several applications visible together, with levels you can compare at a glance. + +The new window now has **vertical application faders**, a percentage scale, aligned mute buttons, and selectable System, Light and Dark themes. The screenshot is the actual Avalonia application connected to a private PipeWire daemon. Browser, Chat, Game and Music are controlled silent fixtures, not invented UI or a list of my private applications. + +## What I borrowed from Voicemeeter + +I looked at [Voicemeeter Banana's official interface](https://vb-audio.com/Voicemeeter/banana.htm). Its useful idea here is the repeated channel strip: a name at the top, a long vertical fader, and controls that sit at the same height across the bank. + +Fadrio applies that layout to **logical applications**. Each strip contains its icon or initial, name, playback state, percentage and mute control. The fader scale runs from 0 to 100 percent; it does not pretend to be a calibrated decibel meter. Playing, Idle and Muted remain readable text. The new muted button also has a distinct appearance in both themes. + +This is still Fadrio's own interface and artwork. Voicemeeter's buses, routing matrix and effects are outside this application's scope. The useful goal is quick application control, not fitting a recording studio into a volume popup. + +## Four strips, five streams + +The Browser fixture owns two streams, initially at 20% and 80%. Fadrio groups them into one strip showing **50% mixed**. Chat is at 60%, Game at 78%, and Music is muted with its level retained at 35%. + +That example makes the application's central rule visible: two browser streams do not become two browser controls. Moving a mixed fader sets every stream owned by that application to the chosen level. The tooltip and accessibility help explain this; a single number should not conceal the operation behind it. + +The application count also counts logical applications. During an active gesture, structural changes wait until the gesture ends, preserving the controls under your pointer. A disappearing target disables immediately, and commands still use the native PipeWire bridge. + +## A wider window that can shrink + +The development window opens at 940 × 680. At 420 pixels wide, the same strips remain available through horizontal scrolling rather than squeezing each fader into a sliver. The Light theme uses a contrasting dark thumb; Dark uses a pale thumb with a mint track. Theme selection currently lasts for the session only. + +The local icon work from the previous development slice stays intact: validated local PNGs load asynchronously, with a readable initial when an icon is missing or cannot be decoded. The malformed PNG regression remains in the desktop check. An icon should not get promoted to application supervisor. + +## What I actually checked + +The local suite passes **111 managed tests**, including 25 UI cases, plus two native tests and the isolated PipeWire integration scenario. Formatting, roadmap checks and six Python roadmap tests pass too. + +The real rendered desktop check moves the vertical fader to 37%, reaches 10% with Home followed by ten Up keys, and mutes the stream. It repeats those controls with a damaged icon, disconnects the private PipeWire daemon during a drag, restarts it, and verifies the recovered controls. The four-application capture separately checks the mixed level, muted state, both themes and narrow-window layout. + +These are GNOME Wayland desktop checks through XWayland using normal host fonts and isolated silent streams. They do not qualify native Wayland, KDE, fractional scaling, screen readers or an installed package. The earlier font-startup stall's root cause also remains open; it has not reproduced in these checks. + +## What comes next + +This advances the application-control part of FAD-0502. Output-device controls, remembered application levels, pinned inactive applications and tray/single-instance behavior still need work. There is no new supported binary release: Fadrio remains a source-only public alpha. + +For daily use, which would help you most next: remembered levels, pinned controls for currently silent applications, or quick access from the tray? 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 deleted file mode 100644 index 76e5edb..0000000 --- a/docs/dev-diaries/003-icons-that-cannot-crash-the-mixer.md +++ /dev/null @@ -1,48 +0,0 @@ -> 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-console-ui.md b/docs/development/qualifying-console-ui.md new file mode 100644 index 0000000..2275217 --- /dev/null +++ b/docs/development/qualifying-console-ui.md @@ -0,0 +1,29 @@ +# FAD-0502 application console qualification + +Recorded 2026-10-07 on GNOME Wayland through XWayland with normal host fonts. The accepted geometry change is in ADR-0003. This advances application controls; output controls and REL-00006 remain open. + +## Observed behavior + +The 940 × 680 console has a horizontally scrollable bank of 184-pixel logical application strips, vertical 0–100% faders, aligned mute buttons, icon/initial fallback, textual activity and mixed-volume help. At 420 × 680 the bank scrolls without compressing the controls. System/Light/Dark selection changes presentation only and lasts for this session. The light-theme thumb and active mute text retain contrast against their surfaces. Formal accessibility conformance remains unqualified. + +`./scripts/capture-console.sh` creates a private PipeWire daemon, isolated XDG directories and five real silent playback streams. Its fixture-only native ABI client seeds levels with acknowledged commands; it does not change the production backend. The Browser fixture's 20% and 80% streams group into one 50% mixed strip. Chat is 60%, Game 78%, and Music 35% muted. CLI snapshots confirm four logical applications. The icon is project-owned; missing fixture icons use initials. Nothing modifies ordinary host audio. + +Actual owned-window captures: + +- [Dark, 940 × 680](../screenshots/fad-0502-console-dark.png) +- [Light, 940 × 680](../screenshots/fad-0502-console-light.png) +- [Light, 420 × 680](../screenshots/fad-0502-console-narrow.png) + +## Validation + +- `FADRIO_RUN_PIPEWIRE_INTEGRATION=1 ./scripts/test.sh`: 111 managed tests (25 UI), two native tests and isolated PipeWire integration passed. +- New meaningful UI cases check validated theme changes without audio commands and logical counts across multi-session updates, gesture freeze, release and disconnect. +- `./scripts/test-ui-interactions.sh`: actual vertical drag to 37%, Home + ten Up keys to 10%, mute, repeated with a header-only malformed PNG, daemon disconnect during drag, restart and recovered commands. Final run passed all three control scenarios. +- `dotnet format Fadrio.slnx --verify-no-changes --no-restore`, six Python roadmap tests, roadmap audit and `git diff --check` passed. +- Final themed render/build and the four-application capture passed after palette/scale/mute refinements. + +The input harness finds the first vertical fader from the longest contiguous rendered track, activates the owned window through EWMH, verifies keyboard focus and polls backend state after asynchronous commands. The percentage scale is not a signal/dB meter. Core and the production native bridge are unchanged. + +## Remaining gates + +No claim is made for native Wayland, KDE, fractional scaling, screen readers, installed packaging or a long-running session. Theme persistence, output controls, durable mixer policies, tray and pinned inactive applications are still pending. The original BUG-00004 startup stall did not reproduce, and its cause is unknown; no fonts or host caches were removed. The October 6 portrait capture and qualification remain historical evidence for the earlier icon slice. diff --git a/docs/screenshots/fad-0502-console-dark.png b/docs/screenshots/fad-0502-console-dark.png new file mode 100644 index 0000000..df34220 Binary files /dev/null and b/docs/screenshots/fad-0502-console-dark.png differ diff --git a/docs/screenshots/fad-0502-console-light.png b/docs/screenshots/fad-0502-console-light.png new file mode 100644 index 0000000..7676ee6 Binary files /dev/null and b/docs/screenshots/fad-0502-console-light.png differ diff --git a/docs/screenshots/fad-0502-console-narrow.png b/docs/screenshots/fad-0502-console-narrow.png new file mode 100644 index 0000000..22de13b Binary files /dev/null and b/docs/screenshots/fad-0502-console-narrow.png differ diff --git a/scripts/capture-console.sh b/scripts/capture-console.sh new file mode 100755 index 0000000..7a381db --- /dev/null +++ b/scripts/capture-console.sh @@ -0,0 +1,117 @@ +#!/usr/bin/env bash +set -euo pipefail +repository_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +cd "$repository_root" +for command in xwininfo xprop ffmpeg pipewire pw-cat pw-dump dotnet rg python3; do + command -v "$command" >/dev/null || { echo "Missing $command" >&2; exit 77; } +done +python3 -c 'from PIL import Image' >/dev/null +[[ -n "${DISPLAY:-}" ]] || exit 77 +if xwininfo -root -tree | rg '"Fadrio"' >/dev/null; then + echo 'Close the existing Fadrio window before capturing.' >&2 + exit 1 +fi +fadrio_capture_dir=$(mktemp -d -t fadrio-console-XXXXXX) +fadrio_capture_pids=() +cleanup() { + for fadrio_capture_pid in "${fadrio_capture_pids[@]}"; do kill "$fadrio_capture_pid" 2>/dev/null || true; done + wait 2>/dev/null || true + printf 'capture_dir=%s\n' "$fadrio_capture_dir" +} +trap cleanup EXIT INT TERM +export XDG_RUNTIME_DIR="$fadrio_capture_dir" +export PIPEWIRE_RUNTIME_DIR="$fadrio_capture_dir" +export PIPEWIRE_REMOTE=pipewire-0 +export XDG_DATA_HOME="$fadrio_capture_dir/share" +export XDG_CACHE_HOME="$fadrio_capture_dir/cache" +export LD_LIBRARY_PATH="$PWD/build/native" +export FADRIO_UI_CAPTURE_DIR="$fadrio_capture_dir" +mkdir -p "$XDG_DATA_HOME/applications" "$XDG_DATA_HOME/icons" +cp assets/branding/raster/fadrio-app-icon-monochrome.png "$XDG_DATA_HOME/icons/fadrio-fixture.png" +for fadrio_capture_name in Browser Chat Game Music; do + cat >"$XDG_DATA_HOME/applications/dev.fglabs.Fadrio.Capture$fadrio_capture_name.desktop" <"$fadrio_capture_dir/pipewire.log" 2>&1 & +fadrio_capture_pids+=("$!") +for _ in {1..100}; do [[ -S "$fadrio_capture_dir/pipewire-0" ]] && break; sleep .05; done +[[ -S "$fadrio_capture_dir/pipewire-0" ]] +start_stream() { + pw-cat --playback --target 0 --rate 48000 --channels 2 --format s16 --volume "$2" \ + -P "{ application.name = \"$1 (fixture)\" application.id = \"dev.fglabs.Fadrio.Capture$1\" application.icon-name = \"$3\" }" \ + - >"$fadrio_capture_dir/streams.log" 2>&1 & + fadrio_capture_pids+=("$!") +} +start_stream Browser .2 fadrio-fixture +start_stream Browser .8 fadrio-fixture +start_stream Chat .6 missing-fixture-icon +start_stream Game .78 missing-fixture-icon +start_stream Music .35 missing-fixture-icon +env -u WAYLAND_DISPLAY dotnet "$PWD/src/Fadrio.UI/bin/Debug/net10.0/fadrio.dll" >"$fadrio_capture_dir/ui.log" 2>&1 & +fadrio_capture_ui_pid=$! +fadrio_capture_pids+=("$fadrio_capture_ui_pid") +fadrio_capture_window="" +for _ in {1..300}; do + fadrio_capture_window=$(xwininfo -root -tree | awk '/"Fadrio"/ && !/mutter/ {if (!found) print $1; found=1}') + [[ -n "$fadrio_capture_window" ]] && break + sleep .1 +done +[[ -n "$fadrio_capture_window" ]] +xprop -id "$fadrio_capture_window" _NET_WM_PID | rg -F "= $fadrio_capture_ui_pid" >/dev/null +sleep 2 +# Seed actual observed levels through the same native bridge as the app. +# Raw node IDs remain inside this private diagnostic capture fixture. +python3 - "$PWD/build/native/libfadrio_native.so" <<'PYSEED' +import ctypes as c +import json +import subprocess +import sys +import threading +import time + +class EventPrefix(c.Structure): + _fields_ = [('size', c.c_uint32), ('type', c.c_int), ('generation', c.c_uint64)] +ready = threading.Event() +@c.CFUNCTYPE(None, c.c_void_p, c.c_void_p) +def callback(pointer, _): + event_type = c.cast(pointer, c.POINTER(EventPrefix)).contents.type + if event_type == 1: ready.set() +lib = c.CDLL(sys.argv[1]) +lib.vm_context_create.argtypes = [type(callback), c.c_void_p] +lib.vm_context_create.restype = c.c_void_p +lib.vm_start.argtypes = [c.c_void_p] +lib.vm_set_stream_volume.argtypes = [c.c_void_p, c.c_uint32, c.c_float] +lib.vm_context_destroy.argtypes = [c.c_void_p] +context = lib.vm_context_create(callback, None) +assert context +try: + assert lib.vm_start(context) == 0 + assert ready.wait(5), 'Native fixture did not connect' + nodes = json.loads(subprocess.check_output(['pw-dump'], text=True)) + levels = {'Browser': [.2, .8], 'Chat': [.6], 'Game': [.78], 'Music': [.35]} + for name, volumes in levels.items(): + matches = [node for node in nodes if node.get('type') == 'PipeWire:Interface:Node' + and node.get('info', {}).get('props', {}).get('application.id') == 'dev.fglabs.Fadrio.Capture' + name] + assert len(matches) == len(volumes), (name, len(matches)) + for node, volume in zip(matches, volumes): + deadline = time.monotonic() + 5 + while lib.vm_set_stream_volume(context, node['id'], volume) != 0: + assert time.monotonic() < deadline, 'Native fixture volume failed' + time.sleep(.1) +finally: + lib.vm_context_destroy(context) +PYSEED +sleep 1 +dotnet src/Fadrio.Cli/bin/Debug/net10.0/fadrioctl.dll mute xdg:dev.fglabs.Fadrio.CaptureMusic >"$fadrio_capture_dir/mute.txt" +dotnet src/Fadrio.Cli/bin/Debug/net10.0/fadrioctl.dll apps >"$fadrio_capture_dir/apps.txt" +[[ $(rg -c '^Application:' "$fadrio_capture_dir/apps.txt") == 4 ]] +sleep 1 +ffmpeg -hide_banner -loglevel error -f x11grab -window_id "$fadrio_capture_window" \ + -video_size 940x680 -i "$DISPLAY" -frames:v 1 "$fadrio_capture_dir/before.png" +export FADRIO_UI_REFERENCE_CAPTURE="$fadrio_capture_dir/before.png" +python3 scripts/ui-interaction-probe.py "$fadrio_capture_window" "$PWD" --preview +kill -0 "$fadrio_capture_ui_pid" diff --git a/scripts/test-ui-interactions.sh b/scripts/test-ui-interactions.sh index 59463d8..5a62551 100755 --- a/scripts/test-ui-interactions.sh +++ b/scripts/test-ui-interactions.sh @@ -62,11 +62,11 @@ printf 'window_ready_seconds=%s\n' "$((SECONDS - fadrio_fixture_started))" >>"$f 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" + -video_size 940x680 -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" + -video_size 940x680 -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 @@ -80,7 +80,7 @@ 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" + -video_size 940x680 -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 @@ -89,7 +89,7 @@ wait "$fadrio_fixture_stream_pid" 2>/dev/null || true fadrio_fixture_stream_pid="" 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/reconnecting.png" + -video_size 940x680 -i "$DISPLAY" -frames:v 1 "$fadrio_fixture_dir/reconnecting.png" pipewire -c "$PWD/tests/fixtures/pipewire/fadrio-test.conf" >>"$fadrio_fixture_dir/pipewire.log" 2>&1 & fadrio_fixture_pipewire_pid=$! for _ in {1..100}; do @@ -98,15 +98,15 @@ for _ in {1..100}; do done 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" + -video_size 940x680 -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" application.icon-name = "fadrio-fixture" }' \ - >"$fadrio_fixture_dir/stream.log" 2>&1 & fadrio_fixture_stream_pid=$! sleep 2 ffmpeg -hide_banner -loglevel error -f x11grab -window_id "$fadrio_fixture_window" \ - -video_size 360x680 -i "$DISPLAY" -frames:v 1 "$fadrio_fixture_dir/recovered-before.png" + -video_size 940x680 -i "$DISPLAY" -frames:v 1 "$fadrio_fixture_dir/recovered-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/recovered.png" + -video_size 940x680 -i "$DISPLAY" -frames:v 1 "$fadrio_fixture_dir/recovered.png" kill -0 "$fadrio_fixture_ui_pid" diff --git a/scripts/ui-interaction-probe.py b/scripts/ui-interaction-probe.py index 7da96ed..7114936 100644 --- a/scripts/ui-interaction-probe.py +++ b/scripts/ui-interaction-probe.py @@ -6,21 +6,27 @@ import sys import time from PIL import Image +from itertools import groupby 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. + # Find the first real vertical fader by its green value track. 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 + for px in range(30, capture.width - 30): + pixels = [py for py in range(180, capture.height - 60) + if (lambda rgb: rgb[1] > rgb[0] + 45 and rgb[2] > rgb[0] + 35)(capture.getpixel((px, py)))] + runs = [[value for _, value in group] for _, group in groupby(enumerate(pixels), lambda pair: pair[1] - pair[0])] + longest = max(runs, key=len, default=[]) + if len(longest) > 100: + candidates.append((px, longest)) + assert candidates, 'No rendered vertical fader found' + first = [candidate for candidate in candidates if candidate[0] < candidates[0][0] + 8] + slider_x, track_pixels = first[len(first) // 2] + slider_top = min(track_pixels) - 8 + slider_bottom = max(track_pixels) - 8 + slider_target = round(slider_top + .63 * (slider_bottom - slider_top)) +mute_y = max(track_pixels) + 44 x = c.CDLL('libX11.so.6') t = c.CDLL('libXtst.so.6') x.XOpenDisplay.restype = c.c_void_p @@ -49,6 +55,7 @@ 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)] +x.XResizeWindow.argtypes = [c.c_void_p, c.c_ulong, c.c_uint, c.c_uint] 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] @@ -117,21 +124,49 @@ def wait_state(predicate): 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 and sys.argv[3] == '--preview': + def capture_preview(name): + geometry = subprocess.check_output(['xwininfo', '-id', hex(window)], text=True) + width = re.search(r'Width: (\d+)', geometry)[1] + height = re.search(r'Height: (\d+)', geometry)[1] + move(400, 110) + subprocess.run(['ffmpeg', '-hide_banner', '-loglevel', 'error', '-f', 'x11grab', + '-window_id', hex(window), '-video_size', width + 'x' + height, + '-i', os.environ['DISPLAY'], '-frames:v', '1', + os.environ['FADRIO_UI_CAPTURE_DIR'] + '/' + name + '.png'], check=True) + + for name, count in [('console-dark', 2), ('console-light', 1)]: + activate() + move(870, 42) + button(1) + button(0) + key('Home') + for _ in range(count): key('Down') + key('Return') + time.sleep(.7) + capture_preview(name) + x.XResizeWindow(d, window, 420, 680) + x.XFlush(d) + time.sleep(.7) + x.XTranslateCoordinates(d, window, root, 0, 0, c.byref(origin_x), c.byref(origin_y), c.byref(child)) + capture_preview('console-narrow') + print('Captured real multi-application console, dark/light themes and narrow viewport', flush=True) + sys.exit(0) if len(sys.argv) > 3: # The shell passes only its own isolated daemon PID. - move(73, slider_y) + move(slider_x, slider_target) button(1) - move(100, slider_y) + move(slider_x, slider_target + 20) os.kill(int(sys.argv[3]), signal.SIGTERM) time.sleep(1) - move(146, slider_y) + move(slider_x, slider_target) button(0) print('Disconnected the isolated daemon during an active drag', flush=True) sys.exit(0) wait_state(lambda observed: observed[0] == 100) - move(314, slider_y) + move(slider_x, slider_top) button(1) - for px in [290, 265, 240, 215, 190, 165, 146]: move(px, slider_y) + for step in range(1, 9): move(slider_x, round(slider_top + (slider_target - slider_top) * step / 8)) button(0) volume, muted = wait_state(lambda observed: 35 <= observed[0] <= 45) print('Rendered slider drag reached', volume, 'percent', flush=True) @@ -139,18 +174,24 @@ def wait_state(predicate): 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) + move(slider_x, slider_target) button(1) button(0) key('Home') - for _ in range(10): key('Right') + for _ in range(10): key('Up') volume, muted = wait_state(lambda observed: observed[0] == 10) - print('Keyboard Home + ten Right keys reached 10 percent', flush=True) - move(62, mute_y) + print('Keyboard Home + ten Up keys reached 10 percent', flush=True) + move(slider_x, mute_y) button(1) button(0) wait_state(lambda observed: observed[1]) print('Rendered mute button muted the isolated stream', flush=True) +except Exception: + subprocess.run(['ffmpeg', '-hide_banner', '-loglevel', 'error', '-f', 'x11grab', + '-window_id', hex(window), '-video_size', str(capture.width) + 'x' + str(capture.height), + '-i', os.environ['DISPLAY'], '-frames:v', '1', + os.path.dirname(os.environ['FADRIO_UI_REFERENCE_CAPTURE']) + '/probe-failure.png']) + raise finally: t.XTestFakeButtonEvent(d, 1, 0, 0) t.XTestFakeMotionEvent(d, -1, old_x.value, old_y.value, 0) diff --git a/src/Fadrio.UI/App.axaml b/src/Fadrio.UI/App.axaml index 1d0b03f..d427bcf 100644 --- a/src/Fadrio.UI/App.axaml +++ b/src/Fadrio.UI/App.axaml @@ -2,6 +2,36 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="Fadrio.UI.App" RequestedThemeVariant="Default"> + + + + + #CFDAE8 + + + + + + + + + + + + #35495D + + + + + + + + + + + + + diff --git a/src/Fadrio.UI/App.axaml.cs b/src/Fadrio.UI/App.axaml.cs index 98d0b41..24d3685 100644 --- a/src/Fadrio.UI/App.axaml.cs +++ b/src/Fadrio.UI/App.axaml.cs @@ -18,7 +18,8 @@ public override void OnFrameworkInitializationCompleted() MixerUiSession? session = null; var viewModel = new MainWindowViewModel( (id, volume) => session!.SetVolumeAsync(id, volume), - (id, muted) => session!.SetMuteAsync(id, muted)); + (id, muted) => session!.SetMuteAsync(id, muted), + preference => ThemePreferenceService.Apply(this, preference)); session = new MixerUiSession(viewModel, database); var window = new MainWindow { diff --git a/src/Fadrio.UI/MainWindow.axaml b/src/Fadrio.UI/MainWindow.axaml index 0fce288..428e818 100644 --- a/src/Fadrio.UI/MainWindow.axaml +++ b/src/Fadrio.UI/MainWindow.axaml @@ -6,53 +6,105 @@ x:DataType="vm:MainWindowViewModel" Title="{Binding Title}" Icon="avares://fadrio/Assets/fadrio-app-icon.png" - Width="360" - Height="680" - MinWidth="320" - MinHeight="400" + Width="940" Height="680" MinWidth="420" MinHeight="420" + Background="{DynamicResource MixerBackground}" + Foreground="{DynamicResource MixerText}" WindowStartupLocation="CenterScreen"> - - - - - - - - - - - - - - - - - - - + + 36 + 16 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +