A Linux build, the AT-SPI bridge finally run, and 112 MB that belonged to Mesa
First build of this tree on a free desktop, which found five things that
Windows could not have.
build.sh and build-wasm.sh, the counterparts of the two .ps1 scripts. All the
build logic stays in CMakeLists.txt, as it does there.
reaktor_root() stripped a path component before its first probe. On Windows
the walk starts at reaktor.exe and that strip is what turns a file into its
directory; everywhere else it starts at the working directory, so the one
directory carrying .reaktor-root was the one never tested. Run from the
repository root the app came up with no stylesheet and no icons. Probe first,
strip second - one extra fopen on Windows, which cannot succeed.
SDL wants XScreenSaver's headers at configure time and fails hard without
them, for a code path this app never reaches: main.c allows the screensaver on
purpose. Turned off, so the README's one-liner works on a stock Debian.
auto is now SDL's software rasteriser on every platform, not only where the
adapter turned out to be WARP. And on the free desktops SDL's GL drivers are
compiled out, because X11 initialises Mesa whatever the renderer is: with no
GPU that GL is llvmpipe, a software rasteriser reached through a JIT, and it
cost 53 MB of libLLVM plus 10 of libgallium and 30 of heap. Same binary, same
page, that flag the only difference - 123.6 MB resident to 11.4.
Labels rode low on every 30px control. nk_widget_text centres on the content
rect, which folds back to the button's middle for any padding - but its first
line clamps a negative height to zero and leaves the origin below the centre,
and tiny.css asks for 39.2px of inset on a 30px row. Four and a half pixels,
on everything that height. reaktor_fit_label() trims the padding to what the
row holds, per widget, so taller buttons keep what the stylesheet asked for.
The same arithmetic compact_push() already documented for glyphs, where it
hides artwork instead of moving text.
Tree headers reported a 4px height to the model, because nk_widget_bounds
peeks the current row and nk_tree_push resets it. The focus ring drew as a
thin bar above the label; so did every bound AT-SPI and UIA were told.
Scroll-to-focus was the keyboard's alone, so a reader that moved focus got a
ring it could not see. Shared as focus_reveal().
The web canvas is rounded at the top - the desktop gets that from the window
manager - which exposed a shell that painted the page dark in both schemes.
The AT-SPI bridge has now been built and run. It compiled clean first try
under -Wall -Wextra, against the docs' own prediction that it would not.
Handshake, tree, signatures, Action and GrabFocus all check out; GetAll still
answers {} and GetExtents still answers in window coordinates, both of which
were predicted. ACCESSIBILITY.md is rewritten around what was measured, and
its phase-4 sketch now matches the three signatures that actually exist.
DEVELOPMENT.md said the app loads reaktor-icon.png and explained at length
why, while the constant names the .svg and the section's own last paragraph
agreed. Corrected, along with a branding/ inventory that counted six files in
two inks where there are three in one.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,12 @@
|
||||
"runtimeExecutable": "python",
|
||||
"runtimeArgs": ["-m", "http.server", "-d", "build-wasm", "8765"],
|
||||
"port": 8765
|
||||
},
|
||||
{
|
||||
"name": "wasm-unix",
|
||||
"runtimeExecutable": "python3",
|
||||
"runtimeArgs": ["-m", "http.server", "-d", "build-wasm", "8765"],
|
||||
"port": 8765
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -46,6 +46,45 @@ endforeach()
|
||||
foreach(drv RENDER_D3D RENDER_D3D12 RENDER_VULKAN VULKAN)
|
||||
set(SDL_${drv} OFF CACHE BOOL "" FORCE)
|
||||
endforeach()
|
||||
|
||||
# And OpenGL, on the free desktops only, which is the largest single thing in
|
||||
# this process's memory and buys it nothing.
|
||||
#
|
||||
# Nothing under src/ calls a GL function or asks for an SDL_WINDOW_OPENGL
|
||||
# window; the renderer is SDL's software rasteriser by default (see the
|
||||
# REAKTOR_RENDERER block in src/main.c). But SDL's X11 driver initialises GL
|
||||
# whatever the renderer is, and on a desktop without a GPU that GL is Mesa's
|
||||
# llvmpipe - which is itself a software rasteriser, reached the expensive way.
|
||||
# Measured here, same binary, same page, only this flag between them:
|
||||
#
|
||||
# SDL with GL RSS 123.6 MB private 58.7 MB heap 31.1 MB
|
||||
# SDL without GL RSS 11.4 MB private 4.3 MB heap 1.1 MB
|
||||
#
|
||||
# 53 MB of that is libLLVM and 10 MB libgallium; the 30 MB of heap is what
|
||||
# llvmpipe allocates on the way up. The figure without it is finally the one
|
||||
# docs/PERFORMANCE.md reports for Windows, where there is no Mesa to load.
|
||||
#
|
||||
# The cost is Mesa's, so the switch is scoped to where Mesa is: Windows keeps
|
||||
# direct3d11 and macOS keeps Metal, neither of which is affected, and
|
||||
# Emscripten keeps GLES because WebGL is the only GPU it has. What it costs
|
||||
# here is REAKTOR_RENDERER=gpu, which on a free desktop now has no driver to
|
||||
# pin - configure with -DREAKTOR_SDL_GL=ON to get it back for a measurement.
|
||||
option(REAKTOR_SDL_GL "Build SDL's OpenGL/GLES drivers on Linux and the BSDs" OFF)
|
||||
if(UNIX AND NOT APPLE AND NOT EMSCRIPTEN AND NOT REAKTOR_SDL_GL)
|
||||
set(SDL_OPENGL OFF CACHE BOOL "" FORCE)
|
||||
set(SDL_OPENGLES OFF CACHE BOOL "" FORCE)
|
||||
endif()
|
||||
|
||||
# And the one X11 extension whose absence stopped the build outright. SDL wants
|
||||
# XScreenSaver's *headers* at configure time and fails hard without them, while
|
||||
# the only thing behind them is SDL_DisableScreenSaver - which this app never
|
||||
# reaches, because main.c sets SDL_HINT_VIDEO_ALLOW_SCREENSAVER on purpose: an
|
||||
# app that draws nothing at rest has no business holding the display awake.
|
||||
# So the dependency was being paid for a code path that is already dead here,
|
||||
# and libxss-dev is not installed by default on a Debian desktop. Inert on
|
||||
# Windows, macOS and Emscripten, where SDL never looks at the variable.
|
||||
set(SDL_X11_XSCRNSAVER OFF CACHE BOOL "" FORCE)
|
||||
|
||||
add_subdirectory("${TP}/SDL" EXCLUDE_FROM_ALL)
|
||||
|
||||
# --------------------------------------------------------- LCUI libcss -----
|
||||
@@ -187,6 +226,38 @@ if(WIN32)
|
||||
file(WRITE "${GEN}/reaktor.rc" "1 ICON \"reaktor.ico\"
|
||||
")
|
||||
set(APP_RESOURCES "${GEN}/reaktor.rc")
|
||||
elseif(UNIX AND NOT APPLE AND NOT EMSCRIPTEN)
|
||||
# The same job as the .rc above, done the way the free desktops do it.
|
||||
#
|
||||
# An ELF file has no icon resource. There is nowhere in the format to put
|
||||
# one, so a file manager draws every executable with the same generic glyph
|
||||
# and no flag on this build changes that - the .ico above is a Windows
|
||||
# resource and reaches nothing here. What a free desktop reads instead is a
|
||||
# .desktop entry, which names the binary and the icon by path: the icon
|
||||
# belongs to the *application* rather than to the file, and turns up in the
|
||||
# menu, in the switcher and beside the window. StartupWMClass is what ties
|
||||
# a running window back to the entry - SDL sets WM_CLASS from argv[0],
|
||||
# which makes it "reaktor".
|
||||
#
|
||||
# Absolute paths, because the binary stays in the build tree (see the note
|
||||
# on reaktor_root at the foot of this file), and generated rather than
|
||||
# committed for the same reason the .rc is: it is boilerplate, and a
|
||||
# committed copy would name whoever built it last. Nothing installs it -
|
||||
# that is the user's directory, not the build's:
|
||||
#
|
||||
# cp build/reaktor.desktop ~/.local/share/applications/
|
||||
file(WRITE "${CMAKE_BINARY_DIR}/reaktor.desktop"
|
||||
"[Desktop Entry]
|
||||
Type=Application
|
||||
Version=1.0
|
||||
Name=Reaktor
|
||||
Comment=A Nuklear-powered engine where none of the styling is compiled in
|
||||
Exec=${CMAKE_BINARY_DIR}/reaktor
|
||||
Icon=${CMAKE_CURRENT_SOURCE_DIR}/branding/reaktor-icon.png
|
||||
Terminal=false
|
||||
Categories=Development;
|
||||
StartupWMClass=reaktor
|
||||
")
|
||||
endif()
|
||||
|
||||
# ---------------------------------------------------------------- app -------
|
||||
|
||||
@@ -61,6 +61,14 @@ on `PATH`.
|
||||
|
||||
### macOS, Linux, the BSDs
|
||||
|
||||
```bash
|
||||
./build.sh
|
||||
```
|
||||
|
||||
The counterpart of `build.ps1`: it checks the submodules are there, prefers
|
||||
Ninja when it is installed, and hands everything else to CMake. `--target NAME`
|
||||
builds one target, `--debug` switches the build type. Or drive CMake yourself:
|
||||
|
||||
```bash
|
||||
cmake -S . -B build && cmake --build build --parallel
|
||||
```
|
||||
@@ -71,15 +79,24 @@ cmake -S . -B build && cmake --build build --parallel
|
||||
.\build-wasm.ps1
|
||||
```
|
||||
|
||||
or, with an activated emsdk on any platform:
|
||||
```bash
|
||||
./build-wasm.sh
|
||||
```
|
||||
|
||||
The shell script looks for emsdk in `$EMSDK`, then beside an `emcc` already on
|
||||
`PATH`, then in `~/emsdk`. `--serve` builds and then serves the result, which
|
||||
is worth knowing because a `file://` page cannot fetch the `.wasm`:
|
||||
|
||||
```bash
|
||||
python3 -m http.server -d build-wasm 8000
|
||||
```
|
||||
|
||||
Or, with an activated emsdk on any platform:
|
||||
|
||||
```bash
|
||||
emcmake cmake -S . -B build-wasm && cmake --build build-wasm --parallel
|
||||
```
|
||||
|
||||
A `file://` page cannot fetch the `.wasm`, so serve the output directory:
|
||||
`python -m http.server -d build-wasm 8000`.
|
||||
|
||||
## Where things are
|
||||
|
||||
| Path | What it is |
|
||||
@@ -93,6 +110,7 @@ A `file://` page cannot fetch the `.wasm`, so serve the output directory:
|
||||
| `src/metrics.c` | The display scale, in one place |
|
||||
| `src/theme.c` | Which colour scheme the desktop is using |
|
||||
| `src/util.c` | Paths, whole-file reads, the resident set |
|
||||
| `build.sh` / `build-wasm.sh` | The Unix side of `build.ps1` and `build-wasm.ps1`; all the build logic is in `CMakeLists.txt` either way |
|
||||
| `branding/` | The project's mark, as SVG, PNG and `.ico` |
|
||||
| `assets/fonts/` | Aileron, the CC0 typeface the UI is set in — vendored rather than submoduled, the one exception to the rule |
|
||||
|
||||
|
||||
Executable
+90
@@ -0,0 +1,90 @@
|
||||
#!/bin/sh
|
||||
# build-wasm.sh - the same sources, linked to a web page.
|
||||
#
|
||||
# The counterpart of build-wasm.ps1. All build logic lives in CMakeLists.txt,
|
||||
# exactly as for the native build; this only locates the Emscripten toolchain
|
||||
# and hands it to CMake.
|
||||
#
|
||||
# ./build-wasm.sh # build
|
||||
# ./build-wasm.sh --serve # build, then serve it on :8000
|
||||
#
|
||||
# emsdk is looked for in $EMSDK, then beside emcc on PATH, then in ~/emsdk.
|
||||
# If none of those has it:
|
||||
# git clone https://github.com/emscripten-core/emsdk
|
||||
# cd emsdk && ./emsdk install latest && ./emsdk activate latest
|
||||
#
|
||||
# Output: build-wasm/reaktor.html plus its .js, .wasm and .data. A file:// page
|
||||
# cannot fetch the .wasm, so the directory has to be served.
|
||||
set -eu
|
||||
|
||||
root=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
||||
out="$root/build-wasm"
|
||||
serve=0
|
||||
port=8000
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--serve|-s) serve=1 ;;
|
||||
--port|-p)
|
||||
shift
|
||||
[ $# -gt 0 ] || { echo "build-wasm.sh: --port needs a number" >&2; exit 2; }
|
||||
port="$1" ;;
|
||||
--help|-h) sed -n '2,17p' "$0" | cut -c 3-; exit 0 ;;
|
||||
--) shift; break ;;
|
||||
*) echo "build-wasm.sh: unknown argument: $1 (try --help)" >&2; exit 2 ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# $EMSDK first, then the emsdk that owns an emcc already on PATH, then the
|
||||
# default clone location. Only the toolchain file is actually needed: emcmake
|
||||
# exists to set CMAKE_TOOLCHAIN_FILE and two cache variables, and passing it
|
||||
# directly is the same thing without a second process.
|
||||
emsdk="${EMSDK:-}"
|
||||
if [ -z "$emsdk" ] && command -v emcc >/dev/null 2>&1; then
|
||||
emcc_path=$(command -v emcc)
|
||||
emsdk=$(CDPATH= cd -- "$(dirname -- "$emcc_path")/../.." && pwd)
|
||||
fi
|
||||
[ -n "$emsdk" ] || emsdk="$HOME/emsdk"
|
||||
|
||||
toolchain="$emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake"
|
||||
if [ ! -f "$toolchain" ]; then
|
||||
echo "build-wasm.sh: emsdk not found at $emsdk" >&2
|
||||
echo " clone https://github.com/emscripten-core/emsdk, run './emsdk install latest'" >&2
|
||||
echo " then './emsdk activate latest', or set EMSDK to an existing one" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
command -v cmake >/dev/null 2>&1 || {
|
||||
echo "build-wasm.sh: cmake not found on PATH" >&2; exit 1; }
|
||||
|
||||
if [ ! -f "$root/third_party/SDL/CMakeLists.txt" ]; then
|
||||
echo "build-wasm.sh: submodules missing - run: git submodule update --init --recursive" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# emcc needs node and the rest of the sdk on PATH, which emsdk_env.sh sets up.
|
||||
# It writes its banner to stdout, so it is silenced rather than allowed to look
|
||||
# like build output.
|
||||
if [ -f "$emsdk/emsdk_env.sh" ]; then
|
||||
# shellcheck disable=SC1091
|
||||
. "$emsdk/emsdk_env.sh" >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
if command -v ninja >/dev/null 2>&1; then
|
||||
set -- -G Ninja "$@"
|
||||
fi
|
||||
|
||||
cmake -S "$root" -B "$out" \
|
||||
-DCMAKE_TOOLCHAIN_FILE="$toolchain" \
|
||||
-DCMAKE_BUILD_TYPE=Release "$@"
|
||||
cmake --build "$out" --parallel
|
||||
|
||||
echo
|
||||
echo "built: $out/reaktor.html"
|
||||
echo "a file:// page cannot fetch the .wasm, so serve it:"
|
||||
echo " python3 -m http.server -d $out $port"
|
||||
|
||||
if [ "$serve" -eq 1 ]; then
|
||||
exec python3 -m http.server -d "$out" "$port"
|
||||
fi
|
||||
@@ -0,0 +1,61 @@
|
||||
#!/bin/sh
|
||||
# build.sh - convenience wrapper around CMake on macOS, Linux and the BSDs.
|
||||
#
|
||||
# The counterpart of build.ps1, which does the same job on Windows. All build
|
||||
# logic lives in CMakeLists.txt, exactly as it does there; this only checks
|
||||
# that the submodules are present and prefers Ninja when it is installed, so
|
||||
# that the failure modes are a sentence rather than a page of CMake.
|
||||
#
|
||||
# ./build.sh # everything
|
||||
# ./build.sh --target NAME # one CMake target, which is what you want
|
||||
# # while a single library is being brought up
|
||||
# ./build.sh --debug # -DCMAKE_BUILD_TYPE=Debug
|
||||
#
|
||||
# Anything after -- is passed to the configure step untouched.
|
||||
set -eu
|
||||
|
||||
root=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
||||
out="$root/build"
|
||||
target=""
|
||||
buildtype="Release"
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--target|-t)
|
||||
shift
|
||||
[ $# -gt 0 ] || { echo "build.sh: --target needs a name" >&2; exit 2; }
|
||||
target="$1" ;;
|
||||
--debug) buildtype="Debug" ;;
|
||||
--release) buildtype="Release" ;;
|
||||
--help|-h) sed -n '2,16p' "$0" | cut -c 3-; exit 0 ;;
|
||||
--) shift; break ;;
|
||||
*) echo "build.sh: unknown argument: $1 (try --help)" >&2; exit 2 ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
command -v cmake >/dev/null 2>&1 || {
|
||||
echo "build.sh: cmake not found on PATH" >&2; exit 1; }
|
||||
|
||||
if [ ! -f "$root/third_party/SDL/CMakeLists.txt" ]; then
|
||||
echo "build.sh: submodules missing - run: git submodule update --init --recursive" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Ninja if it is there; otherwise CMake's default generator, which is make
|
||||
# everywhere this runs. Neither is required to be installed.
|
||||
if command -v ninja >/dev/null 2>&1; then
|
||||
set -- -G Ninja "$@"
|
||||
fi
|
||||
|
||||
cmake -S "$root" -B "$out" -DCMAKE_BUILD_TYPE="$buildtype" "$@"
|
||||
|
||||
if [ -n "$target" ]; then
|
||||
cmake --build "$out" --parallel --target "$target"
|
||||
echo
|
||||
echo "built target: $target"
|
||||
else
|
||||
cmake --build "$out" --parallel
|
||||
echo
|
||||
echo "built: $out/reaktor"
|
||||
fi
|
||||
+119
-42
@@ -6,11 +6,13 @@ jump, Enter and Space press, and a ring shows where focus is. The tab strip
|
||||
also answers Ctrl-Tab, Ctrl-Shift-Tab and Ctrl-1..7, and F1 opens Diagnostics.
|
||||
**In a browser, a screen reader gets all of it**: the tree is mirrored into
|
||||
hidden DOM beside the canvas, with ARIA roles, names, states and positions, and
|
||||
the browser exposes that to every reader on every platform. On the desktop a
|
||||
reader still finds one window and no contents — the native bridges are ahead.
|
||||
the browser exposes that to every reader on every platform. **On Windows and on
|
||||
the free desktops a reader gets it natively**, through UI Automation and through
|
||||
AT-SPI; macOS is written and has never run.
|
||||
|
||||
**Phases 1, 2, 3 and 4a are done.** The model exists, every widget reports into
|
||||
it, focus lives in it, and the web serves it; 4b–4d and 5 are ahead.
|
||||
**Phases 1, 2, 3, 4a, 4b and 4c are done.** The model exists, every widget
|
||||
reports into it, focus lives in it, the web serves it, and two native bridges
|
||||
serve it; 4d and 5 are ahead.
|
||||
|
||||
## Why it is not a small change
|
||||
|
||||
@@ -122,6 +124,17 @@ Two things came out of doing it that the plan had not foreseen:
|
||||
— a reader should be able to find and scroll to them — but `reaktor_a11y_end`
|
||||
marks them `offscreen` against the window node's rect, so a magnifier is not
|
||||
sent chasing bounds nobody can see.
|
||||
- **`nk_widget_bounds` answers for the row that is current, not the row the
|
||||
widget will get.** For everything that takes the row it is given this is the
|
||||
same sentence twice. A tree header is not: `nk_tree_push` resets the row to
|
||||
its own height before it draws, so a peek taken before the push carries
|
||||
whatever the last layout call set — after `api()`, a 4px spacer. Every tree
|
||||
node went into the model 4px tall, and the focus ring drew as a thin bar
|
||||
above the label rather than a box around it. The height is Nuklear's own
|
||||
expression, `font->height + 2 * tab.padding.y`, taken in one helper so a
|
||||
fourth tree cannot get it wrong. Worth keeping in mind because the bug is
|
||||
invisible in the drawing — Nuklear laid the header out correctly — and shows
|
||||
up only in what the model was told.
|
||||
|
||||
Node counts per page run 26 (Login) to 80 (Buttons).
|
||||
|
||||
@@ -220,7 +233,11 @@ How it came out, and where it differs from the sketch above:
|
||||
to scroll on the next frame, by the node's bounds against the band, with a
|
||||
little air. Only nodes inside the page ask — the tab strip is outside the band
|
||||
too and must not — which the tree answers by ancestry, since the page reports
|
||||
itself as a group.
|
||||
itself as a group. **A reader's focus move asks for it too**, which it did
|
||||
not at first: this lived inside the keyboard's move for long enough that UIA's
|
||||
`SetFocus`, AT-SPI's `GrabFocus` and the web mirror's focus event all stamped
|
||||
a node focused and left the page where it was, so the ring was drawn
|
||||
somewhere nobody could see. It is a function both call now.
|
||||
- **The arrows are the value on a range.** Right and Up step up, Left and Down
|
||||
down, on a slider or a spinner; every other role still lets them move focus
|
||||
among siblings. The shell cannot apply the step itself — it knows a node's
|
||||
@@ -239,11 +256,22 @@ How it came out, and where it differs from the sketch above:
|
||||
One thin interface, four implementations, each independently shippable:
|
||||
|
||||
```c
|
||||
int reaktor_a11y_platform_init(SDL_Window *win);
|
||||
void reaktor_a11y_platform_push(const reaktor_a11y_change *list, int n);
|
||||
void reaktor_a11y_platform_shutdown(void);
|
||||
void reaktor_a11y_platform_init(reaktor_a11y_action activate,
|
||||
reaktor_a11y_action focus, void *user);
|
||||
void reaktor_a11y_platform_push(const reaktor_a11y *a, unsigned focus_id);
|
||||
void reaktor_a11y_platform_drain(void);
|
||||
```
|
||||
|
||||
Three things about that shape, none of them what the sketch above it first
|
||||
said. `init` takes the two callbacks a client's press and a client's focus move
|
||||
turn into rather than a window — a bridge that needs the window asks SDL for
|
||||
it. `push` is handed the whole tree and the focused id, not the change list:
|
||||
every bridge but the web's wanted to re-read the model rather than replay a
|
||||
diff, and the change list is still there to be asked for. And there is no
|
||||
`shutdown`. The third call is `drain`, which runs what a client asked for on
|
||||
the thread that owns the tree; the pump threads are stopped by the process
|
||||
exiting, which on Linux is clean and takes about 200 ms.
|
||||
|
||||
**Web first — done.** Emscripten draws into a canvas, and a canvas is invisible
|
||||
to assistive technology — but a hidden DOM subtree beside it is not. Mirror the
|
||||
shadow tree into `div`s with ARIA roles, names and states, absolutely positioned
|
||||
@@ -367,7 +395,7 @@ checkbox with the pointer parked off-window.
|
||||
field's text or a slider's value means driving Nuklear from outside, which
|
||||
belongs with `ITextProvider` and the caret.
|
||||
|
||||
**AT-SPI — written, not yet run.** Linux *and the BSDs*: AT-SPI is a
|
||||
**AT-SPI — the tree is served.** Linux *and the BSDs*: AT-SPI is a
|
||||
freedesktop standard rather than a Linux one, `at-spi2-core` and Orca are in
|
||||
FreeBSD ports, OpenBSD ports and pkgsrc, and nothing in the bridge is
|
||||
Linux-specific. The build reaches it through `UNIX AND NOT APPLE` and the
|
||||
@@ -400,18 +428,50 @@ thread, so nothing here touches the model. `Accessible`, `Component`, `Action`
|
||||
and `Value` are implemented; `Value` is read-only for the same reason
|
||||
`IValueProvider` is.
|
||||
|
||||
**It has never been compiled, let alone run** — there is no Linux here and no
|
||||
libdbus to build against. What has been done is a syntax and warnings pass with
|
||||
clang against a stub of the libdbus API, which catches typos and shape errors
|
||||
and cannot catch a wrong signature, because the stub is this file's idea of
|
||||
libdbus and would be wrong the same way. Expect the first real build to fail;
|
||||
that is the shape of this, not a sign it is going badly. Verify in this order,
|
||||
cheapest first: `busctl --user tree` to see the object appear at all, then
|
||||
Accerciser to walk it, then Orca.
|
||||
**It has now been built and run**, on Debian 13 with libdbus 1.16.2, Cinnamon,
|
||||
and the accessibility bus already running. For a long time this paragraph said
|
||||
the opposite — that the file had never been compiled, that only a `clang
|
||||
-fsyntax-only` pass against a hand-written libdbus stub stood behind it, and
|
||||
that the first real build should be expected to fail. It did not fail. The
|
||||
first build was clean under `-Wall -Wextra`, and the first run registered.
|
||||
That is worth recording precisely because the prediction was wrong: a stub
|
||||
written from the same reading of the API as the caller catches less than it
|
||||
seems to, and it still caught enough.
|
||||
|
||||
One thing is known wrong and waits for a machine: `GetExtents` answers in
|
||||
window coordinates whatever coordinate type is asked for, because converting to
|
||||
screen coordinates needs a platform call that X and Wayland answer differently.
|
||||
What was checked, in the order the list below prescribes:
|
||||
|
||||
- **The handshake.** The app takes a name on the accessibility bus and answers
|
||||
at `/org/a11y/atspi/accessible/root` — role `application`, name `Reaktor`,
|
||||
one child. `Embed` is not refused.
|
||||
- **The signatures**, which were called the largest untested surface in the
|
||||
file, and are correct. A client walk decodes `(so)`, `a(so)`, `{sv}` and the
|
||||
two-word state array without a malformed reply: the whole tree comes out with
|
||||
its roles, names and rectangles — the title bar's group, the tab list of
|
||||
seven tabs, the colour-scheme group, and the page with its widgets, which is
|
||||
the same walk Windows gives.
|
||||
- **`Action` and focus.** `DoAction(0)` on the Display tab switches the page.
|
||||
`GrabFocus` on a node stamps it focused, and — since the reader's focus move
|
||||
now asks for the same reveal the keyboard does — scrolls the page to it: a
|
||||
tree node at y=2144 in a 680-tall window came back at y=636, with `SHOWING`
|
||||
set where it had been clear.
|
||||
- **Shutdown**, which was the one failure predicted to be obvious rather than
|
||||
subtle. It is not there: the process exits in about 200 ms on a TERM. The
|
||||
pump thread is never explicitly stopped, because nothing stops it — see the
|
||||
note on `drain` above.
|
||||
|
||||
Two things are wrong, and both were predicted:
|
||||
|
||||
- **`GetAll` on the Properties interface answers with an empty dictionary.**
|
||||
That was a judgement rather than a measurement when it was written, and the
|
||||
measurement agrees with the worry: a client that leans on `GetAll` instead of
|
||||
asking for properties by name sees an element with nothing on it.
|
||||
- **Coordinates.** `GetExtents` answers in window coordinates whatever
|
||||
coordinate type is asked for — confirmed by asking for screen coordinates and
|
||||
getting window ones — because converting needs a platform call that X and
|
||||
Wayland answer differently.
|
||||
|
||||
Neither is fixed here. What has not been done is **Orca**, which is the only
|
||||
thing that answers whether any of this is usable rather than merely present.
|
||||
|
||||
**macOS, NSAccessibility — written, not yet run.** `src/sys/a11y_macos.m` is
|
||||
the project's first Objective-C and the only file that is not C, because
|
||||
@@ -461,25 +521,27 @@ None of this is verifiable by looking at it.
|
||||
- **Always:** the Phase 1 golden file, in CI if there ever is one, because the
|
||||
instrumentation is the part that rots.
|
||||
|
||||
### What has to be tested on Linux, the BSDs and macOS, and why
|
||||
### What has to be tested on macOS, and why
|
||||
|
||||
The Windows bridge and the web mirror were written on a machine that could run
|
||||
them, and every claim about them in this document was measured. **The AT-SPI
|
||||
and NSAccessibility bridges were not.** They have never been compiled against
|
||||
the real headers and have never executed an instruction. What they have had is
|
||||
a `clang -fsyntax-only -Wall -Wextra` pass against hand-written stubs of
|
||||
libdbus and Cocoa, which catches typos, unbalanced brackets and wrong argument
|
||||
counts — and cannot catch a wrong signature, because each stub is the bridge's
|
||||
own idea of the API and would be wrong in the same direction.
|
||||
The Windows bridge, the web mirror and now the AT-SPI bridge were each written
|
||||
or run on a machine that could run them, and every claim about them in this
|
||||
document was measured. **The NSAccessibility bridge was not.** It has never
|
||||
been compiled against the real headers and has never executed an instruction.
|
||||
What it has had is a `clang -fsyntax-only -Wall -Wextra` pass against a
|
||||
hand-written stub of Cocoa, which catches typos, unbalanced brackets and wrong
|
||||
argument counts — and cannot catch a wrong signature, because the stub is the
|
||||
bridge's own idea of the API and would be wrong in the same direction.
|
||||
|
||||
So the list below is not a wishlist. It is the set of things that are unknown,
|
||||
in the order they will bite, with what makes each one worth its own check.
|
||||
The AT-SPI list is kept below with its answers, because the answers are the
|
||||
useful part: it is the record of what a bridge written blind actually got
|
||||
wrong, which is two things out of six and neither of them the one that was
|
||||
feared most. The macOS list is still a list of unknowns.
|
||||
|
||||
**Test in this order on either platform.** Each step is cheap and tells you
|
||||
whether the next one is worth attempting; a failure at step 1 makes everything
|
||||
after it unobservable.
|
||||
**Test in this order.** Each step is cheap and tells you whether the next one
|
||||
is worth attempting; a failure at step 1 makes everything after it
|
||||
unobservable.
|
||||
|
||||
#### Linux and the BSDs
|
||||
#### Linux and the BSDs — done, with the answers
|
||||
|
||||
1. **The bus handshake, before anything else.** `busctl --user tree` should
|
||||
show an object under `/org/a11y/atspi/accessible`. *Why first:* the bridge
|
||||
@@ -487,30 +549,45 @@ after it unobservable.
|
||||
behaviour on a desktop without one, and indistinguishable from a bug. Until
|
||||
the object appears, nothing else can be observed. Check the log for
|
||||
"no accessibility bus" and "Embed refused", which are the two ways it gives
|
||||
up deliberately.
|
||||
up deliberately. **Answer: it appears.** Role `application`, name `Reaktor`,
|
||||
one child, and no "Embed refused" in the log. Note that `busctl tree` shows
|
||||
only `/org/a11y/atspi/accessible` itself and no nodes under it — the nodes
|
||||
are answered by a fallback handler and have nothing to introspect, which
|
||||
looks like an empty tree and is not one. Ask for the children instead.
|
||||
2. **Message signatures, in Accerciser.** Every reply is hand-built with
|
||||
`dbus_message_iter_*`, and the type strings — `(so)`, `a(so)`, `{sv}`,
|
||||
`(sss)`, the two-word state array — are the largest untested surface in the
|
||||
file. *Why:* D-Bus rejects a malformed reply at run time and the stub
|
||||
accepted it at compile time, so this is where a mistake is most likely and
|
||||
least visible from here.
|
||||
least visible from here. **Answer: correct, all of them.** A client walk
|
||||
decodes every reply, and the tree comes out matching the Windows one node
|
||||
for node. The surface judged most likely to be wrong was not wrong
|
||||
anywhere.
|
||||
3. **`GetAll` on the Properties interface.** It answers with an empty
|
||||
dictionary rather than an error. *Why:* that was a judgement, not a
|
||||
measurement — a client that leans on `GetAll` instead of asking for
|
||||
properties by name would see an element with nothing on it.
|
||||
properties by name would see an element with nothing on it. **Answer:
|
||||
measured, and it is `{}`.** The worry was right; the behaviour is
|
||||
unchanged, and this is the first of the two things still to fix.
|
||||
4. **Coordinates. This one is known wrong.** `GetExtents` answers in window
|
||||
coordinates whatever coordinate type was asked for, because converting to
|
||||
screen needs a platform call that X and Wayland answer differently, and
|
||||
guessing blind would have been worse than a documented gap. *Why it
|
||||
matters:* a magnifier or a touch reader will land in the wrong place, while
|
||||
a screen reader reading the tree aloud will seem fine — so it will pass a
|
||||
casual test and fail a real user.
|
||||
casual test and fail a real user. **Answer: still wrong, and confirmed by
|
||||
asking.** A request for screen coordinates comes back in window
|
||||
coordinates. The second of the two things still to fix.
|
||||
5. **Shutdown.** The pump thread blocks in `dbus_connection_read_write_dispatch`
|
||||
and is stopped by a flag plus the connection closing. *Why:* if that is
|
||||
wrong the app hangs on exit, which is the one failure here that is obvious
|
||||
and infuriating rather than subtle.
|
||||
and infuriating rather than subtle. **Answer: it does not hang** — about
|
||||
200 ms on a TERM. It is also not stopped: there is no shutdown call in the
|
||||
seam and nothing sets the flag, so what ends the thread is the process
|
||||
ending. That is not a hang, and it is not a shutdown either.
|
||||
6. **Then Orca**, which is the only thing that answers whether any of it is
|
||||
usable rather than merely present.
|
||||
usable rather than merely present. **Not done.** Everything above says the
|
||||
tree is present and well-formed; none of it says it is usable.
|
||||
|
||||
#### macOS
|
||||
|
||||
@@ -564,7 +641,7 @@ which is what makes these cheap to debug at a distance.
|
||||
| 3 focus + keyboard | Full keyboard operation, visible focus ring. Useful with no reader attached. **Done.** |
|
||||
| 4a web | Screen-reader support on every platform, from one implementation. **Done.** |
|
||||
| 4b Windows | Native support where the app is developed. **Done:** tree, focus, values, patterns and activation. |
|
||||
| 4c Linux, BSD | Parity. **Written, unbuilt** — see above. |
|
||||
| 4c Linux, BSD | Parity. **Done:** built and run on Debian over libdbus; tree, focus, actions. |
|
||||
| 4d macOS | Parity. **Written, unbuilt** — see above. |
|
||||
|
||||
1 → 3 is the honest minimum before any bridge is worth writing, and 3 is the
|
||||
|
||||
+64
-11
@@ -142,17 +142,23 @@ change, since the colour is baked into the raster.
|
||||
|
||||
`branding/` holds the project's own icon rather than a borrowed glyph: a C over
|
||||
a hexagon with the radiation trefoil in its counter. It is authored art, checked
|
||||
in as SVG, PNG and `.ico` in two inks — six files, none of them generated at
|
||||
in as SVG, PNG and `.ico` — three files, in one ink, none of them generated at
|
||||
build time.
|
||||
|
||||
**The app uses one of them: `reaktor-icon.png`, the dark ink**, named once as
|
||||
`REAKTOR_MARK` in `src/reaktor.h`. The mark carries its own colours and sits on a
|
||||
yellow ground, so it reads on either theme; a title bar that swapped inks with
|
||||
the theme just made the same logo look like two logos. The light-ink files stay
|
||||
in `branding/` for whatever needs a mark on a dark ground — a slide, a README on
|
||||
a dark site — but nothing in `src/` opens them.
|
||||
**The app uses one of them: `reaktor-icon.svg`**, named once as `REAKTOR_MARK`
|
||||
in `src/reaktor.h`. The mark carries its own colours and sits on a yellow
|
||||
ground, so it reads on either theme; a title bar that swapped inks with the
|
||||
theme just made the same logo look like two logos.
|
||||
|
||||
**Why the PNG and not the SVG.** plutovg starts a dashed stroke at the top of a
|
||||
Two paragraphs below this one used to say the app loaded the PNG instead, and
|
||||
described at length why. It does not, and has not for some time — the constant
|
||||
names the `.svg`, and the account of the three consumers further down already
|
||||
said so, so the section contradicted itself twice over. Checked at title-bar
|
||||
size: the C reads as a C, opening at three o'clock, which is the thing the PNG
|
||||
was there to guarantee. What follows is kept as the record of a survey that is
|
||||
still worth having, not as a description of what the code does.
|
||||
|
||||
**Why the PNG was once used instead.** plutovg starts a dashed stroke at the top of a
|
||||
circle, where SVG says it starts at three o'clock. The mark's C is a ring with
|
||||
an 84° wedge left out by `stroke-dasharray`, so plutosvg renders it a quarter
|
||||
turn off — the opening lands at the top and the C reads as a U. Nothing else in
|
||||
@@ -191,13 +197,21 @@ Nothing here is worth a rewrite to fix one glyph that a PNG already fixes. The
|
||||
note exists so the question is not reopened without new information: a second
|
||||
dasharray-shaped bug, or plutovg going unmaintained, would be that information.
|
||||
|
||||
Three places consume the mark, and one constant keeps them from drifting apart:
|
||||
Four places consume the mark, and one constant keeps the first two from
|
||||
drifting apart:
|
||||
|
||||
- the title bar, at `MARK_SIZE`;
|
||||
- `SDL_SetWindowIcon`, at 64px, for the task bar and Alt-Tab;
|
||||
- `reaktor-icon.ico`, copied into the build directory and named by a two-line
|
||||
generated `.rc` — Explorer takes the icon from a linked Win32 resource, so it
|
||||
has to exist before the linker runs.
|
||||
has to exist before the linker runs;
|
||||
- `reaktor-icon.png`, named by the `.desktop` entry CMake writes into the build
|
||||
directory on the free desktops. An ELF file has no icon resource — there is
|
||||
nowhere in the format to put one, so a file manager draws every executable
|
||||
with the same generic glyph and no flag changes that. A desktop entry is the
|
||||
mechanism instead: it names the binary and the icon by path, so the icon
|
||||
belongs to the application rather than to the file. Nothing installs it;
|
||||
`cp build/reaktor.desktop ~/.local/share/applications/` does.
|
||||
|
||||
The first two go through the same renderer as an Ionicon — the mark is just an
|
||||
SVG under the repo root — but with NULL for both colours, which renders the
|
||||
@@ -329,7 +343,7 @@ same view every time instead of being clicked into place.
|
||||
| `REAKTOR_REDRAW` | `always` draws every callback — for profiling, not for use |
|
||||
| `REAKTOR_A11Y_DUMP` | A path to write the accessibility tree to, once, after the first frame |
|
||||
| `REAKTOR_HOVER_GAP_MS` | Pins the pointer-redraw gap and skips its calibration — for measuring, not for use |
|
||||
| `REAKTOR_RENDERER` | `auto`, `cpu`, `gpu`, `list`, or a driver name — see the renderer section |
|
||||
| `REAKTOR_RENDERER` | `auto` (software, everywhere), `cpu`, `gpu`, `list`, or a driver name — see the renderer section |
|
||||
| `REAKTOR_STATS` | Logs frame timings once a second |
|
||||
|
||||
The Diagnostics tab reports all of it, plus where each frame's milliseconds
|
||||
@@ -366,6 +380,16 @@ Same sources, same `CMakeLists.txt`. The Emscripten-specific parts:
|
||||
`pointer-events: none` — without that, a full-viewport overlay swallows
|
||||
every canvas click and the app looks dead.
|
||||
- No `.ico` is linked; there is no window to give an icon to.
|
||||
- **The canvas is rounded at the top and the page is painted in both inks.**
|
||||
On the desktop the window manager rounds the frame and the app never thinks
|
||||
about it; in a page there is no frame, so the canvas butted flush into the
|
||||
corner of the viewport. `border-radius` on the canvas is the whole fix, top
|
||||
corners only — the bottom edge is the bottom of the page. It also exposed a
|
||||
latent bug: the shell painted `html, body` with the *dark* `--background-body`
|
||||
and nothing else, which was invisible while the canvas covered every pixel
|
||||
and became two dark notches in a light app the moment the corners were cut.
|
||||
It now carries both, switched on `prefers-color-scheme`, which is all the
|
||||
page behind the canvas ever shows.
|
||||
|
||||
## What a frame costs, and why pointer frames are coalesced
|
||||
|
||||
@@ -467,6 +491,20 @@ of any driver this SDL build has — on Windows `direct3d11`, `opengl`,
|
||||
but will not create (both GL drivers fail on a VM with no 3D), logs a line and
|
||||
falls back rather than refusing to start.
|
||||
|
||||
**`auto` is the software rasteriser, on every platform.** It used to be SDL's
|
||||
own first choice, with a swap to software only when the adapter turned out to
|
||||
be WARP; that swap is now the default everywhere and the detection is kept only
|
||||
to label the modes that do ask for a GPU. Three reasons, in order of weight:
|
||||
the app draws nothing at rest and builds a frame only when something changed,
|
||||
so a GPU buys it nothing it can measure; a GPU path costs unconditionally, and
|
||||
on a machine without one it costs a great deal (WARP here, Mesa's llvmpipe on a
|
||||
Linux desktop — see [PERFORMANCE.md](PERFORMANCE.md)); and one rasteriser
|
||||
everywhere is one set of pixels to reason about, which matters because the
|
||||
feathering rules in `nk_sdl_render_ex` are written against this one. Nothing is
|
||||
removed — `gpu` and a driver by name still pin what they always did. On the
|
||||
free desktops the build also compiles SDL's GL drivers out entirely, because
|
||||
X11 loads Mesa whatever the renderer is; `-DREAKTOR_SDL_GL=ON` puts them back.
|
||||
|
||||
**The reference machine has no GPU, and Direct3D still succeeds** — SDL's
|
||||
`direct3d11` backend falls back to WARP, Microsoft's software implementation,
|
||||
so the app pays for a full D3D11 pipeline and a WDDM swapchain present to draw
|
||||
@@ -661,6 +699,21 @@ code, and none of them is a bug.
|
||||
axes.** A generous radius from the stylesheet can drive a small button's
|
||||
content rect negative, at which point its symbol or image silently vanishes.
|
||||
`compact_push()` in `showcase.c` exists for exactly this.
|
||||
- **…and a negative content rect moves the *label* rather than hiding it.**
|
||||
The same arithmetic, a different symptom, and the second one took much longer
|
||||
to see. `nk_widget_text` centres the label with
|
||||
`label.y = b.y + b.h/2 − font->height/2`, which lands on the button's middle
|
||||
for any padding — `content.y + content.h/2` folds back to it. But the first
|
||||
line of that function is `b.h = NK_MAX(b.h, 2 * t->padding.y)`, and for a
|
||||
button `t->padding` is `(0,0)`: a negative height is clamped to zero while
|
||||
`content.y` is left where it was, below the middle. tiny.css asks for 9.6px
|
||||
of padding on a 2px border and an 8px radius — 39.2px of inset — so on a 30px
|
||||
row the label was drawn **4.6px low**, on every control of that height, which
|
||||
reads as text that does not line up with anything. Taller buttons were always
|
||||
fine: at 46px the content height stays positive and never gets clamped.
|
||||
`reaktor_fit_label()` in `main.c` trims the vertical padding to what the row
|
||||
can hold, per widget, so a button tall enough for the stylesheet's padding
|
||||
keeps it and only the rows that were already degenerate change.
|
||||
- **`nk_stroke_rect` is asymmetric.** A 2px border measures 1px on the left
|
||||
and top and 2px on the right and bottom. Combos therefore set
|
||||
`combo.border = 0`, and the page strokes the frame itself, inset by half the
|
||||
|
||||
+34
-2
@@ -160,6 +160,36 @@ after any change to the style or icon paths — before the libcss rule store was
|
||||
rebuilt per load, the same test climbed from 7.9 to 15.5 MB without levelling
|
||||
off.
|
||||
|
||||
### The same app on Linux, and 112 MB of somebody else's
|
||||
|
||||
Every figure above is Windows. The first Linux measurement was **123.6 MB
|
||||
resident** for the same binary drawing the same page, against a working set of
|
||||
29–34 MB there — and none of the difference was Reaktor's.
|
||||
|
||||
`libLLVM.so` accounted for 53 MB and `libgallium` for 10 more, with about 30 MB
|
||||
of heap behind them. That is Mesa's **llvmpipe**: on a desktop with no GPU, the
|
||||
`opengl` driver *is* a software rasteriser, reached through a JIT. Worse, SDL's
|
||||
X11 driver initialises GL whatever renderer the app asked for, so choosing
|
||||
`software` did not avoid it — nothing under `src/` calls a GL function and the
|
||||
process was still paying for the whole stack. The isolating measurement is the
|
||||
dummy video driver, which skips X11 entirely: 9 MB.
|
||||
|
||||
So the build turns SDL's GL drivers off on the free desktops
|
||||
(`REAKTOR_SDL_GL=ON` puts them back for a comparison). Same binary, same page,
|
||||
that flag the only difference:
|
||||
|
||||
| | Resident | Private | Heap |
|
||||
| --- | --- | --- | --- |
|
||||
| SDL with GL | 123.6 MB | 58.7 MB | 31.1 MB |
|
||||
| SDL without GL | **11.4 MB** | **4.3 MB** | **1.1 MB** |
|
||||
|
||||
Five runs of the second arm: resident 11.3–11.6 MB, private 4.27–4.47 MB. A
|
||||
spread of 0.24 MB against a difference of 112 makes this one of the few numbers
|
||||
here that a single reading would have got right anyway.
|
||||
|
||||
Windows keeps `direct3d11` and macOS keeps Metal — neither loads Mesa — and
|
||||
Emscripten keeps GLES, because WebGL is the only GPU a browser has.
|
||||
|
||||
## CPU
|
||||
|
||||
**At rest: 0.00% of one core**, every tab, foreground or background, over
|
||||
@@ -169,8 +199,10 @@ events and `SDL_AppIterate` returns without drawing unless something changed.
|
||||
costs 1.4–2.0% — the loop itself is nearly free.)
|
||||
|
||||
**A drawn frame costs 7–12 ms of CPU on this machine** — 7 on the login card,
|
||||
12 on the busiest page — now that `auto` takes SDL's software renderer when the
|
||||
adapter is WARP. Left to Direct3D it was **78 ms**, and almost none of that was
|
||||
12 on the busiest page — now that `auto` is SDL's software renderer. It used to
|
||||
take it only when the adapter turned out to be WARP; it takes it on every
|
||||
platform now, for the reasons in the renderer section of
|
||||
[DEVELOPMENT.md](DEVELOPMENT.md). Left to Direct3D it was **78 ms**, and almost none of that was
|
||||
Reaktor's: with no GPU, `direct3d11` runs on WARP and the frame is rasterised in
|
||||
software by the display stack, inside this process, on Windows thread-pool
|
||||
threads — the main thread was 3.6–4.7% of it and `ntdll`'s threads ~83%.
|
||||
|
||||
+5
-3
@@ -244,9 +244,11 @@ void reaktor_a11y_dump(const reaktor_a11y *a, FILE *out);
|
||||
typedef void (*reaktor_a11y_action)(void *user, unsigned id);
|
||||
|
||||
/* Hands the tree to the platform after each drawn frame. On the web it is
|
||||
* mirrored into hidden DOM beside the canvas (a11y_web.c); elsewhere it is a
|
||||
* no-op until phases 4b-d. push is cheap when nothing changed: it looks at the
|
||||
* change count and returns. */
|
||||
* mirrored into hidden DOM beside the canvas (a11y_web.c); on Windows it is
|
||||
* served to UI Automation and on the free desktops to AT-SPI (src/sys/); on
|
||||
* macOS the bridge is written and has never run. Anywhere else this is a
|
||||
* no-op. push is cheap when nothing changed: it looks at the change count and
|
||||
* returns. */
|
||||
void reaktor_a11y_platform_init(reaktor_a11y_action activate,
|
||||
reaktor_a11y_action focus, void *user);
|
||||
void reaktor_a11y_platform_push(const reaktor_a11y *a, unsigned focus_id);
|
||||
|
||||
+3
-2
@@ -20,8 +20,9 @@
|
||||
* presses a node or moves to one is answered through two exported functions,
|
||||
* which the shell turns into the same click and focus a key would make.
|
||||
*
|
||||
* Off the web and off Windows every function here is a no-op; 4c and 4d are
|
||||
* the bridges that are still missing. */
|
||||
* Off the web this file stands aside: Windows, the free desktops and macOS
|
||||
* each have a bridge of their own under src/sys/. What is left here is the
|
||||
* no-op for a platform with none of them - see the #elif at the foot. */
|
||||
#include "a11y.h"
|
||||
|
||||
static reaktor_a11y_action g_activate, g_focus;
|
||||
|
||||
+115
-27
@@ -2763,6 +2763,50 @@ reaktor_button_accent(App *app, struct nk_context *ctx, const char *label)
|
||||
return css_button_accent(app, ctx, "button", label, "--links");
|
||||
}
|
||||
|
||||
|
||||
/* Cut a button's vertical padding to what its row can actually hold, for the
|
||||
* one widget about to be drawn.
|
||||
*
|
||||
* nk_do_button insets the content rect by padding + border + rounding and
|
||||
* nk_widget_text then centres the label inside it. The centring is exact for
|
||||
* any padding, because content.y + content.h/2 comes back to the button's
|
||||
* middle - but only while content.h is what the arithmetic produced. tiny.css
|
||||
* asks for 9.6px of padding on top of a 2px border and an 8px radius, which
|
||||
* is 39px of inset; on a 30px row the height comes out negative, NK_MAX in
|
||||
* nk_widget_text clamps it to zero, and the origin is left below the middle.
|
||||
* The label is then centred on the wrong point and sits three to four pixels
|
||||
* low - which reads as a row of buttons whose text does not line up with
|
||||
* anything, and was reported as exactly that.
|
||||
*
|
||||
* It is the same arithmetic compact_push() in showcase.c already documents
|
||||
* for glyphs, where a content rect with no area shows up as artwork that
|
||||
* vanishes rather than as text that sags.
|
||||
*
|
||||
* Height-aware on purpose, and pushed per widget rather than clamped once in
|
||||
* the CSS mapping: a button tall enough for the stylesheet's padding keeps
|
||||
* it, and an image inside one is inset by exactly what it was before. Only
|
||||
* the rows that were already drawing a degenerate content rect change.
|
||||
* Answers whether it pushed; hand that to reaktor_unfit_label. */
|
||||
int
|
||||
reaktor_fit_label(App *app, struct nk_context *ctx, struct nk_rect b)
|
||||
{
|
||||
float room = b.h * 0.5f
|
||||
- (ctx->style.button.border + ctx->style.button.rounding);
|
||||
|
||||
(void)app;
|
||||
if (room < 0.0f) room = 0.0f;
|
||||
if (ctx->style.button.padding.y <= room) return 0;
|
||||
nk_style_push_vec2(ctx, &ctx->style.button.padding,
|
||||
nk_vec2(ctx->style.button.padding.x, room));
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
reaktor_unfit_label(struct nk_context *ctx, int fitted)
|
||||
{
|
||||
if (fitted) nk_style_pop_vec2(ctx);
|
||||
}
|
||||
|
||||
/* A colour swatch: the button rule exactly as its neighbours draw it, with
|
||||
* the fill replaced and no label. Not nk_button_color, which draws its own
|
||||
* rect and so keeps none of the rule's geometry. */
|
||||
@@ -3061,6 +3105,30 @@ focusable(const reaktor_a11y_node *n)
|
||||
* siblings, which is what makes a tab strip or a menu behave as one
|
||||
* control. A node that scrolled out of the window is skipped rather than
|
||||
* scrolled to: nothing here can move a group's scroll yet. */
|
||||
/* Inside the page and outside its visible band: the page scrolls to it on the
|
||||
* frame that follows, where the group's scroll can be set. The band and the
|
||||
* node's bounds are both as of the last frame, which is the frame the node was
|
||||
* measured in, so they agree.
|
||||
*
|
||||
* Shared by the keyboard and by a screen reader, which is the point of it
|
||||
* being a function. A node a reader moved to is as much "where focus is" as
|
||||
* one Tab reached, and only the keyboard was asking: UIA's SetFocus, AT-SPI's
|
||||
* GrabFocus and the web mirror's focus event all stamped the node focused and
|
||||
* left the page where it was, so the ring was drawn somewhere nobody could
|
||||
* see. Checked on Linux over AT-SPI: GrabFocus on a node scrolled out of the
|
||||
* page reported it focused, not showing, and the page did not move. */
|
||||
static void
|
||||
focus_reveal(App *app, const reaktor_a11y_node *t, int n, int pick)
|
||||
{
|
||||
const struct nk_rect *b = &app->body_rect, *r = &t[pick].bounds;
|
||||
|
||||
if (node_under(t, n, pick, app->page_node) &&
|
||||
(r->y < b->y || r->y + r->h > b->y + b->h)) {
|
||||
app->focus_scroll = 1;
|
||||
app->focus_scroll_rect = *r;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
focus_move(App *app, int step)
|
||||
{
|
||||
@@ -3097,19 +3165,7 @@ focus_move(App *app, int step)
|
||||
app->focus_seen = 1;
|
||||
app->focus_visible = 1;
|
||||
app->dirty = 1;
|
||||
/* Inside the page and outside its visible band: the page scrolls to it
|
||||
* on the frame that follows, where the group's scroll can be set. The
|
||||
* band and the node's bounds are both as of the last frame, which is
|
||||
* the frame the node was measured in, so they agree. */
|
||||
{
|
||||
const struct nk_rect *b = &app->body_rect, *r = &t[pick].bounds;
|
||||
|
||||
if (node_under(t, n, pick, app->page_node) &&
|
||||
(r->y < b->y || r->y + r->h > b->y + b->h)) {
|
||||
app->focus_scroll = 1;
|
||||
app->focus_scroll_rect = *r;
|
||||
}
|
||||
}
|
||||
focus_reveal(app, t, n, pick);
|
||||
/* Tab into a field puts the caret in it, as it does everywhere else. */
|
||||
if (t[pick].role == REAKTOR_A11Y_TEXTBOX) {
|
||||
app->key_click = 1;
|
||||
@@ -3229,6 +3285,7 @@ reader_focus(void *user, unsigned id)
|
||||
app->focus_seen = 1;
|
||||
app->focus_visible = 1;
|
||||
app->dirty = 1;
|
||||
focus_reveal(app, t, n, i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -3508,21 +3565,48 @@ SDL_AppInit(void **appstate, int argc, char *argv[])
|
||||
* platform builds. "list" prints them and exits, so the names do not
|
||||
* have to be guessed.
|
||||
*
|
||||
* "auto" is not simply SDL's own choice: see the software fallback
|
||||
* after the window is created. "gpu" pins the first non-software
|
||||
* driver and keeps it, which is how the two were measured against
|
||||
* each other. */
|
||||
* "auto" is SDL's software rasteriser, on every platform - Windows,
|
||||
* macOS, Linux, the BSDs and the web alike. It is not SDL's own first
|
||||
* choice, and deliberately not:
|
||||
*
|
||||
* - This app draws nothing at rest and builds a frame only when
|
||||
* something changed, so a GPU buys it nothing it can measure. A
|
||||
* drawn frame is 7-12 ms of CPU, once, on a UI that draws a
|
||||
* handful of frames a second at its busiest.
|
||||
* - What a GPU path does cost is unconditional. On the reference
|
||||
* Windows machine direct3d11 lands on WARP and costs six times
|
||||
* SDL's software renderer - 78.7 ms a frame against 13.1 - and
|
||||
* on a Linux desktop with no GPU the opengl driver is Mesa's
|
||||
* llvmpipe, which rasterises in software anyway and maps 53 MB of
|
||||
* libLLVM plus 10 MB of libgallium to do it. Both were the
|
||||
* default here once, and both were paying a GPU's price for a
|
||||
* software renderer's result.
|
||||
* - One rasteriser on every platform is also one set of pixels to
|
||||
* reason about. The feathering rules in nk_sdl_render_ex are
|
||||
* written against the software renderer; a GPU path is the one
|
||||
* that draws the page differently.
|
||||
*
|
||||
* "gpu" pins the first non-software driver and keeps it, which is how
|
||||
* the two were measured against each other, and a driver by name does
|
||||
* the same for one in particular. Nothing about the GPU paths is
|
||||
* removed - they are no longer what you get without asking. */
|
||||
const char *mode = SDL_getenv("REAKTOR_RENDERER");
|
||||
int i, n = SDL_GetNumRenderDrivers();
|
||||
|
||||
if (!mode || !*mode) mode = "auto";
|
||||
SDL_strlcpy(app->render_mode, mode, sizeof(app->render_mode));
|
||||
/* What Diagnostics shows. "auto" alone said nothing about which
|
||||
* renderer it had settled on, which is the first thing anyone asks. */
|
||||
if (SDL_strcmp(mode, "auto") == 0)
|
||||
SDL_strlcpy(app->render_mode, "auto: software",
|
||||
sizeof(app->render_mode));
|
||||
else
|
||||
SDL_strlcpy(app->render_mode, mode, sizeof(app->render_mode));
|
||||
|
||||
if (SDL_strcmp(mode, "list") == 0) {
|
||||
for (i = 0; i < n; i++) SDL_Log("%s", SDL_GetRenderDriver(i));
|
||||
return SDL_APP_SUCCESS;
|
||||
}
|
||||
if (SDL_strcmp(mode, "cpu") == 0) {
|
||||
if (SDL_strcmp(mode, "cpu") == 0 || SDL_strcmp(mode, "auto") == 0) {
|
||||
SDL_SetHint(SDL_HINT_RENDER_DRIVER, "software");
|
||||
} else if (SDL_strcmp(mode, "gpu") == 0) {
|
||||
for (i = 0; i < n; i++) {
|
||||
@@ -3608,14 +3692,18 @@ SDL_AppInit(void **appstate, int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
/* No GPU: Direct3D has landed on WARP, Microsoft's software
|
||||
* implementation, and costs six times what SDL's own software
|
||||
* renderer costs here - 78.7 ms of CPU a frame against 13.1. So
|
||||
* `auto` swaps to SDL's. That swap was written once before and taken
|
||||
* out, because the software rasteriser drew the page differently;
|
||||
* the renderer section in DEVELOPMENT.md is the account of closing
|
||||
* that gap, and what remains of it is accepted. A driver asked for
|
||||
* by name is kept, and reported as running with no GPU behind it. */
|
||||
/* A GPU driver that turned out to have no GPU behind it: on Windows
|
||||
* Direct3D has landed on WARP, Microsoft's software implementation,
|
||||
* which costs six times what SDL's own software renderer costs here -
|
||||
* 78.7 ms of CPU a frame against 13.1.
|
||||
*
|
||||
* `auto` no longer reaches this: it asks for the software renderer
|
||||
* outright, on every platform, so there is nothing to swap. What is
|
||||
* left is the report for the two modes that do ask for a GPU - `gpu`
|
||||
* and a driver by name - which are kept as asked for and labelled
|
||||
* with what they actually got. The swap itself stays because `auto`
|
||||
* can still land here if the software renderer failed to create and
|
||||
* the fallback above picked SDL's own default. */
|
||||
if (renderer_is_software(app->ren)) {
|
||||
if (SDL_strcmp(app->render_mode, "auto") == 0) {
|
||||
SDL_Renderer *sw;
|
||||
|
||||
+25
-3
@@ -595,6 +595,25 @@ stepper_pop(struct nk_context *ctx)
|
||||
nk_style_pop_style_item(ctx);
|
||||
}
|
||||
|
||||
/* The slot nk_tree_push is about to lay out for its header.
|
||||
*
|
||||
* nk_widget_bounds cannot be asked for it directly: it peeks the *current*
|
||||
* row, and the current row is whatever the last layout call set - after api()
|
||||
* that is a 4px spacer. The push then resets the row to Nuklear's own header
|
||||
* height before it draws. So the peek gets x, y and width right and the
|
||||
* height wrong, and the node went into the tree 4px tall: the focus ring came
|
||||
* out as a thin bar above the label instead of a box around it, and every
|
||||
* platform reading bounds - the ring, AT-SPI, UIA - was told the same wrong
|
||||
* thing. The expression below is Nuklear's own, from nk_tree_state_base, and
|
||||
* it is the one tree_chevron already assumes when it centres the chevron. */
|
||||
static struct nk_rect
|
||||
tree_header_bounds(struct nk_context *ctx)
|
||||
{
|
||||
struct nk_rect b = nk_widget_bounds(ctx);
|
||||
b.h = ctx->style.font->height + 2.0f * ctx->style.tab.padding.y;
|
||||
return b;
|
||||
}
|
||||
|
||||
/* A tree header's chevron, in the slot nk_tree_state_base gives its own: a
|
||||
* font-height square at the header's padding. `b` is the header's bounds,
|
||||
* captured before the push; `open` is what the push answered. */
|
||||
@@ -875,8 +894,11 @@ static int
|
||||
demo_button(App *app, struct nk_context *ctx, const char *label)
|
||||
{
|
||||
unsigned id = hot(app, ctx, REAKTOR_A11Y_BUTTON, label, 0);
|
||||
int fitted = reaktor_fit_label(app, ctx, nk_widget_bounds(ctx));
|
||||
int hit = nk_button_label(ctx, label);
|
||||
|
||||
reaktor_unfit_label(ctx, fitted);
|
||||
|
||||
/* Both, always: `||` would short-circuit and leave the activation for the
|
||||
* frame to turn into a second press. */
|
||||
if (reaktor_focus_activated(app, id)) hit = 1;
|
||||
@@ -1633,7 +1655,7 @@ page_display(App *app, struct nk_context *ctx, showcase_state *s)
|
||||
* left empty. Closed nodes still report, and still get their chevron:
|
||||
* a reader can reach a collapsed branch, and it points somewhere. */
|
||||
{
|
||||
struct nk_rect hb = nk_widget_bounds(ctx);
|
||||
struct nk_rect hb = tree_header_bounds(ctx);
|
||||
int open;
|
||||
|
||||
hot(app, ctx, REAKTOR_A11Y_NONE, NULL, 0);
|
||||
@@ -1645,7 +1667,7 @@ page_display(App *app, struct nk_context *ctx, showcase_state *s)
|
||||
nk_layout_row_dynamic(ctx, ROW_SMALL, 1);
|
||||
nk_label(ctx, "Its children are indented under it.", NK_TEXT_LEFT);
|
||||
|
||||
hb = nk_widget_bounds(ctx);
|
||||
hb = tree_header_bounds(ctx);
|
||||
hot(app, ctx, REAKTOR_A11Y_NONE, NULL, 0);
|
||||
open = nk_tree_push(ctx, NK_TREE_NODE, "A node inside it",
|
||||
NK_MINIMIZED);
|
||||
@@ -1662,7 +1684,7 @@ page_display(App *app, struct nk_context *ctx, showcase_state *s)
|
||||
for (i = 0; i < 3; i++) {
|
||||
char lab[32];
|
||||
SDL_snprintf(lab, sizeof(lab), "Selectable branch %d", i + 1);
|
||||
hb = nk_widget_bounds(ctx);
|
||||
hb = tree_header_bounds(ctx);
|
||||
hot(app, ctx, REAKTOR_A11Y_NONE, NULL, 0);
|
||||
open = nk_tree_element_push(ctx, NK_TREE_NODE, lab,
|
||||
NK_MINIMIZED, &s->tree_leaf[i]);
|
||||
|
||||
@@ -142,6 +142,13 @@ void reaktor_hot_top(App *app, struct nk_rect r, int cursor, int repaint);
|
||||
* crossing into it - for anything drawn at the pointer. */
|
||||
void reaktor_hot_follow(App *app, struct nk_rect r, int cursor);
|
||||
|
||||
/* Cuts a button's vertical padding to what its row can hold, for the one
|
||||
* widget about to be drawn, and puts it back. Without it a label on a row
|
||||
* shorter than padding + border + rounding is centred on a clamped content
|
||||
* rect and rides low - see the note on the definition in main.c. */
|
||||
int reaktor_fit_label(App *app, struct nk_context *ctx, struct nk_rect b);
|
||||
void reaktor_unfit_label(struct nk_context *ctx, int fitted);
|
||||
|
||||
int reaktor_button(App *app, struct nk_context *ctx, const char *label);
|
||||
int reaktor_button_accent(App *app, struct nk_context *ctx, const char *label);
|
||||
int reaktor_button_icon(App *app, struct nk_context *ctx,
|
||||
|
||||
+18
-6
@@ -70,11 +70,20 @@ int reaktor_root(char *out, size_t cap)
|
||||
* This used to probe for a "third_party" directory, which broke under
|
||||
* CMake: add_subdirectory(third_party/SDL) mirrors that path into the
|
||||
* build tree, so build/third_party existed and the walk stopped one
|
||||
* level too early. A dedicated marker cannot be shadowed that way. */
|
||||
* level too early. A dedicated marker cannot be shadowed that way.
|
||||
*
|
||||
* Probe first, strip second - and not the other way round, which cost
|
||||
* the starting directory its turn. That is invisible on Windows, where
|
||||
* the walk starts at reaktor.exe and the first strip is what turns a
|
||||
* file into the directory holding it. It is the whole of the bug
|
||||
* everywhere else, where the walk starts at the working directory: run
|
||||
* from the repository root, the one directory that carries the marker
|
||||
* was the one directory never tested, and the app came up with no
|
||||
* stylesheet and no icons. Probing the start costs Windows one fopen
|
||||
* of "...reaktor.exe/.reaktor-root", which cannot succeed, and every
|
||||
* probe after it is the one it always made. */
|
||||
for (;;) {
|
||||
char *slash = strrchr(exe, '/');
|
||||
if (!slash) return 0;
|
||||
*slash = '\0';
|
||||
char *slash;
|
||||
|
||||
if (snprintf(probe, sizeof(probe), "%s/.reaktor-root", exe) < 0)
|
||||
return 0;
|
||||
@@ -83,8 +92,11 @@ int reaktor_root(char *out, size_t cap)
|
||||
FILE *f = fopen(probe, "rb");
|
||||
if (f) { fclose(f); return copy_out(out, cap, exe); }
|
||||
}
|
||||
/* Stop once we have chewed back to the root. */
|
||||
if (strchr(exe, '/') == NULL) return 0;
|
||||
|
||||
/* Stop once we have chewed back past the root. */
|
||||
slash = strrchr(exe, '/');
|
||||
if (!slash) return 0;
|
||||
*slash = '\0';
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
+16
-1
@@ -12,15 +12,30 @@
|
||||
html, body {
|
||||
margin: 0;
|
||||
height: 100%;
|
||||
background: #252525; /* tiny.css --background-body, dark */
|
||||
/* tiny.css --background-body. Both inks, and not the dark one alone:
|
||||
this used to be hardcoded to #252525, which was invisible while the
|
||||
canvas covered every pixel of the page and stopped being invisible the
|
||||
moment its corners were rounded - a light app with two dark notches cut
|
||||
out of the top. The app has its own switch, so this only has to be
|
||||
right for "system", which is what it defaults to. */
|
||||
background: #f7f7f7;
|
||||
overflow: hidden;
|
||||
}
|
||||
@media (prefers-color-scheme: dark) {
|
||||
html, body { background: #252525; }
|
||||
}
|
||||
/* No width or height on the canvas: SDL sizes it to the window it asks
|
||||
for, and the app asks for the page's size. A CSS size here would stretch
|
||||
the rendering instead of resizing it. */
|
||||
#canvas {
|
||||
display: block;
|
||||
outline: none;
|
||||
/* Rounded at the top, square at the bottom. On the desktop the window
|
||||
manager rounds the frame and the app never thinks about it; in a page
|
||||
there is no frame, so the canvas was a flush rectangle butting into the
|
||||
corner of the viewport. Top only - the bottom edge is the bottom of the
|
||||
page, and rounding it would cut a notch out of nothing. */
|
||||
border-radius: 10px 10px 0 0;
|
||||
}
|
||||
#status {
|
||||
position: fixed;
|
||||
|
||||
Reference in New Issue
Block a user