Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
feat(cua-driver): ship vector semantic cursor themes (#2603)
Francesco Bonaccie2c52d50ba33
diff --git a/.github/workflows/cd-rust-cua-driver.yml b/.github/workflows/cd-rust-cua-driver.ymlindex 9049bd23b8..9eaddfcfd6 100644--- a/.github/workflows/cd-rust-cua-driver.yml+++ b/.github/workflows/cd-rust-cua-driver.yml@@ -146,12 +146,13 @@ jobs:cp "target/${TARGET}/release/libcua_driver_sdk.so" "release/${STAGE}/"cp "target/${TARGET}/release/cua_driver_node_runtime.node" "release/${STAGE}/"cp include/cua_driver_abi.h "release/${STAGE}/"+ cp -R ../wayland-helper "release/${STAGE}/wayland-helper"cp ../../LICENSE.md "release/${STAGE}/LICENSE" 2>/dev/null || true(cd release && tar -czf "${STAGE}.tar.gz" "${STAGE}")# Bare runtime tarball: CLI plus the UniFFI library consumed by the# Python and Node imported-SDK packages.tar -czf "release/${STAGE}-binary.tar.gz" -C "release/${STAGE}" \- cua-driver cua-cursor-theme libcua_driver_sdk.so cua_driver_node_runtime.node cua_driver_abi.h+ cua-driver cua-cursor-theme libcua_driver_sdk.so cua_driver_node_runtime.node cua_driver_abi.h wayland-helperls -lh "release/${STAGE}.tar.gz" "release/${STAGE}-binary.tar.gz"- uses: actions/upload-artifact@v4with:diff --git a/.github/workflows/ci-nix-linux.yml b/.github/workflows/ci-nix-linux.ymlindex 6fb0a930b4..f87cd4ec00 100644--- a/.github/workflows/ci-nix-linux.yml+++ b/.github/workflows/ci-nix-linux.yml@@ -17,6 +17,7 @@ on:- "libs/cua-driver/rust/crates/cursor-overlay/**"- "libs/cua-driver/rust/crates/pip-preview/**"- "libs/cua-driver/rust/crates/platform-linux/**"+ - "libs/cua-driver/wayland-helper/**"- "libs/cua-driver/tests/fixtures/shared/web/index.html"- ".github/workflows/ci-nix-linux.yml"push:@@ -34,6 +35,7 @@ on:- "libs/cua-driver/rust/crates/cursor-overlay/**"- "libs/cua-driver/rust/crates/pip-preview/**"- "libs/cua-driver/rust/crates/platform-linux/**"+ - "libs/cua-driver/wayland-helper/**"- "libs/cua-driver/tests/fixtures/shared/web/index.html"- ".github/workflows/ci-nix-linux.yml"workflow_dispatch:diff --git a/.github/workflows/ci-rust-linux.yml b/.github/workflows/ci-rust-linux.ymlindex a3e78602c0..1a92ff6c6f 100644--- a/.github/workflows/ci-rust-linux.yml+++ b/.github/workflows/ci-rust-linux.yml@@ -13,6 +13,7 @@ on:- "libs/cua-driver/rust/crates/cursor-overlay/**"- "libs/cua-driver/rust/crates/pip-preview/**"- "libs/cua-driver/rust/crates/platform-linux/**"+ - "libs/cua-driver/wayland-helper/**"- "libs/cua-driver/tests/fixtures/**"- "nix/**"- "flake.nix"@@ -31,6 +32,7 @@ on:- "libs/cua-driver/rust/crates/cursor-overlay/**"- "libs/cua-driver/rust/crates/pip-preview/**"- "libs/cua-driver/rust/crates/platform-linux/**"+ - "libs/cua-driver/wayland-helper/**"- "libs/cua-driver/tests/fixtures/**"- "nix/**"- "flake.nix"diff --git a/docs/content/docs/how-to-guides/driver/personalize-cursor.mdx b/docs/content/docs/how-to-guides/driver/personalize-cursor.mdxindex b5ef19b353..7b9b7276f5 100644--- a/docs/content/docs/how-to-guides/driver/personalize-cursor.mdx+++ b/docs/content/docs/how-to-guides/driver/personalize-cursor.mdx@@ -6,14 +6,18 @@ description: "Use Cua Driver's semantic default cursor or compile and install aimport { Callout } from 'fumadocs-ui/components/callout';Cua Driver ships one built-in theme, `cua.default`, on macOS, Windows, and-Linux. It uses an off-white pointer with a navy outline and small animations-for actions such as observe, click, drag, scroll, type, and navigate.+Linux. It uses a session-colored pointer with a white outline and matching+glow. Every state shares the same gentle floating motion, with semantic+animations layered on top for actions such as observe, click, drag, scroll,+type, and navigate.<Callout type="warn" title="Visual aid, not authorization">The cursor helps a person follow an agent. It is not a security indicator,consent prompt, or proof that an action succeeded.</Callout>++## Select a theme for a sessionCreate a session and select an already-installed theme by ID:@@ -49,7 +53,12 @@ A source theme is a dotLottie archive with:- an author and license.The compiler enforces the complete theme contract, including the semantic-manifest, animation inventory, frame limits, author, and license.+manifest, animation inventory, frame limits, bounded vector feature set,+author, and license. It preserves paths and strokes as vectors, so the native+renderer can draw them at the current display scale instead of enlarging a+fixed-resolution image.++Validate, compile, inspect, and preview the source:@@ -77,12 +86,19 @@ visually distinct design under a separate theme ID.Theme authoring is a trusted local workflow. The short-lived compiler validatesthe ZIP and Lottie source, rejects unsupported or unbounded content, and emits-bounded premultiplied RGBA frames.+bounded vector frames containing validated geometry, paints, and transforms.The privileged overlay loads only the compiled `.cua-theme` artifact. It neverparses ZIP, JSON, Lottie, fonts, expressions, URLs, or an arbitrary source-path. MCP and SDK tools may select an installed ID, but they cannot install-source or submit inline animation data.+path. It rasterizes the bounded vector commands through Skia at the display's+actual backing scale. MCP and SDK tools may select an installed ID, but they+cannot install source or submit inline animation data.++The built-in `cua.default` theme uses the same compiler and renderer. Cua ships+its compiled artifact inside the driver, so users do not need to install it.+The driver applies the stable session color and shared floating motion after+compositing the default theme's action and modifier layers. Installed custom+themes keep their authored colors.Remove a custom theme with:diff --git a/docs/public/img/cua-driver/cursor-themes/action-animations.gif b/docs/public/img/cua-driver/cursor-themes/action-animations.gifnew file mode 100644index 0000000000..003b96711aBinary files /dev/null and b/docs/public/img/cua-driver/cursor-themes/action-animations.gif differdiff --git a/docs/public/img/cua-driver/cursor-themes/delivery-target-context.gif b/docs/public/img/cua-driver/cursor-themes/delivery-target-context.gifnew file mode 100644index 0000000000..bf72322bb8Binary files /dev/null and b/docs/public/img/cua-driver/cursor-themes/delivery-target-context.gif differdiff --git a/flake.nix b/flake.nixindex be381c6d4b..5f4582277f 100644--- a/flake.nix+++ b/flake.nix@@ -28,6 +28,7 @@root = ./libs/cua-driver;fileset = pkgs.lib.fileset.unions [./libs/cua-driver/rust+ ./libs/cua-driver/wayland-helper./libs/cua-driver/compat-fixtures./libs/cua-driver/tests/fixtures/shared/web/index.html];diff --git a/libs/cua-driver/docs/cursor-themes.md b/libs/cua-driver/docs/cursor-themes.mdindex f9335fd915..d3d574fda0 100644--- a/libs/cua-driver/docs/cursor-themes.md+++ b/libs/cua-driver/docs/cursor-themes.md@@ -1,9 +1,20 @@# Agent cursor themesCua Driver ships one built-in cursor theme: `cua.default`. It is the default on-macOS, Windows, and Linux and cannot be removed. The theme uses the approved-off-white pointer with a navy outline and a small semantic animation that-describes what the active session is doing.+macOS, Windows, and Linux and cannot be removed. The theme uses a colored+pointer with a white outline over a larger, cursor-shaped glow in the same+session color. The glow softly fades to transparent around the full pointer+silhouette, while the white outline preserves a crisp boundary on light, dark,+and similarly colored backgrounds. Its semantic action and modifier marks use+the same session-colored center and white-outline treatment as the pointer,+plus a tighter, softer glow so they remain legible without competing with it.+Every semantic state inherits the same gentle levitation and rotation as the+idle pointer, with its action-specific motion layered on top. The pointer,+semantic mark, and active modifiers therefore move as one visual unit.+Reduced-motion mode removes this shared movement. The anonymous/default cursor+uses Cua blue. Named sessions receive a stable fill+from the built-in session palette, so concurrent agents remain visually+distinct.The cursor is a visual aid for people watching an agent. It is not a securityindicator, an authorization prompt, or evidence that a tool call succeeded.@@ -28,6 +39,10 @@ its `cursor_id`, shape, color, label, size, opacity, image-path, gradient, andbloom styling fields are not accepted. Input-delivery tools may still use`cursor_id` to name a virtual pointer; it does not select cursor artwork.+The default theme fill is derived from the declared `session` id. There is no+separate fill-color tool argument. Installed custom themes keep the colors+compiled into their own artwork.+The same four typed operations are available on `CuaDriver` and`CuaDriverSession` in the Python and TypeScript SDKs:@@ -44,20 +59,20 @@ accessibility preference where the platform exposes one.A full custom theme must provide all twelve action animations:-| Action | Playback |-| --- | --- |-| `idle` | resting loop |-| `observe` | loop |-| `click` | one shot |-| `drag` | held |-| `scroll` | loop |-| `text` | held |-| `key` | one shot |-| `navigate` | one shot |-| `app` | one shot |-| `transfer` | loop |-| `record` | loop |-| `system` | one shot |+| Action | Playback |+| ---------- | ------------ |+| `idle` | resting loop |+| `observe` | loop |+| `click` | one shot |+| `drag` | held |+| `scroll` | loop |+| `text` | held |+| `key` | one shot |+| `navigate` | one shot |+| `app` | one shot |+| `transfer` | loop |+| `record` | loop |+| `system` | one shot |It must also provide six transparent modifier animations. The renderercomposites at most one delivery modifier and one target modifier over the@@ -85,10 +100,17 @@ theme.lottieEvery animation must be a transparent 128×128 Lottie animation at 30 fps andcontain no more than 120 frames. A compiled theme may contain at most 1,000-frames in total across its actions and modifiers. Profile v1 supports the-bounded subset accepted by the bundled compiler. Expressions, scripts,-external URLs, fonts, images, unbounded archives, and unsupported renderer-features are rejected.+frames in total across its actions and modifiers. The compiler samples+animation timing at 30 fps but preserves the artwork as vector paths, ellipses,+rounded rectangles, solid fills, strokes, and transforms. The overlay then+rasterizes those commands at the display's live backing scale.++Profile v1 accepts shape layers with static path geometry and animated layer+position, scale, rotation, opacity, solid color, and stroke width. Shape-layer+transforms must remain at their identity values; place animation on the layer+transform instead. Groups, animated path geometry, expressions, scripts,+external URLs, fonts, images, nested assets, masks, effects, parented layers,+unbounded archives, and other unsupported Lottie features are rejected.`manifest.json` must contain every referenced animation ID. A minimal`cua/theme.json` has this shape:@@ -163,12 +185,56 @@ cua-driver cursor-theme uninstall com.example.cursor.studio```The authoring compiler is a short-lived, unprivileged sidecar. It converts-Lottie source into bounded, premultiplied RGBA frames. The privileged overlay-loads only the compiled `.cua-theme` format; it never parses ZIP, JSON, Lottie,-fonts, expressions, URLs, or arbitrary source paths. Agent-facing tools can-select an already-installed ID but cannot install a theme or pass inline theme-data.--The embedded default is rendered directly as native vector paths for smaller-artifacts and lower idle memory. It follows the same semantic and reduced-motion-contract as compiled Lottie themes.+Lottie source into bounded vector frames containing only validated geometry,+paint, and transforms. The privileged overlay loads only the compiled+`.cua-theme` format and rasterizes those commands through Skia at the requested+backing scale. It never parses ZIP, JSON, Lottie, fonts, expressions, URLs, or+arbitrary source paths. Agent-facing tools can select an already-installed ID+but cannot install a theme or pass inline theme data.++The built-in default follows the same path. Its canonical+`cua.default.lottie` source and reproducible generator are checked into+`cursor-overlay/assets/`. The resulting bounded `cua.default.cua-theme` is+embedded in the binary and decoded by the same renderer used for installed+custom themes. Only the embedded default receives the runtime session-color+tint and shared float transform. The artifact contains no fixed-resolution+pixel atlas, so the cursor stays crisp at 1×, 2×, 3×, and fractional display+scales.++From the Rust workspace, contributors can reproduce both checked-in artifacts:++```bash+python3 crates/cursor-overlay/assets/build_default_theme.py+cargo run -p cursor-theme-cli -- build \+ crates/cursor-overlay/assets/cua.default.lottie \+ --output crates/cursor-overlay/assets/cua.default.cua-theme+```++A unit test verifies that the compiled artifact's source hash matches the+checked-in dotLottie archive.++## Preview the production renderer++Contributors can inspect every built-in state in the static cursor gallery. The+gallery uses WebM assets generated from `cursor-overlay`, so its pixels and+timing come from the production renderer rather than a browser reimplementation.++From the repository root:++```bash+./libs/cua-driver/scripts/cursor-gallery.sh serve+```++Open `http://127.0.0.1:3001` to pause, replay, change speed, and compare the+states on light, dark, blue, or mixed backgrounds. The generated WebM files and+raw frames are ignored by Git.++Regenerate the public documentation GIFs after changing the built-in cursor:++```bash+./libs/cua-driver/scripts/cursor-gallery.sh export-docs+```++Commit both GIFs in `docs/public/img/cua-driver/cursor-themes/` with the renderer+change. The export requires Chrome, Node.js with WebSocket support, Python 3,+and ffmpeg.diff --git a/libs/cua-driver/rust/Cargo.lock b/libs/cua-driver/rust/Cargo.lockindex 3d6d3715a2..a316a151f8 100644--- a/libs/cua-driver/rust/Cargo.lock+++ b/libs/cua-driver/rust/Cargo.lock@@ -1089,7 +1089,7 @@ dependencies = ["serde","serde_json","sha2",- "tiny-skia 0.11.4",+ "tiny-skia","tracing","zstd",]@@ -1101,11 +1101,11 @@ dependencies = ["anyhow","cursor-overlay","image",- "rasterlottie","serde","serde_json","sha2","tempfile",+ "tiny-skia","zip",]@@ -2613,7 +2613,7 @@ dependencies = ["serde","serde_json","thiserror 1.0.69",- "tiny-skia 0.11.4",+ "tiny-skia","usvg",]@@ -2770,7 +2770,7 @@ dependencies = ["serde","serde_json","thiserror 1.0.69",- "tiny-skia 0.11.4",+ "tiny-skia","tokio","tracing","tracing-subscriber",@@ -2814,7 +2814,7 @@ dependencies = ["serde","serde_json","thiserror 1.0.69",- "tiny-skia 0.11.4",+ "tiny-skia","tokio","tokio-tungstenite","tracing",@@ -2838,7 +2838,7 @@ dependencies = ["serde","serde_json","thiserror 1.0.69",- "tiny-skia 0.11.4",+ "tiny-skia","tokio","tracing","windows 0.58.0",@@ -3039,20 +3039,6 @@ version = "0.10.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69"-[[package]]-name = "rasterlottie"-version = "0.2.1"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "384686130a2b365f82258f5e444c512e57989addcf2b45e9913c4ef6f0e95a24"-dependencies = [- "rustc-hash 2.1.3",- "serde",- "serde_json",- "thiserror 2.0.18",- "tiny-skia 0.12.0",- "zip",-]-[[package]]name = "redox_syscall"version = "0.5.18"@@ -3195,7 +3181,7 @@ dependencies = ["pico-args","rgb","svgtypes",- "tiny-skia 0.11.4",+ "tiny-skia","usvg",]@@ -3873,22 +3859,7 @@ dependencies = ["cfg-if","log","png 0.17.16",- "tiny-skia-path 0.11.4",-]--[[package]]-name = "tiny-skia"-version = "0.12.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "47ffee5eaaf5527f630fb0e356b90ebdec84d5d18d937c5e440350f88c5a91ea"-dependencies = [- "arrayref",- "arrayvec",- "bytemuck",- "cfg-if",- "log",- "png 0.18.1",- "tiny-skia-path 0.12.0",+ "tiny-skia-path",][[package]]@@ -3902,17 +3873,6 @@ dependencies = ["strict-num",]-[[package]]-name = "tiny-skia-path"-version = "0.12.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "edca365c3faccca67d06593c5980fa6c57687de727a03131735bb85f01fdeeb9"-dependencies = [- "arrayref",- "bytemuck",- "strict-num",-]-[[package]]name = "tinystr"version = "0.8.3"@@ -4469,7 +4429,7 @@ dependencies = ["siphasher","strict-num","svgtypes",- "tiny-skia-path 0.11.4",+ "tiny-skia-path","unicode-bidi","unicode-script","unicode-vo",diff --git a/libs/cua-driver/rust/Skills/cua-driver/SKILL.md b/libs/cua-driver/rust/Skills/cua-driver/SKILL.mdindex 69302b8740..a6047f635a 100644--- a/libs/cua-driver/rust/Skills/cua-driver/SKILL.md+++ b/libs/cua-driver/rust/Skills/cua-driver/SKILL.md@@ -166,7 +166,11 @@ must be replaced by a fresh snapshot.Visual cursor overlay for demos and screen recordings. It is enabled bydefault for declared sessions; anonymous actions remain cursor-less. Toggle with`set_agent_cursor_enabled` to hide or re-show it. The embedded-`cua.default` theme uses an off-white/navy pointer and semantic animations for+`cua.default` theme uses a session-colored pointer over a larger,+cursor-shaped glow in the same session color. The glow fades to transparent+around the full silhouette. Action and modifier marks use the same+session-colored center and white-outline treatment, plus a tighter, softer+glow. This pairing preserves contrast across varied backgrounds. It provides animations foridle, observe, click, drag, scroll, text, key, navigation, app, transfer,recording, and system activity. Motion knobs:`set_agent_cursor_motion` takes any subset of `start_handle`,@@ -179,7 +183,9 @@ MCP connection and the daemon scopes the cursor, config overrides, andrecording to it). The CLI and SDK contracts take the declared `session`explicitly. Cursor-theme controls no longer accept `cursor_id` or the legacyshape/color/image fields. Input-delivery tools may still use `cursor_id` to-name a virtual pointer; it never selects artwork. Select only preinstalled+name a virtual pointer; it never selects artwork. The default cursor is Cua+blue, while each named session receives a stable fill from the built-in+palette. Select only preinstalledthemes with `set_agent_cursor_theme`; theme source paths and inline animationdata are never accepted through an agent tool. Use the trusted local`cua-driver cursor-theme` workflow to validate, compile, preview, install,diff --git a/libs/cua-driver/rust/crates/cursor-overlay/assets/README.md b/libs/cua-driver/rust/crates/cursor-overlay/assets/README.mdnew file mode 100644index 0000000000..2629823d76--- /dev/null+++ b/libs/cua-driver/rust/crates/cursor-overlay/assets/README.md@@ -0,0 +1,31 @@+# Embedded default cursor theme++`cua.default.lottie` is the canonical source archive for Cua Driver's built-in+cursor. `cua.default.cua-theme` is the bounded runtime artifact compiled from+that archive.++The privileged overlay embeds and decodes only the `.cua-theme` artifact. It+never parses dotLottie ZIP files or Lottie JSON at runtime. The artifact+contains bounded vector geometry, paints, transforms, and sampled animation+frames rather than a fixed-resolution pixel atlas. Skia rasterizes those+commands at the live display backing scale.++Regenerate both files from the Rust workspace:++```bash+python3 crates/cursor-overlay/assets/build_default_theme.py+cargo run -p cursor-theme-cli -- build \+ crates/cursor-overlay/assets/cua.default.lottie \+ --output crates/cursor-overlay/assets/cua.default.cua-theme+cargo run -p cursor-theme-cli -- inspect \+ crates/cursor-overlay/assets/cua.default.cua-theme+```++The Python generator uses only the standard library and writes deterministic+ZIP metadata and entry ordering. A Rust test verifies that the source hash+inside the compiled artifact matches the checked-in `.lottie` bytes.++The source uses Cua blue as a palette key and white for outlines. At runtime,+only the embedded default is recolored to the stable session fill. Installed+custom themes retain their authored colors. The shared floating motion is+applied after compositing so action and modifier layers remain synchronized.diff --git a/libs/cua-driver/rust/crates/cursor-overlay/assets/build_default_theme.py b/libs/cua-driver/rust/crates/cursor-overlay/assets/build_default_theme.pynew file mode 100644index 0000000000..759842fb30--- /dev/null+++ b/libs/cua-driver/rust/crates/cursor-overlay/assets/build_default_theme.py@@ -0,0 +1,769 @@+#!/usr/bin/env python3+"""Build the deterministic dotLottie source archive for ``cua.default``.++The checked-in ``cua.default.lottie`` is the canonical authoring artifact used+to produce the embedded ``cua.default.cua-theme``. This script deliberately+uses only Python's standard library so contributors can reproduce the source+archive without a LottieFiles account or a browser editor.++The runtime applies two bounded effects after decoding the compiled theme:++* the approved blue tint key is replaced with the stable session color;+* the shared four-second float transform is applied to the composed theme.++Those effects are runtime concerns because they must stay synchronized across+the action, delivery, and target layers.+"""++from __future__ import annotations++import argparse+import json+from pathlib import Path+from typing import Any, Iterable, Sequence+from zipfile import ZIP_DEFLATED, ZipFile, ZipInfo++CANVAS = 128+FPS = 30+BLUE = [94 / 255, 192 / 255, 232 / 255, 1]+WHITE = [1, 1, 1, 1]+TRANSPARENT = [0, 0, 0, 0]++Point = tuple[float, float]+PathPoint = tuple[Point, Point, Point]+++def static(value: Any) -> dict[str, Any]:+ return {"a": 0, "k": value}+++def _value(value: Any) -> list[float]:+ if isinstance(value, (int, float)):+ return [value]+ return list(value)+++def animated(+ values: Sequence[tuple[int, Any]],+ *,+ linear: bool = False,+) -> dict[str, Any]:+ frames: list[dict[str, Any]] = []+ for index, (frame, value) in enumerate(values):+ item: dict[str, Any] = {"t": frame, "s": _value(value)}+ if index + 1 < len(values):+ item["e"] = _value(values[index + 1][1])+ if linear:+ item["i"] = {"x": [0.833], "y": [0.833]}+ item["o"] = {"x": [0.167], "y": [0.167]}+ else:+ item["i"] = {"x": [0.25], "y": [1.0]}+ item["o"] = {"x": [0.2], "y": [0.75]}+ frames.append(item)+ return {"a": 1, "k": frames}+++def path_shape(+ points: Sequence[PathPoint],+ *,+ closed: bool = False,+ name: str = "Path",+) -> dict[str, Any]:+ return {+ "ty": "sh",+ "nm": name,+ "ks": {+ "a": 0,+ "k": {+ "i": [[point[1][0], point[1][1]] for point in points],+ "o": [[point[2][0], point[2][1]] for point in points],+ "v": [[point[0][0], point[0][1]] for point in points],+ "c": closed,+ },+ },+ }+++def points(coordinates: Sequence[Point], *, closed: bool = False, name: str = "Path") -> dict[str, Any]:+ return path_shape(+ [((x, y), (0, 0), (0, 0)) for x, y in coordinates],+ closed=closed,+ name=name,+ )+++def ellipse(x: float, y: float, width: float, height: float, *, name: str) -> dict[str, Any]:+ return {+ "ty": "el",+ "nm": name,+ "p": static([x, y]),+ "s": static([width, height]),+ "d": 1,+ }+++def rectangle(+ x: float,+ y: float,+ width: float,+ height: float,+ *,+ roundness: float = 0,+ name: str,+) -> dict[str, Any]:+ return {+ "ty": "rc",+ "nm": name,+ "p": static([x, y]),+ "s": static([width, height]),+ "r": static(roundness),+ "d": 1,+ }+++def stroke(color: list[float], width: float, opacity: float = 100) -> dict[str, Any]:+ return {+ "ty": "st",+ "c": static(color),+ "o": static(opacity),+ "w": static(width),+ "lc": 2,+ "lj": 2,+ "ml": 4,+ }+++def fill(color: list[float], opacity: float = 100) -> dict[str, Any]:+ return {"ty": "fl", "c": static(color), "o": static(opacity), "r": 1}+++def shape_transform() -> dict[str, Any]:+ return {+ "ty": "tr",+ "p": static([0, 0]),+ "a": static([0, 0]),+ "s": static([100, 100]),+ "r": static(0),+ "o": static(100),+ "sk": static(0),+ "sa": static(0),+ }+++def layer_transform(+ *,+ position: dict[str, Any] | None = None,+ scale: dict[str, Any] | None = None,+ rotation: dict[str, Any] | None = None,+ opacity: dict[str, Any] | None = None,+) -> dict[str, Any]:+ return {+ "o": opacity or static(100),+ "r": rotation or static(0),+ "p": position or static([64, 64]),+ "a": static([64, 64]),+ "s": scale or static([100, 100]),+ }+++def shape_layer(+ index: int,+ name: str,+ shapes: Sequence[dict[str, Any]],+ frames: int,+ *,+ position: dict[str, Any] | None = None,+ scale: dict[str, Any] | None = None,+ rotation: dict[str, Any] | None = None,+ opacity: dict[str, Any] | None = None,+) -> dict[str, Any]:+ return {+ "ddd": 0,+ "ind": index,+ "ty": 4,+ "nm": name,+ "sr": 1,+ "ks": layer_transform(+ position=position,+ scale=scale,+ rotation=rotation,+ opacity=opacity,+ ),+ "ao": 0,+ "shapes": [*shapes, shape_transform()],+ "ip": 0,+ "op": frames,+ "st": 0,+ "bm": 0,+ }+++CURSOR_PATH = path_shape(+ [+ ((55, 30), (0, 0), (-7, -2)),+ ((43, 41), (-1, -8), (0, 0)),+ ((64, 98), (0, 0), (3, 8)),+ ((77, 99), (-4, 7), (0, 0)),+ ((86, 79), (0, 0), (2, -4)),+ ((95, 70), (-4, 2), (0, 0)),+ ((108, 63), (0, 0), (7, -4)),+ ((107, 50), (7, 3), (0, 0)),+ ],+ closed=True,+ name="Cursor",+)+++def cursor_layers(+ frames: int,+ *,+ position: dict[str, Any] | None = None,+ scale: dict[str, Any] | None = None,+) -> list[dict[str, Any]]:+ layers: list[dict[str, Any]] = []+ index = 1+ for width, opacity in [+ (44, 2.0),+ (36, 2.4),+ (29, 3.0),+ (23, 3.8),+ (18, 4.8),+ (14, 6.0),+ (10, 7.5),+ (7, 9.5),+ ]:+ layers.append(+ shape_layer(+ index,+ f"Cursor glow {width}",+ [CURSOR_PATH, stroke(BLUE, width, opacity)],+ frames,+ position=position,+ scale=scale,+ )+ )+ index += 1+ layers.append(+ shape_layer(+ index,+ "Cursor body",+ [CURSOR_PATH, fill(BLUE), stroke(WHITE, 5)],+ frames,+ position=position,+ scale=scale,+ )+ )+ return layers+++def cue_layers(+ start_index: int,+ name: str,+ geometry: Sequence[dict[str, Any]],+ frames: int,+ *,+ width: float = 4,+ position: dict[str, Any] | None = None,+ scale: dict[str, Any] | None = None,+ rotation: dict[str, Any] | None = None,+ opacity: dict[str, Any] | None = None,+) -> list[dict[str, Any]]:+ layers: list[dict[str, Any]] = []+ index = start_index+ for expansion, glow_opacity in [(13, 2.4), (9, 3.1), (6, 4.0), (3, 5.2)]:+ layers.append(+ shape_layer(+ index,+ f"{name} glow {expansion}",+ [*geometry, stroke(BLUE, width + expansion, glow_opacity)],+ frames,+ position=position,+ scale=scale,+ rotation=rotation,+ opacity=opacity,+ )+ )+ index += 1+ layers.append(+ shape_layer(+ index,+ f"{name} outline",+ [*geometry, stroke(WHITE, width + 1.5)],+ frames,+ position=position,+ scale=scale,+ rotation=rotation,+ opacity=opacity,+ )+ )+ index += 1+ layers.append(+ shape_layer(+ index,+ f"{name} color",+ [*geometry, stroke(BLUE, max(width - 1, 1.5))],+ frames,+ position=position,+ scale=scale,+ rotation=rotation,+ opacity=opacity,+ )+ )+ return layers+++def lottie(name: str, frames: int, layers: Sequence[dict[str, Any]]) -> dict[str, Any]:+ return {+ "v": "5.12.2",+ "fr": FPS,+ "ip": 0,+ "op": frames,+ "w": CANVAS,+ "h": CANVAS,+ "nm": name,+ "ddd": 0,+ "assets": [],+ "layers": list(reversed(layers)),+ "markers": [],+ }+++def action_idle() -> dict[str, Any]:+ return lottie("action_idle", 1, cursor_layers(1))+++def action_observe() -> dict[str, Any]:+ frames = 48+ geometry = [+ path_shape(+ [+ ((38, 28), (0, 0), (-11, 1)),+ ((20, 49), (0, -11), (0, 0)),+ ],+ name="Observe inner",+ ),+ path_shape(+ [+ ((42, 19), (0, 0), (-19, 0)),+ ((11, 51), (0, -18), (0, 0)),+ ],+ name="Observe outer",+ ),+ ]+ cue = cue_layers(+ 20,+ "Observe",+ geometry,+ frames,+ position=static([72, 54]),+ scale=animated([(0, [88, 88]), (24, [100, 100]), (48, [108, 108])]),+ opacity=animated([(0, 0), (7, 100), (34, 100), (44, 0), (48, 0)]),+ )+ return lottie("action_observe", frames, [*cursor_layers(frames), *cue])+++def action_click() -> dict[str, Any]:+ frames = 20+ geometry = [+ points([(35, 20), (34, 11)], name="Click upper"),+ points([(27, 25), (19, 19)], name="Click middle"),+ points([(25, 34), (15, 34)], name="Click lower"),+ ]+ cursor_scale = animated(+ [(0, [100, 100]), (7, [93, 93]), (12, [103, 103]), (20, [100, 100])]+ )+ cue = cue_layers(+ 20,+ "Click",+ geometry,+ frames,+ position=static([74, 67]),+ scale=animated([(0, [110, 110]), (8, [130, 130]), (20, [150, 150])]),+ opacity=animated([(0, 0), (4, 100), (11, 100), (20, 0)]),+ )+ return lottie(+ "action_click",+ frames,+ [*cursor_layers(frames, scale=cursor_scale), *cue],+ )+++def action_drag() -> dict[str, Any]:+ frames = 48+ movement = animated(+ [(0, [64, 64]), (8, [64, 64]), (30, [71, 67]), (40, [71, 67]), (48, [64, 64])]+ )+ geometry = [+ points([(28, 38), (16, 35)], name="Drag upper"),+ points([(26, 48), (12, 45)], name="Drag lower"),+ ]+ cue = cue_layers(+ 20,+ "Drag",+ geometry,+ frames,+ position=movement,+ opacity=animated([(0, 20), (15, 100), (36, 100), (48, 20)]),+ )+ return lottie(+ "action_drag",+ frames,+ [*cursor_layers(frames, position=movement), *cue],+ )+++def action_scroll() -> dict[str, Any]:+ frames = 48+ geometry = [+ points([(23, 31), (31, 22), (39, 31)], name="Scroll up"),+ points([(23, 49), (31, 58), (39, 49)], name="Scroll down"),+ ]+ cue = cue_layers(+ 20,+ "Scroll",+ geometry,+ frames,+ position=animated([(0, [59, 68]), (24, [59, 60]), (48, [59, 68])]),+ opacity=animated([(0, 42), (24, 100), (48, 42)]),+ )+ return lottie("action_scroll", frames, [*cursor_layers(frames), *cue])+++def action_text() -> dict[str, Any]:+ frames = 48+ geometry = [+ points([(31, 22), (31, 58)], name="Text stem"),+ points([(24, 22), (38, 22)], name="Text top"),+ points([(24, 58), (38, 58)], name="Text bottom"),+ ]+ cue = cue_layers(+ 20,+ "Text",+ geometry,+ frames,+ position=static([60, 64]),+ opacity=animated(+ [(0, 100), (16, 100), (17, 18), (30, 18), (31, 100), (48, 100)],+ linear=True,+ ),+ )+ return lottie("action_text", frames, [*cursor_layers(frames), *cue])+++def action_key() -> dict[str, Any]:+ frames = 48+ geometry = [+ rectangle(28, 39, 28, 28, roundness=6, name="Key cap"),+ points([(23, 32), (23, 46)], name="Key stem"),+ points([(24, 39), (33, 32)], name="Key upper"),+ points([(25, 39), (34, 46)], name="Key lower"),+ ]+ cue = cue_layers(+ 20,+ "Key",+ geometry,+ frames,+ width=3.5,+ position=animated([(0, [55, 64]), (8, [55, 67]), (17, [55, 63]), (26, [55, 64]), (48, [55, 64])]),+ scale=animated([(0, [100, 100]), (8, [92, 92]), (17, [103, 103]), (26, [100, 100]), (48, [100, 100])]),+ opacity=animated([(0, 0), (4, 100), (30, 100), (42, 0), (48, 0)]),+ )+ return lottie("action_key", frames, [*cursor_layers(frames), *cue])+++def action_navigate() -> dict[str, Any]:+ frames = 48+ geometry = [+ points([(15, 29), (25, 40), (15, 51)], name="Navigate first"),+ points([(29, 29), (39, 40), (29, 51)], name="Navigate second"),+ ]+ cue = cue_layers(+ 20,+ "Navigate",+ geometry,+ frames,+ position=animated([(0, [54, 64]), (18, [59, 64]), (30, [63, 64]), (48, [63, 64])]),+ opacity=animated([(0, 0), (8, 100), (28, 100), (42, 0), (48, 0)]),+ )+ return lottie("action_navigate", frames, [*cursor_layers(frames), *cue])+++def action_app() -> dict[str, Any]:+ frames = 48+ geometry = [+ rectangle(x, y, 10, 10, roundness=2, name=f"App {x} {y}")+ for x, y in [(18, 31), (34, 31), (18, 47), (34, 47)]+ ]+ cue = cue_layers(+ 20,+ "App",+ geometry,+ frames,+ width=3.5,+ position=static([59, 64]),+ scale=animated([(0, [20, 20]), (14, [112, 112]), (24, [100, 100]), (48, [100, 100])]),+ opacity=animated([(0, 0), (8, 100), (34, 100), (44, 0), (48, 0)]),+ )+ return lottie("action_app", frames, [*cursor_layers(frames), *cue])+++def action_transfer() -> dict[str, Any]:+ frames = 48+ geometry = [+ points([(22, 50), (22, 20), (14, 28), (22, 20), (30, 28)], name="Transfer up"),+ points([(37, 28), (37, 58), (29, 50), (37, 58), (45, 50)], name="Transfer down"),+ ]+ cue = cue_layers(+ 20,+ "Transfer",+ geometry,+ frames,+ position=animated([(0, [55, 70]), (24, [55, 58]), (48, [55, 70])]),+ opacity=animated([(0, 38), (24, 100), (48, 38)]),+ )+ return lottie("action_transfer", frames, [*cursor_layers(frames), *cue])+++def action_record() -> dict[str, Any]:+ frames = 48+ ring = cue_layers(+ 20,+ "Record ring",+ [ellipse(29, 39, 34, 34, name="Record ring")],+ frames,+ position=static([52, 64]),+ )+ dot_scale = animated([(0, [72, 72]), (24, [114, 114]), (48, [72, 72])])+ dot_opacity = animated([(0, 42), (24, 100), (48, 42)])+ dot_geometry = [ellipse(29, 39, 10, 10, name="Record dot")]+ dot = [+ shape_layer(+ 30,+ "Record dot outline",+ [*dot_geometry, fill(BLUE), stroke(WHITE, 3)],+ frames,+ position=static([52, 64]),+ scale=dot_scale,+ opacity=dot_opacity,+ )+ ]+ return lottie("action_record", frames, [*cursor_layers(frames), *ring, *dot])+++def action_system() -> dict[str, Any]:+ frames = 48+ geometry = [+ ellipse(29, 39, 24, 24, name="System outer"),+ ellipse(29, 39, 8, 8, name="System inner"),+ *[+ points(coordinates, name=f"System tooth {index}")+ for index, coordinates in enumerate(+ [+ [(29, 20), (29, 25)],+ [(29, 53), (29, 58)],+ [(10, 39), (15, 39)],+ [(43, 39), (48, 39)],+ [(16, 26), (20, 30)],+ [(38, 48), (42, 52)],+ [(16, 52), (20, 48)],+ [(38, 30), (42, 26)],+ ]+ )+ ],+ ]+ cue = cue_layers(+ 20,+ "System",+ geometry,+ frames,+ width=3.5,+ position=static([50, 64]),+ rotation=animated([(0, -18), (22, 50), (34, 0), (48, 0)]),+ opacity=animated([(0, 0), (6, 100), (34, 100), (44, 0), (48, 0)]),+ )+ return lottie("action_system", frames, [*cursor_layers(frames), *cue])+++def modifier_layers(name: str, geometry: Sequence[dict[str, Any]], *, width: float = 2.5) -> dict[str, Any]:+ return lottie(+ f"modifier_{name}",+ 1,+ cue_layers(1, name.title(), geometry, 1, width=width),+ )+++def modifier_background() -> dict[str, Any]:+ dots = [+ ellipse(x, y, 3, 3, name=f"Background dot {index}")+ for index, (x, y) in enumerate(+ [(34, 23), (27, 28), (22, 35), (19, 44), (20, 54), (22, 64), (26, 74), (32, 84), (39, 94), (48, 102)]+ )+ ]+ layers = [+ shape_layer(1, "Background outline", [*dots, fill(WHITE)], 1),+ shape_layer(2, "Background color", [*dots, fill(BLUE)], 1, scale=static([62, 62])),+ ]+ return lottie("modifier_background", 1, layers)+++def modifier_foreground() -> dict[str, Any]:+ return modifier_layers("foreground", [ellipse(25, 90, 18, 18, name="Foreground ring")], width=3)+++def modifier_ax() -> dict[str, Any]:+ geometry = [+ ellipse(x, y, 6, 6, name=f"AX node {index}")+ for index, (x, y) in enumerate([(104, 89), (94, 104), (114, 104)])+ ]+ geometry.extend(+ [+ points([(104, 92), (104, 97), (94, 101)], name="AX left"),+ points([(104, 97), (114, 101)], name="AX right"),+ ]+ )+ return modifier_layers("ax", geometry)+++def modifier_pixel() -> dict[str, Any]:+ geometry = [+ points(segment, name=f"Pixel segment {index}")+ for index, segment in enumerate(+ [+ [(94, 91), (100, 91)],+ [(106, 91), (113, 91)],+ [(113, 91), (113, 98)],+ [(113, 104), (113, 110)],+ [(113, 110), (106, 110)],+ [(100, 110), (94, 110)],+ [(94, 110), (94, 104)],+ [(94, 98), (94, 91)],+ ]+ )+ ]+ return modifier_layers("pixel", geometry)+++def modifier_browser() -> dict[str, Any]:+ geometry = [+ ellipse(104, 100, 20, 20, name="Browser globe"),+ points([(94, 100), (114, 100)], name="Browser equator"),+ points([(104, 90), (100, 100), (104, 110)], name="Browser left"),+ points([(104, 90), (108, 100), (104, 110)], name="Browser right"),+ ]+ return modifier_layers("browser", geometry)+++def modifier_desktop() -> dict[str, Any]:+ geometry = [+ rectangle(103.5, 97.5, 21, 15, roundness=2, name="Desktop screen"),+ points([(103.5, 105), (103.5, 110), (97, 110), (110, 110)], name="Desktop stand"),+ ]+ return modifier_layers("desktop", geometry)+++def all_animations() -> dict[str, dict[str, Any]]:+ actions = {+ "action_idle": action_idle(),+ "action_observe": action_observe(),+ "action_click": action_click(),+ "action_drag": action_drag(),+ "action_scroll": action_scroll(),+ "action_text": action_text(),+ "action_key": action_key(),+ "action_navigate": action_navigate(),+ "action_app": action_app(),+ "action_transfer": action_transfer(),+ "action_record": action_record(),+ "action_system": action_system(),+ }+ modifiers = {+ "modifier_background": modifier_background(),+ "modifier_foreground": modifier_foreground(),+ "modifier_ax": modifier_ax(),+ "modifier_pixel": modifier_pixel(),+ "modifier_browser": modifier_browser(),+ "modifier_desktop": modifier_desktop(),+ }+ return {**actions, **modifiers}+++def semantic_manifest() -> dict[str, Any]:+ actions = {+ name: {"animation": f"action_{name}", "still_frame": 0 if name == "idle" else 8}+ for name in [+ "idle",+ "observe",+ "click",+ "drag",+ "scroll",+ "text",+ "key",+ "navigate",+ "app",+ "transfer",+ "record",+ "system",+ ]+ }+ actions["click"]["still_frame"] = 8+ return {+ "schema": "cua.cursor-theme/1",+ "id": "cua.default",+ "name": "Cua Default",+ "version": "1.0.0",+ "author": "Cua",+ "license": "MIT",+ "compatibility": {"profile": "cua-driver-full-v1", "semantics": 1},+ "canvas": {"width": CANVAS, "height": CANVAS, "fps": FPS},+ "hotspot": {"x": 55, "y": 30},+ "actions": actions,+ "modifiers": {+ name: {"animation": f"modifier_{name}", "still_frame": 0}+ for name in ["background", "foreground", "ax", "pixel", "browser", "desktop"]+ },+ }+++def encoded_json(value: Any) -> bytes:+ return (json.dumps(value, sort_keys=True, separators=(",", ":")) + "\n").encode()+++def write_entry(archive: ZipFile, name: str, data: bytes) -> None:+ info = ZipInfo(name, date_time=(1980, 1, 1, 0, 0, 0))+ info.compress_type = ZIP_DEFLATED+ info.external_attr = 0o100644 << 16+ archive.writestr(info, data, compresslevel=9)+++def build(output: Path) -> None:+ animations = all_animations()+ standard_manifest = {+ "version": "2",+ "generator": "Cua Driver default cursor generator",+ "animations": [+ {"id": animation_id, "name": animation_id}+ for animation_id in animations+ ],+ }+ output.parent.mkdir(parents=True, exist_ok=True)+ with ZipFile(output, "w") as archive:+ write_entry(archive, "manifest.json", encoded_json(standard_manifest))+ write_entry(archive, "cua/theme.json", encoded_json(semantic_manifest()))+ for animation_id, animation in animations.items():+ write_entry(archive, f"a/{animation_id}.json", encoded_json(animation))+++def main() -> None:+ parser = argparse.ArgumentParser()+ parser.add_argument(+ "--output",+ type=Path,+ default=Path(__file__).with_name("cua.default.lottie"),+ )+ args = parser.parse_args()+ build(args.output.resolve())+ print(args.output.resolve())+++if __name__ == "__main__":+ main()diff --git a/libs/cua-driver/rust/crates/cursor-overlay/assets/cua.default.cua-theme b/libs/cua-driver/rust/crates/cursor-overlay/assets/cua.default.cua-themenew file mode 100644index 0000000000..f37618bd46Binary files /dev/null and b/libs/cua-driver/rust/crates/cursor-overlay/assets/cua.default.cua-theme differdiff --git a/libs/cua-driver/rust/crates/cursor-overlay/assets/cua.default.lottie b/libs/cua-driver/rust/crates/cursor-overlay/assets/cua.default.lottienew file mode 100644index 0000000000..d0bf16bd37Binary files /dev/null and b/libs/cua-driver/rust/crates/cursor-overlay/assets/cua.default.lottie differdiff --git a/libs/cua-driver/rust/crates/cursor-overlay/examples/export_gallery_frames.rs b/libs/cua-driver/rust/crates/cursor-overlay/examples/export_gallery_frames.rsnew file mode 100644index 0000000000..b500987fed--- /dev/null+++ b/libs/cua-driver/rust/crates/cursor-overlay/examples/export_gallery_frames.rs@@ -0,0 +1,114 @@+use cursor_overlay::{+ theme::paint_default_theme, CursorAction, CursorVisualState, DeliveryModifier, ReducedMotion,+ TargetModifier,+};+use std::{fs, path::Path};+use tiny_skia::Pixmap;++const SIZE: u32 = 256;+const FPS: u32 = 30;+const DURATION_SECS: u32 = 4;+const PREVIEW_BACKING_SCALE: f32 = 1.5;++fn main() {+ let output = std::env::args()+ .nth(1)+ .expect("usage: export_gallery_frames <output-directory>");+ let output = Path::new(&output);++ let mut states = Vec::new();+ for action in CursorAction::ALL {+ states.push((+ output.join("actions").join(action.as_str()),+ action,+ None,+ None,+ ));+ }++ for (name, delivery, target) in [+ ("background", Some(DeliveryModifier::Background), None),+ ("foreground", Some(DeliveryModifier::Foreground), None),+ ("ax", None, Some(TargetModifier::Ax)),+ ("pixel", None, Some(TargetModifier::Pixel)),+ ("browser", None, Some(TargetModifier::Browser)),+ ("desktop", None, Some(TargetModifier::Desktop)),+ ] {+ states.push((+ output.join("modifiers").join(name),+ CursorAction::Idle,+ delivery,+ target,+ ));+ }++ states.push((+ output.join("combined").join("foreground-pixel-click"),+ CursorAction::Click,+ Some(DeliveryModifier::Foreground),+ Some(TargetModifier::Pixel),+ ));++ std::thread::scope(|scope| {+ for (path, action, delivery, target) in states {+ scope.spawn(move || export_state(&path, action, delivery, target));+ }+ });+}++fn export_state(+ output: &Path,+ action: CursorAction,+ delivery: Option<DeliveryModifier>,+ target: Option<TargetModifier>,+) {+ fs::create_dir_all(output).expect("create frame output");+ for frame in 0..FPS * DURATION_SECS {+ let mut pixmap = Pixmap::new(SIZE, SIZE).expect("create frame");+ let visual = CursorVisualState {+ requested_action: action,+ resolved_action: action,+ delivery,+ target,+ elapsed_secs: f64::from(frame) / f64::from(FPS),+ ending_secs: None,+ reduced_motion: ReducedMotion::Off,+ preempted_count: 0,+ };+ paint_default_theme(+ &mut pixmap,+ &visual,+ SIZE as f32 / 2.0,+ SIZE as f32 / 2.0,+ std::f32::consts::FRAC_PI_4,+ PREVIEW_BACKING_SCALE,+ 1.0,+ );+ let pixels = unpremultiply_rgba(pixmap.data().to_vec());+ image::save_buffer_with_format(+ output.join(format!("{frame:04}.png")),+ &pixels,+ SIZE,+ SIZE,+ image::ColorType::Rgba8,+ image::ImageFormat::Png,+ )+ .expect("write frame");+ }+}++fn unpremultiply_rgba(mut pixels: Vec<u8>) -> Vec<u8> {+ for pixel in pixels.chunks_exact_mut(4) {+ let alpha = u16::from(pixel[3]);+ if alpha == 0 {+ pixel[0] = 0;+ pixel[1] = 0;+ pixel[2] = 0;+ continue;+ }+ pixel[0] = ((u16::from(pixel[0]) * 255 + alpha / 2) / alpha).min(255) as u8;+ pixel[1] = ((u16::from(pixel[1]) * 255 + alpha / 2) / alpha).min(255) as u8;+ pixel[2] = ((u16::from(pixel[2]) * 255 + alpha / 2) / alpha).min(255) as u8;+ }+ pixels+}diff --git a/libs/cua-driver/rust/crates/cursor-overlay/src/lib.rs b/libs/cua-driver/rust/crates/cursor-overlay/src/lib.rsindex 79b276d4f9..a4cce20406 100644--- a/libs/cua-driver/rust/crates/cursor-overlay/src/lib.rs+++ b/libs/cua-driver/rust/crates/cursor-overlay/src/lib.rs@@ -21,13 +21,16 @@ pub use motion::{MotionConfig, Spring};pub use path_planner::{PathPlanner, PathState, PlannedPath};pub use render_state::{paint_cursor, render_frame, FocusRect, RenderStateCore};pub use theme::{- CursorAction, CursorVisualState, DeliveryModifier, PlaybackKind, ReducedMotion, TargetModifier,- DEFAULT_THEME_ID, DEFAULT_THEME_VERSION, THEME_PROFILE,+ session_fill_hex, session_fill_rgba, CursorAction, CursorVisualState, DeliveryModifier,+ PlaybackKind, ReducedMotion, TargetModifier, DEFAULT_CURSOR_FILL, DEFAULT_THEME_ID,+ DEFAULT_THEME_VERSION, THEME_PROFILE,};pub use theme_artifact::{- decode_theme, inspect_artifact, list_installed_themes, load_installed_theme,- paint_compiled_theme, resolve_theme_selection, theme_store_root, validate_compiled_theme,- CompiledAnimation, CompiledFrame, CompiledTheme,+ decode_theme, embedded_default_theme, inspect_artifact, list_installed_themes,+ load_installed_theme, paint_compiled_theme, paint_compiled_theme_with_tint,+ resolve_theme_selection, theme_store_root, validate_compiled_theme, CompiledAnimation,+ CompiledDrawCommand, CompiledFrame, CompiledGeometry, CompiledStroke, CompiledTheme,+ CompiledTransform,};#[cfg(feature = "theme-authoring")]pub use theme_artifact::{encode_theme, install_artifact, uninstall_theme};diff --git a/libs/cua-driver/rust/crates/cursor-overlay/src/render_state.rs b/libs/cua-driver/rust/crates/cursor-overlay/src/render_state.rsindex 1a0ac8fdcf..dd5f549f56 100644--- a/libs/cua-driver/rust/crates/cursor-overlay/src/render_state.rs+++ b/libs/cua-driver/rust/crates/cursor-overlay/src/render_state.rs@@ -67,7 +67,7 @@ pub struct RenderStateCore {pub pressed: bool,/// Semantic action and animation playback state.pub visual: CursorVisualState,- /// Decoded installed theme. `None` selects the embedded `cua.default`.+ /// Decoded installed or embedded theme.pub theme: Option<Arc<CompiledTheme>>,/// Non-fatal launch-time fallback reason, if an installed theme failed.pub theme_fallback: Option<String>,@@ -93,7 +93,7 @@ impl RenderStateCore {let (theme, theme_fallback) = match crate::load_installed_theme(&cfg.theme_id) {Ok(theme) => (theme, None),Err(error) => (- None,+ Some(crate::embedded_default_theme()),Some(format!("theme `{}` could not be loaded; using {}: {error}",cfg.theme_id,@@ -679,7 +679,9 @@ pub fn paint_cursor(}if let Some(theme) = core.theme.as_deref() {- crate::paint_compiled_theme(+ let tint = (theme.id == crate::DEFAULT_THEME_ID)+ .then(|| crate::session_fill_rgba(&core.cfg.cursor_id));+ crate::paint_compiled_theme_with_tint(pm,theme,&core.visual,@@ -688,9 +690,13 @@ pub fn paint_cursor(heading as f32,backing_scale.max(1.0),alpha_scale,+ tint,);} else {- crate::theme::paint_default_theme(+ // Defensive fallback for a manually constructed RenderStateCore. The+ // normal constructor always resolves either the requested theme or the+ // embedded default.+ crate::theme::paint_default_theme_with_fill(pm,&core.visual,px as f32,@@ -698,6 +704,7 @@ pub fn paint_cursor(heading as f32,backing_scale.max(1.0),alpha_scale,+ crate::session_fill_rgba(&core.cfg.cursor_id),);}}@@ -767,10 +774,31 @@ mod backing_scale_tests {use super::*;use crate::CursorConfig;- /// Count opaque (alpha > 0) pixels in the pixmap — a proxy for the- /// cursor's on-pixmap footprint that's independent of palette / gradient.- fn opaque_pixel_count(pm: &tiny_skia::Pixmap) -> u32 {- pm.data().chunks_exact(4).filter(|px| px[3] > 0).count() as u32+ fn visible_pixel_count(pm: &tiny_skia::Pixmap) -> u32 {+ // Count strongly visible coverage, not the halo's feather pixels.+ // Low-alpha gradient coverage is quantized differently across scales+ // and is not useful evidence for the backing-scale regression.+ pm.data().chunks_exact(4).filter(|px| px[3] > 96).count() as u32+ }++ fn visible_bounds(pm: &tiny_skia::Pixmap) -> (u32, u32) {+ let mut min_x = u32::MAX;+ let mut min_y = u32::MAX;+ let mut max_x = 0;+ let mut max_y = 0;+ for (index, pixel) in pm.data().chunks_exact(4).enumerate() {+ if pixel[3] <= 96 {+ continue;+ }+ let x = index as u32 % pm.width();+ let y = index as u32 / pm.width();+ min_x = min_x.min(x);+ min_y = min_y.min(y);+ max_x = max_x.max(x);+ max_y = max_y.max(y);+ }+ assert_ne!(min_x, u32::MAX, "render should have visible pixels");+ (max_x - min_x + 1, max_y - min_y + 1)}fn render_at(backing_scale: f32, logical_size: u32) -> tiny_skia::Pixmap {@@ -791,32 +819,51 @@ mod backing_scale_tests {pm}- /// Doubling `backing_scale` doubles every linear dimension of the cursor's- /// pixel footprint, so the opaque-pixel COUNT should grow ~4× (one factor- /// of 2 per axis). Exact equality isn't expected — the embedded SVG- /// downscales from a 52-px source, anti-aliased edges round at integer- /// boundaries, and the bloom gradient has a soft cutoff — but the ratio- /// should sit clearly above 3.0 (well past the ~2.0 ceiling we'd hit if- /// only one dimension were scaling). This is the regression guard for- /// the retina-blur fix: if a future refactor reverts paint_cursor to- /// emitting logical-pixel art into a physical-pixel pixmap, the ratio- /// collapses back toward 1.0.+ /// The compiled artifact contains vector geometry. Skia must rasterize it+ /// at the destination backing scale, so linear dimensions grow 1:2:3 and+ /// strongly visible coverage grows approximately with the square.#[test]- fn backing_scale_two_grows_opaque_footprint_roughly_fourfold() {+ fn compiled_vectors_render_at_one_two_and_three_x() {let pm_1x = render_at(1.0, 200);let pm_2x = render_at(2.0, 200);+ let pm_3x = render_at(3.0, 200);- let n_1x = opaque_pixel_count(&pm_1x);- let n_2x = opaque_pixel_count(&pm_2x);+ let n_1x = visible_pixel_count(&pm_1x);+ let n_2x = visible_pixel_count(&pm_2x);+ let n_3x = visible_pixel_count(&pm_3x);assert!(n_1x > 0, "1× render should paint SOMETHING (got {n_1x})");assert!(n_2x > 0, "2× render should paint SOMETHING (got {n_2x})");+ assert!(n_3x > 0, "3× render should paint SOMETHING (got {n_3x})");- let ratio = n_2x as f64 / n_1x as f64;+ let ratio_2x = n_2x as f64 / n_1x as f64;+ let ratio_3x = n_3x as f64 / n_1x as f64;+ assert!(+ ratio_2x > 3.0 && ratio_2x < 5.0,+ "2× backing_scale should produce ~4× more visible pixels: \+ got n_1x={n_1x}, n_2x={n_2x}, ratio={ratio_2x:.2}"+ );assert!(- ratio > 3.0 && ratio < 5.0,- "2× backing_scale should produce ~4× more opaque pixels — \- got n_1x={n_1x}, n_2x={n_2x}, ratio={ratio:.2}"+ ratio_3x > 7.0 && ratio_3x < 11.0,+ "3× backing_scale should produce ~9× more visible pixels: \+ got n_1x={n_1x}, n_3x={n_3x}, ratio={ratio_3x:.2}");++ let bounds_1x = visible_bounds(&pm_1x);+ let bounds_2x = visible_bounds(&pm_2x);+ let bounds_3x = visible_bounds(&pm_3x);+ for (one, two, three) in [+ (bounds_1x.0, bounds_2x.0, bounds_3x.0),+ (bounds_1x.1, bounds_2x.1, bounds_3x.1),+ ] {+ assert!(+ (two as f64 / one as f64 - 2.0).abs() < 0.15,+ "2× visible bounds should double: {one}, {two}"+ );+ assert!(+ (three as f64 / one as f64 - 3.0).abs() < 0.20,+ "3× visible bounds should triple: {one}, {three}"+ );+ }}}diff --git a/libs/cua-driver/rust/crates/cursor-overlay/src/theme.rs b/libs/cua-driver/rust/crates/cursor-overlay/src/theme.rsindex 86b023249a..32950d6401 100644--- a/libs/cua-driver/rust/crates/cursor-overlay/src/theme.rs+++ b/libs/cua-driver/rust/crates/cursor-overlay/src/theme.rs@@ -1,11 +1,11 @@-//! Canonical cursor-theme semantics and the embedded `cua.default` renderer.+//! Canonical cursor-theme semantics and `cua.default` runtime parameters.//!-//! The default artwork was authored as Lottie on a 128×128 canvas. Production-//! rendering uses this bounded vector representation so the privileged overlay-//! never parses Lottie, ZIP, fonts, scripts, images, or network references.+//! The default artwork is authored as a checked-in dotLottie archive and+//! compiled into the bounded artifact embedded by [`crate::theme_artifact`].+//! This module owns transport-neutral state, session colors, and the shared+//! runtime float transform. It does not parse Lottie at runtime.use serde::{Deserialize, Serialize};-use tiny_skia::{Color, FillRule, Paint, Path, PathBuilder, Stroke, Transform};pub use cua_driver_contract::{CursorAction, CursorDelivery as DeliveryModifier, CursorPlayback as PlaybackKind,@@ -16,14 +16,65 @@ pub const DEFAULT_THEME_ID: &str = "cua.default";pub const DEFAULT_THEME_VERSION: &str = "1.0.0";pub const THEME_PROFILE: &str = "cua-driver-full-v1";pub const CANVAS_SIZE: f32 = 128.0;-pub const DISPLAY_SIZE: f32 = 58.0;+pub const DISPLAY_SIZE: f32 = 48.0;+const FLOAT_DURATION_SECS: f32 = 4.0;++pub const DEFAULT_CURSOR_FILL: [u8; 4] = [94, 192, 232, 255];++const SESSION_CURSOR_FILLS: &[[u8; 4]] = &[+ [178, 132, 255, 255],+ [247, 132, 170, 255],+ [96, 218, 174, 255],+ [244, 178, 66, 255],+ [76, 204, 224, 255],+ [221, 113, 236, 255],+ [232, 82, 98, 255],+ [184, 220, 54, 255],+ [80, 126, 236, 255],+];++/// Return the stable fill color for one session-owned cursor.+///+/// The anonymous/default cursor keeps the original Cua blue. Named sessions+/// hash into the former multi-cursor palette so concurrent runs are visually+/// distinct without accepting an agent-controlled styling argument.+pub fn session_fill_rgba(session_id: &str) -> [u8; 4] {+ if session_id.is_empty() || session_id == "default" {+ return DEFAULT_CURSOR_FILL;+ }-fn ink() -> Color {- Color::from_rgba8(16, 21, 47, 255)+ SESSION_CURSOR_FILLS[stable_session_index(session_id, SESSION_CURSOR_FILLS.len())]}-fn paper() -> Color {- Color::from_rgba8(251, 251, 249, 255)+pub fn session_fill_hex(session_id: &str) -> String {+ let [r, g, b, _] = session_fill_rgba(session_id);+ format!("#{r:02X}{g:02X}{b:02X}")+}++fn stable_session_index(id: &str, count: usize) -> usize {+ let suffix = id+ .rfind(['-', '_', '.'])+ .map(|index| &id[index + 1..])+ .unwrap_or(id);+ if let Ok(number) = suffix.parse::<usize>() {+ if number > 0 {+ return (number - 1) % count;+ }+ }+ if suffix.len() == 1 {+ if let Some(character) = suffix.chars().next() {+ if character.is_ascii_alphabetic() {+ return (character.to_ascii_lowercase() as usize - b'a' as usize) % count;+ }+ }+ }++ let mut hash: u32 = 2_166_136_261;+ for character in id.chars() {+ hash ^= character as u32;+ hash = hash.wrapping_mul(16_777_619);+ }+ hash as usize % count}#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]@@ -128,107 +179,21 @@ impl CursorVisualState {}}-fn solid_paint(color: Color, alpha: f32) -> Paint<'static> {- Paint {- shader: tiny_skia::Shader::SolidColor(- Color::from_rgba(- color.red(),- color.green(),- color.blue(),- (color.alpha() * alpha).clamp(0.0, 1.0),- )- .unwrap_or(Color::TRANSPARENT),- ),- anti_alias: true,- ..Default::default()+pub(crate) fn shared_float_motion(visual: &CursorVisualState) -> (f32, f32, f32) {+ if visual.reduced_motion == ReducedMotion::On {+ return (0.0, 0.0, 0.0);}-}-fn cue_stroke(alpha: f32, width: f32) -> (Paint<'static>, Stroke) {+ let progress =+ (visual.elapsed_secs as f32).rem_euclid(FLOAT_DURATION_SECS) / FLOAT_DURATION_SECS;+ let angle = progress * std::f32::consts::TAU;(- solid_paint(ink(), alpha),- Stroke {- width,- line_cap: tiny_skia::LineCap::Round,- line_join: tiny_skia::LineJoin::Round,- ..Default::default()- },+ angle.sin() * 5.0,+ 6.0 * angle.cos() - 5.0,+ 2.5_f32.to_radians() * angle.cos(),)}-fn draw_path(- pm: &mut tiny_skia::Pixmap,- path: &Path,- transform: Transform,- alpha: f32,- width: f32,-) {- let (paint, stroke) = cue_stroke(alpha, width);- pm.stroke_path(path, &paint, &stroke, transform, None);-}--fn line_path(points: &[(f32, f32)]) -> Option<Path> {- let (&(x, y), rest) = points.split_first()?;- let mut builder = PathBuilder::new();- builder.move_to(x, y);- for &(x, y) in rest {- builder.line_to(x, y);- }- builder.finish()-}--fn rounded_rect_path(x: f32, y: f32, width: f32, height: f32, radius: f32) -> Option<Path> {- let r = radius.min(width * 0.5).min(height * 0.5).max(0.0);- let k = 0.552_284_8;- let mut builder = PathBuilder::new();- builder.move_to(x + r, y);- builder.line_to(x + width - r, y);- builder.cubic_to(- x + width - r + r * k,- y,- x + width,- y + r - r * k,- x + width,- y + r,- );- builder.line_to(x + width, y + height - r);- builder.cubic_to(- x + width,- y + height - r + r * k,- x + width - r + r * k,- y + height,- x + width - r,- y + height,- );- builder.line_to(x + r, y + height);- builder.cubic_to(- x + r - r * k,- y + height,- x,- y + height - r + r * k,- x,- y + height - r,- );- builder.line_to(x, y + r);- builder.cubic_to(x, y + r - r * k, x + r - r * k, y, x + r, y);- builder.close();- builder.finish()-}--fn ease_in_out(t: f32) -> f32 {- let t = t.clamp(0.0, 1.0);- t * t * (3.0 - 2.0 * t)-}--fn triangle_wave(t: f32) -> f32 {- let t = t.rem_euclid(1.0);- if t < 0.5 {- t * 2.0- } else {- (1.0 - t) * 2.0- }-}-/// Paint one frame of the embedded Full-v1 theme.////// `anchor_x/y` is the existing overlay's cursor centre. The Lottie canvas is@@ -243,440 +208,233 @@ pub fn paint_default_theme(backing_scale: f32,alpha: f32,) {- let scale = DISPLAY_SIZE * backing_scale / CANVAS_SIZE;- let base_rotation = heading - std::f32::consts::FRAC_PI_4;- let mut body_dx = 0.0;- let mut body_dy = 0.0;- let mut body_rotation = 0.0;- let mut body_scale = 1.0;-- let duration = visual.resolved_action.duration_secs() as f32;- let local = (visual.elapsed_secs as f32).rem_euclid(duration.max(1.0 / 30.0));- let progress = (local / duration.max(1.0 / 30.0)).clamp(0.0, 1.0);- let reduced = visual.reduced_motion == ReducedMotion::On;-- if !reduced {- match visual.resolved_action {- CursorAction::Idle => {- let angle = progress * std::f32::consts::TAU;- body_dx = angle.sin() * 5.0;- body_dy = 6.0 * angle.cos() - 5.0;- body_rotation = 2.5_f32.to_radians() * angle.cos();- }- CursorAction::Click => {- body_scale = if progress < 0.35 {- 1.0 - ease_in_out(progress / 0.35) * 0.07- } else if progress < 0.6 {- 0.93 + ease_in_out((progress - 0.35) / 0.25) * 0.10- } else {- 1.03 - ease_in_out((progress - 0.6) / 0.4) * 0.03- };- }- CursorAction::Drag => {- let held = ease_in_out(triangle_wave(progress));- body_dx = held * 7.0;- body_dy = held * 3.0;- }- _ => {}- }- }-- let canvas_transform = Transform::from_translate(-64.0, -64.0)- .post_scale(scale, scale)- .post_rotate(base_rotation.to_degrees())- .post_translate(anchor_x, anchor_y);- let body_transform = Transform::from_translate(-64.0, -64.0)- .post_scale(scale * body_scale, scale * body_scale)- .post_rotate((base_rotation + body_rotation).to_degrees())- .post_translate(anchor_x + body_dx * scale, anchor_y + body_dy * scale);-- draw_action_cue(+ paint_default_theme_with_fill(pm,- visual.resolved_action,- progress,- canvas_transform,+ visual,+ anchor_x,+ anchor_y,+ heading,+ backing_scale,alpha,- reduced,+ DEFAULT_CURSOR_FILL,);- draw_cursor_body(pm, body_transform, alpha);- draw_modifiers(pm, visual, canvas_transform, alpha);}-fn draw_cursor_body(pm: &mut tiny_skia::Pixmap, transform: Transform, alpha: f32) {- let mut builder = PathBuilder::new();- builder.move_to(55.0, 30.0);- builder.cubic_to(48.0, 28.0, 42.0, 33.0, 43.0, 41.0);- builder.line_to(64.0, 98.0);- builder.cubic_to(67.0, 106.0, 73.0, 106.0, 77.0, 99.0);- builder.line_to(86.0, 79.0);- builder.cubic_to(88.0, 75.0, 91.0, 72.0, 95.0, 70.0);- builder.line_to(108.0, 63.0);- builder.cubic_to(115.0, 59.0, 114.0, 53.0, 107.0, 50.0);- builder.close();- let Some(path) = builder.finish() else {- return;- };- pm.fill_path(- &path,- &solid_paint(paper(), alpha),- FillRule::Winding,- transform,- None,- );- let (paint, mut stroke) = cue_stroke(alpha, 5.0);- stroke.line_join = tiny_skia::LineJoin::Round;- pm.stroke_path(&path, &paint, &stroke, transform, None);-}--fn draw_action_cue(+pub fn paint_default_theme_with_fill(pm: &mut tiny_skia::Pixmap,- action: CursorAction,- progress: f32,- transform: Transform,+ visual: &CursorVisualState,+ anchor_x: f32,+ anchor_y: f32,+ heading: f32,+ backing_scale: f32,alpha: f32,- reduced: bool,+ fill_rgba: [u8; 4],) {- let wave = if reduced {- 0.5- } else {- triangle_wave(progress)- };- match action {- CursorAction::Idle => {}- CursorAction::Observe => {- let opacity = alpha- * if reduced {- 1.0- } else {- (progress * 7.0).min(1.0)- };- let scale = if reduced { 1.0 } else { 0.88 + progress * 0.20 };- let t = Transform::from_translate(-64.0, -64.0)- .post_scale(scale, scale)- .post_translate(64.0 + 8.0, 64.0 - 10.0)- .post_concat(transform);- let mut a = PathBuilder::new();- a.move_to(38.0, 28.0);- a.cubic_to(27.0, 29.0, 20.0, 38.0, 20.0, 49.0);- if let Some(path) = a.finish() {- draw_path(pm, &path, t, opacity, 4.0);- }- let mut b = PathBuilder::new();- b.move_to(42.0, 19.0);- b.cubic_to(23.0, 19.0, 11.0, 33.0, 11.0, 51.0);- if let Some(path) = b.finish() {- draw_path(pm, &path, t, opacity, 4.0);- }- }- CursorAction::Click => {- let cue_progress = (progress / 0.65).clamp(0.0, 1.0);- let opacity = alpha * (1.0 - cue_progress).min(cue_progress * 4.0).clamp(0.0, 1.0);- let cue_scale = 0.25 + ease_in_out(cue_progress) * 1.0;- let t = Transform::from_translate(-25.0, -25.0)- .post_scale(cue_scale, cue_scale)- .post_translate(25.0 + 10.0, 25.0 + 3.0)- .post_concat(transform);- for points in [- &[(35.0, 20.0), (34.0, 11.0)][..],- &[(27.0, 25.0), (19.0, 19.0)][..],- &[(25.0, 34.0), (15.0, 34.0)][..],- ] {- if let Some(path) = line_path(points) {- draw_path(pm, &path, t, opacity, 4.0);- }- }- }- CursorAction::Drag => {- let offset = if reduced {- 0.0- } else {- ease_in_out(wave) * 7.0- };- let t = Transform::from_translate(offset, offset * 0.43).post_concat(transform);- for points in [- &[(28.0, 38.0), (16.0, 35.0)][..],- &[(26.0, 48.0), (12.0, 45.0)][..],- ] {- if let Some(path) = line_path(points) {- draw_path(pm, &path, t, alpha * (0.2 + wave * 0.8), 4.0);- }- }- }- CursorAction::Scroll => {- let y = if reduced { 0.0 } else { 4.0 - wave * 8.0 };- let t = Transform::from_translate(-5.0, y).post_concat(transform);- for points in [- &[(23.0, 31.0), (31.0, 22.0), (39.0, 31.0)][..],- &[(23.0, 49.0), (31.0, 58.0), (39.0, 49.0)][..],- ] {- if let Some(path) = line_path(points) {- draw_path(pm, &path, t, alpha * (0.42 + wave * 0.58), 4.0);- }- }- }- CursorAction::Text => {- let opacity = if reduced || progress < 0.34 || progress > 0.64 {- alpha- } else {- alpha * 0.18- };- let t = Transform::from_translate(-4.0, 0.0).post_concat(transform);- for points in [- &[(31.0, 22.0), (31.0, 58.0)][..],- &[(24.0, 22.0), (38.0, 22.0)][..],- &[(24.0, 58.0), (38.0, 58.0)][..],- ] {- if let Some(path) = line_path(points) {- draw_path(pm, &path, t, opacity, 4.0);- }- }- }- CursorAction::Key => {- let bounce = if reduced {- 0.0- } else {- (progress * std::f32::consts::TAU).sin() * (1.0 - progress) * 3.0- };- let t = Transform::from_translate(-9.0, bounce).post_concat(transform);- if let Some(rect) = tiny_skia::Rect::from_xywh(14.0, 25.0, 28.0, 28.0) {- if let Some(path) =- rounded_rect_path(rect.x(), rect.y(), rect.width(), rect.height(), 6.0)- {- draw_path(pm, &path, t, alpha, 3.5);- }- }- if let Some(path) = line_path(&[- (23.0, 32.0),- (23.0, 46.0),- (23.0, 39.0),- (33.0, 32.0),- (24.0, 39.0),- (34.0, 46.0),- ]) {- draw_path(pm, &path, t, alpha, 3.5);- }- }- CursorAction::Navigate => {- let x = if reduced {- 0.0- } else {- -5.0 + ease_in_out(progress) * 9.0- };- let t = Transform::from_translate(x - 5.0, 0.0).post_concat(transform);- for points in [- &[(15.0, 29.0), (25.0, 40.0), (15.0, 51.0)][..],- &[(29.0, 29.0), (39.0, 40.0), (29.0, 51.0)][..],- ] {- if let Some(path) = line_path(points) {- draw_path(pm, &path, t, alpha * (0.2 + wave * 0.8), 4.0);- }- }- }- CursorAction::App => {- let s = if reduced {- 1.0- } else {- 0.2 + ease_in_out((progress * 2.0).min(1.0)) * 0.8- };- let t = Transform::from_translate(-26.0, -39.0)- .post_scale(s, s)- .post_translate(26.0 - 5.0, 39.0)- .post_concat(transform);- for (x, y) in [(13.0, 26.0), (29.0, 26.0), (13.0, 42.0), (29.0, 42.0)] {- if let Some(rect) = tiny_skia::Rect::from_xywh(x, y, 10.0, 10.0) {- if let Some(path) =- rounded_rect_path(rect.x(), rect.y(), rect.width(), rect.height(), 2.0)- {- draw_path(pm, &path, t, alpha, 3.5);- }- }- }- }- CursorAction::Transfer => {- let y = if reduced { 0.0 } else { 6.0 - wave * 12.0 };- let t = Transform::from_translate(-9.0, y).post_concat(transform);- for points in [- &[- (22.0, 50.0),- (22.0, 20.0),- (14.0, 28.0),- (22.0, 20.0),- (30.0, 28.0),- ][..],- &[- (37.0, 28.0),- (37.0, 58.0),- (29.0, 50.0),- (37.0, 58.0),- (45.0, 50.0),- ][..],- ] {- if let Some(path) = line_path(points) {- draw_path(pm, &path, t, alpha * (0.38 + wave * 0.62), 4.0);- }- }- }- CursorAction::Record => {- let t = Transform::from_translate(-12.0, 0.0).post_concat(transform);- let (paint, stroke) = cue_stroke(alpha, 4.0);- let mut ring = PathBuilder::new();- ring.push_circle(29.0, 39.0, 17.0);- if let Some(path) = ring.finish() {- pm.stroke_path(&path, &paint, &stroke, t, None);- }- let radius = if reduced { 5.0 } else { 3.6 + wave * 2.1 };- let mut dot = PathBuilder::new();- dot.push_circle(29.0, 39.0, radius);- if let Some(path) = dot.finish() {- pm.fill_path(- &path,- &solid_paint(ink(), alpha * (0.42 + wave * 0.58)),- FillRule::Winding,- t,- None,- );- }- }- CursorAction::System => {- let rotation = if reduced {- 0.0- } else {- ease_in_out(progress) * 68.0 - 18.0- };- let t = Transform::from_translate(-29.0, -39.0)- .post_rotate(rotation)- .post_translate(29.0 - 14.0, 39.0)- .post_concat(transform);- let (paint, stroke) = cue_stroke(alpha, 3.5);- for radius in [12.0, 4.0] {- let mut circle = PathBuilder::new();- circle.push_circle(29.0, 39.0, radius);- if let Some(path) = circle.finish() {- pm.stroke_path(&path, &paint, &stroke, t, None);- }- }- for points in [- &[(29.0, 20.0), (29.0, 25.0)][..],- &[(29.0, 53.0), (29.0, 58.0)][..],- &[(10.0, 39.0), (15.0, 39.0)][..],- &[(43.0, 39.0), (48.0, 39.0)][..],- &[(16.0, 26.0), (20.0, 30.0)][..],- &[(38.0, 48.0), (42.0, 52.0)][..],- &[(16.0, 52.0), (20.0, 48.0)][..],- &[(38.0, 30.0), (42.0, 26.0)][..],- ] {- if let Some(path) = line_path(points) {- draw_path(pm, &path, t, alpha, 3.5);- }- }- }- }+ let theme = crate::theme_artifact::embedded_default_theme();+ crate::theme_artifact::paint_compiled_theme_with_tint(+ pm,+ &theme,+ visual,+ anchor_x,+ anchor_y,+ heading,+ backing_scale,+ alpha,+ Some(fill_rgba),+ );}-fn draw_modifiers(- pm: &mut tiny_skia::Pixmap,- visual: &CursorVisualState,- transform: Transform,- alpha: f32,-) {- if visual.delivery == Some(DeliveryModifier::Background) {- let mut builder = PathBuilder::new();- builder.move_to(34.0, 23.0);- builder.cubic_to(20.0, 31.0, 17.0, 48.0, 21.0, 63.0);- builder.cubic_to(25.0, 80.0, 38.0, 95.0, 53.0, 106.0);- if let Some(path) = builder.finish() {- let (paint, mut stroke) = cue_stroke(alpha * 0.75, 2.5);- stroke.dash = Some(tiny_skia::StrokeDash::new(vec![1.0, 5.0], 0.0).unwrap());- pm.stroke_path(&path, &paint, &stroke, transform, None);+#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn full_profile_has_twelve_unique_actions() {+ let mut names = std::collections::BTreeSet::new();+ for action in CursorAction::ALL {+ assert!(names.insert(action.as_str()));}+ assert_eq!(names.len(), 12);}- if visual.delivery == Some(DeliveryModifier::Foreground) {- let (paint, stroke) = cue_stroke(alpha, 3.0);- let mut ring = PathBuilder::new();- ring.push_circle(104.0, 96.0, 9.0);- if let Some(path) = ring.finish() {- pm.stroke_path(&path, &paint, &stroke, transform, None);- }+ #[test]+ fn default_theme_uses_compact_48_point_footprint() {+ assert_eq!(DISPLAY_SIZE, 48.0);}- match visual.target {- Some(TargetModifier::Ax) => {- let (paint, stroke) = cue_stroke(alpha, 2.5);- for (x, y) in [(104.0, 89.0), (94.0, 104.0), (114.0, 104.0)] {- let mut circle = PathBuilder::new();- circle.push_circle(x, y, 3.0);- if let Some(path) = circle.finish() {- pm.stroke_path(&path, &paint, &stroke, transform, None);- }- }- if let Some(path) = line_path(&[- (104.0, 92.0),- (104.0, 97.0),- (94.0, 101.0),- (104.0, 97.0),- (114.0, 101.0),- ]) {- draw_path(pm, &path, transform, alpha, 2.5);- }- }- Some(TargetModifier::Pixel) => {- if let Some(rect) = tiny_skia::Rect::from_xywh(94.0, 91.0, 19.0, 19.0) {- let path = PathBuilder::from_rect(rect);- let (paint, mut stroke) = cue_stroke(alpha, 2.5);- stroke.dash = Some(tiny_skia::StrokeDash::new(vec![2.0, 3.0], 0.0).unwrap());- pm.stroke_path(&path, &paint, &stroke, transform, None);- }- }- Some(TargetModifier::Browser) => {- let (paint, stroke) = cue_stroke(alpha, 2.5);- let mut circle = PathBuilder::new();- circle.push_circle(104.0, 100.0, 10.0);- if let Some(path) = circle.finish() {- pm.stroke_path(&path, &paint, &stroke, transform, None);- }- for points in [- &[(94.0, 100.0), (114.0, 100.0)][..],- &[(104.0, 90.0), (100.0, 100.0), (104.0, 110.0)][..],- &[(104.0, 90.0), (108.0, 100.0), (104.0, 110.0)][..],- ] {- if let Some(path) = line_path(points) {- draw_path(pm, &path, transform, alpha, 2.5);- }- }- }- Some(TargetModifier::Desktop) => {- if let Some(rect) = tiny_skia::Rect::from_xywh(93.0, 90.0, 21.0, 15.0) {- if let Some(path) =- rounded_rect_path(rect.x(), rect.y(), rect.width(), rect.height(), 2.0)- {- draw_path(pm, &path, transform, alpha, 2.5);+ #[test]+ fn default_cursor_keeps_original_blue_fill() {+ assert_eq!(session_fill_rgba("default"), DEFAULT_CURSOR_FILL);+ assert_eq!(session_fill_hex("default"), "#5EC0E8");+ }++ #[test]+ fn named_session_colors_are_stable_and_distinct() {+ assert_eq!(session_fill_rgba("agent-1"), session_fill_rgba("agent-1"));+ assert_ne!(session_fill_rgba("agent-1"), session_fill_rgba("agent-2"));+ assert_ne!(session_fill_rgba("agent-2"), DEFAULT_CURSOR_FILL);+ }++ #[test]+ fn default_cursor_uses_parameterized_fill_white_ink_and_matching_glow() {+ let mut pixmap = tiny_skia::Pixmap::new(256, 256).unwrap();+ paint_default_theme_with_fill(+ &mut pixmap,+ &CursorVisualState::default(),+ 128.0,+ 128.0,+ std::f32::consts::FRAC_PI_4,+ 2.0,+ 1.0,+ [12, 34, 56, 255],+ );++ let pixels = pixmap.data().chunks_exact(4).collect::<Vec<_>>();+ assert!(pixels.iter().any(|pixel| *pixel == [12, 34, 56, 255]));+ assert!(pixels.iter().any(|pixel| *pixel == [255, 255, 255, 255]));+ assert!(pixels.iter().any(|pixel| pixel[2] > pixel[1]+ && pixel[1] > pixel[0]+ && pixel[0] > 0+ && pixel[3] > 16+ && pixel[3] < 200));+ }++ #[test]+ fn matching_glow_surrounds_the_full_pointer_silhouette() {+ let mut pixmap = tiny_skia::Pixmap::new(256, 256).unwrap();+ let visual = CursorVisualState {+ reduced_motion: ReducedMotion::On,+ ..CursorVisualState::default()+ };+ paint_default_theme_with_fill(+ &mut pixmap,+ &visual,+ 128.0,+ 128.0,+ std::f32::consts::FRAC_PI_4,+ 2.0,+ 1.0,+ [12, 34, 56, 255],+ );++ let bounds = |predicate: &dyn Fn(&[u8]) -> bool| {+ let mut result = (u32::MAX, u32::MAX, 0, 0);+ for (index, pixel) in pixmap.data().chunks_exact(4).enumerate() {+ if predicate(pixel) {+ let x = index as u32 % pixmap.width();+ let y = index as u32 / pixmap.width();+ result.0 = result.0.min(x);+ result.1 = result.1.min(y);+ result.2 = result.2.max(x);+ result.3 = result.3.max(y);}}- if let Some(path) = line_path(&[- (103.5, 105.0),- (103.5, 110.0),- (97.0, 110.0),- (110.0, 110.0),- ]) {- draw_path(pm, &path, transform, alpha, 2.5);- }- }- None => {}+ result+ };+ let body = bounds(&|pixel| pixel == [12, 34, 56, 255]);+ let glow = bounds(&|pixel| {+ pixel[2] > pixel[1]+ && pixel[1] > pixel[0]+ && pixel[0] > 0+ && pixel[3] > 8+ && pixel[3] < 220+ });++ assert!(+ glow.0 + 4 <= body.0,+ "glow should cover the pointer's left edge: body={body:?}, glow={glow:?}"+ );+ assert!(+ glow.1 + 4 <= body.1,+ "glow should cover the pointer's top edge: body={body:?}, glow={glow:?}"+ );+ assert!(+ glow.2 >= body.2 + 4,+ "glow should cover the pointer's right edge: body={body:?}, glow={glow:?}"+ );+ assert!(+ glow.3 >= body.3 + 4,+ "glow should cover the pointer's bottom edge: body={body:?}, glow={glow:?}"+ );}-}-#[cfg(test)]-mod tests {- use super::*;+ #[test]+ fn foreground_and_pixel_modifiers_render_on_opposite_sides() {+ let mut base = tiny_skia::Pixmap::new(128, 128).unwrap();+ let mut pixmap = tiny_skia::Pixmap::new(128, 128).unwrap();+ let base_visual = CursorVisualState {+ reduced_motion: ReducedMotion::On,+ ..CursorVisualState::default()+ };+ let visual = CursorVisualState {+ delivery: Some(DeliveryModifier::Foreground),+ target: Some(TargetModifier::Pixel),+ reduced_motion: ReducedMotion::On,+ ..CursorVisualState::default()+ };+ paint_default_theme_with_fill(+ &mut base,+ &base_visual,+ 64.0,+ 64.0,+ std::f32::consts::FRAC_PI_4,+ 1.0,+ 1.0,+ [12, 34, 56, 255],+ );+ paint_default_theme_with_fill(+ &mut pixmap,+ &visual,+ 64.0,+ 64.0,+ std::f32::consts::FRAC_PI_4,+ 1.0,+ 1.0,+ [12, 34, 56, 255],+ );++ let changed_pixels = |x_range: std::ops::Range<u32>| {+ (0..128)+ .flat_map(|y| x_range.clone().map(move |x| (x, y)))+ .filter(|(x, y)| {+ let index = ((y * pixmap.width() + x) * 4) as usize;+ pixmap.data()[index..index + 4] != base.data()[index..index + 4]+ })+ .count()+ };++ assert!(changed_pixels(0..50) > 5);+ assert!(changed_pixels(78..128) > 5);+ }#[test]- fn full_profile_has_twelve_unique_actions() {- let mut names = std::collections::BTreeSet::new();+ fn every_action_inherits_the_same_floating_base_motion() {+ let mut idle = CursorVisualState::default();+ idle.elapsed_secs = 0.75;+ let expected = shared_float_motion(&idle);+ assert_ne!(expected, (0.0, 0.0, 0.0));+for action in CursorAction::ALL {- assert!(names.insert(action.as_str()));+ let mut visual = CursorVisualState::default();+ visual.begin(action, None, None);+ visual.elapsed_secs = 0.75;+ assert_eq!(+ shared_float_motion(&visual),+ expected,+ "{} did not inherit the shared floating motion",+ action.as_str()+ );}- assert_eq!(names.len(), 12);+ }++ #[test]+ fn reduced_motion_disables_shared_floating_motion() {+ let visual = CursorVisualState {+ elapsed_secs: 0.75,+ reduced_motion: ReducedMotion::On,+ ..CursorVisualState::default()+ };+ assert_eq!(shared_float_motion(&visual), (0.0, 0.0, 0.0));}#[test]diff --git a/libs/cua-driver/rust/crates/cursor-overlay/src/theme_artifact.rs b/libs/cua-driver/rust/crates/cursor-overlay/src/theme_artifact.rsindex 1bfc9e1793..804eb081e9 100644--- a/libs/cua-driver/rust/crates/cursor-overlay/src/theme_artifact.rs+++ b/libs/cua-driver/rust/crates/cursor-overlay/src/theme_artifact.rs@@ -15,32 +15,92 @@ use std::{path::{Path, PathBuf},sync::{Arc, Mutex, OnceLock},};-use tiny_skia::{PixmapPaint, PixmapRef, Transform};+use tiny_skia::{Color, FillRule, LineCap, LineJoin, Paint, PathBuilder, Stroke, Transform};-const MAGIC: &[u8; 8] = b"CUATHEM1";+const MAGIC: &[u8; 8] = b"CUATHEM2";const HEADER_LEN: usize = 8 + 2 + 4 + 32;-const ARTIFACT_VERSION: u16 = 1;+const ARTIFACT_VERSION: u16 = 2;const MAX_COMPRESSED_BYTES: usize = 24 * 1024 * 1024;-const MAX_DECOMPRESSED_BYTES: usize = 96 * 1024 * 1024;+const MAX_DECOMPRESSED_BYTES: usize = 24 * 1024 * 1024;const MAX_TOTAL_FRAMES: usize = 1_000;const MAX_FRAMES_PER_ANIMATION: usize = 120;+const MAX_COMMANDS_PER_FRAME: usize = 128;+const MAX_GEOMETRIES_PER_COMMAND: usize = 64;+const MAX_PATH_POINTS: usize = 512;const MAX_TEXT_BYTES: usize = 200;const CANVAS: u32 = 128;const FPS: u16 = 30;+const DEFAULT_THEME_BYTES: &[u8] = include_bytes!("../assets/cua.default.cua-theme");++#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]+pub enum CompiledGeometry {+ Path {+ vertices: Vec<[f32; 2]>,+ in_tangents: Vec<[f32; 2]>,+ out_tangents: Vec<[f32; 2]>,+ closed: bool,+ },+ Ellipse {+ center: [f32; 2],+ size: [f32; 2],+ },+ Rectangle {+ center: [f32; 2],+ size: [f32; 2],+ roundness: f32,+ },+}++#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq)]+pub struct CompiledTransform {+ pub anchor: [f32; 2],+ pub position: [f32; 2],+ /// Multipliers, where `[1.0, 1.0]` is the Lottie 100% scale.+ pub scale: [f32; 2],+ pub rotation_degrees: f32,+}++impl Default for CompiledTransform {+ fn default() -> Self {+ Self {+ anchor: [0.0, 0.0],+ position: [0.0, 0.0],+ scale: [1.0, 1.0],+ rotation_degrees: 0.0,+ }+ }+}-#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]+#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq)]+pub struct CompiledStroke {+ pub color: [u8; 4],+ pub width: f32,+ pub line_cap: u8,+ pub line_join: u8,+}++#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]+pub struct CompiledDrawCommand {+ pub geometries: Vec<CompiledGeometry>,+ pub transform: CompiledTransform,+ pub opacity: f32,+ pub fill: Option<[u8; 4]>,+ pub stroke: Option<CompiledStroke>,+}++#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]pub struct CompiledFrame {- /// Premultiplied RGBA8 pixels, exactly 128×128.- pub pixels: Vec<u8>,+ /// Bounded vector commands in the theme's 128×128 coordinate space.+ pub commands: Vec<CompiledDrawCommand>,}-#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]+#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]pub struct CompiledAnimation {pub still_frame: u16,pub frames: Vec<CompiledFrame>,}-#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]+#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]pub struct CompiledTheme {pub id: String,pub name: String,@@ -84,6 +144,66 @@ fn valid_theme_id(value: &str) -> bool {})}+fn bounded_number(value: f32) -> bool {+ value.is_finite() && value.abs() <= 4096.0+}++fn validate_geometry(name: &str, frame: usize, geometry: &CompiledGeometry) -> Result<()> {+ let validate_pair = |label: &str, pair: [f32; 2]| -> Result<()> {+ if !pair.into_iter().all(bounded_number) {+ bail!("animation `{name}` frame {frame} has an invalid {label}");+ }+ Ok(())+ };+ match geometry {+ CompiledGeometry::Path {+ vertices,+ in_tangents,+ out_tangents,+ ..+ } => {+ if vertices.is_empty()+ || vertices.len() > MAX_PATH_POINTS+ || in_tangents.len() != vertices.len()+ || out_tangents.len() != vertices.len()+ {+ bail!("animation `{name}` frame {frame} has an invalid vector path");+ }+ for point in vertices+ .iter()+ .chain(in_tangents.iter())+ .chain(out_tangents.iter())+ {+ validate_pair("path coordinate", *point)?;+ }+ }+ CompiledGeometry::Ellipse { center, size } => {+ validate_pair("ellipse center", *center)?;+ validate_pair("ellipse size", *size)?;+ if size[0] < 0.0 || size[1] < 0.0 {+ bail!("animation `{name}` frame {frame} has a negative ellipse size");+ }+ }+ CompiledGeometry::Rectangle {+ center,+ size,+ roundness,+ } => {+ validate_pair("rectangle center", *center)?;+ validate_pair("rectangle size", *size)?;+ if size[0] < 0.0+ || size[1] < 0.0+ || !roundness.is_finite()+ || *roundness < 0.0+ || *roundness > 2048.0+ {+ bail!("animation `{name}` frame {frame} has invalid rectangle geometry");+ }+ }+ }+ Ok(())+}+fn validate_animation(name: &str, animation: &CompiledAnimation) -> Result<usize> {if animation.frames.is_empty() || animation.frames.len() > MAX_FRAMES_PER_ANIMATION {bail!("animation `{name}` must contain 1..={MAX_FRAMES_PER_ANIMATION} frames");@@ -91,13 +211,46 @@ fn validate_animation(name: &str, animation: &CompiledAnimation) -> Result<usizeif usize::from(animation.still_frame) >= animation.frames.len() {bail!("animation `{name}` has an out-of-range still_frame");}- let expected = (CANVAS * CANVAS * 4) as usize;for (index, frame) in animation.frames.iter().enumerate() {- if frame.pixels.len() != expected {- bail!(- "animation `{name}` frame {index} is {} bytes; expected {expected}",- frame.pixels.len()- );+ if frame.commands.len() > MAX_COMMANDS_PER_FRAME {+ bail!("animation `{name}` frame {index} has too many vector commands");+ }+ for command in &frame.commands {+ if command.geometries.is_empty()+ || command.geometries.len() > MAX_GEOMETRIES_PER_COMMAND+ || !command.opacity.is_finite()+ || !(0.0..=1.0).contains(&command.opacity)+ {+ bail!("animation `{name}` frame {index} has an invalid vector command");+ }+ for pair in [+ command.transform.anchor,+ command.transform.position,+ command.transform.scale,+ ] {+ if !pair.into_iter().all(bounded_number) {+ bail!("animation `{name}` frame {index} has an invalid transform");+ }+ }+ if !bounded_number(command.transform.rotation_degrees) {+ bail!("animation `{name}` frame {index} has an invalid rotation");+ }+ if command.fill.is_none() && command.stroke.is_none() {+ bail!("animation `{name}` frame {index} has a command without paint");+ }+ if let Some(stroke) = command.stroke {+ if !stroke.width.is_finite()+ || stroke.width <= 0.0+ || stroke.width > 512.0+ || !(1..=3).contains(&stroke.line_cap)+ || !(1..=3).contains(&stroke.line_join)+ {+ bail!("animation `{name}` frame {index} has an invalid stroke");+ }+ }+ for geometry in &command.geometries {+ validate_geometry(name, index, geometry)?;+ }}}Ok(animation.frames.len())@@ -154,7 +307,7 @@ pub fn validate_compiled_theme(theme: &CompiledTheme, full: bool) -> Result<()>Ok(())}-#[cfg(feature = "theme-authoring")]+#[cfg(any(test, feature = "theme-authoring"))]pub fn encode_theme(theme: &CompiledTheme) -> Result<Vec<u8>> {validate_compiled_theme(theme, theme.profile == crate::THEME_PROFILE)?;let payload = postcard::to_allocvec(theme).context("serialize compiled theme")?;@@ -316,7 +469,7 @@ fn theme_cache() -> &'static Mutex<BTreeMap<String, Arc<CompiledTheme>>> {pub fn load_installed_theme(id: &str) -> Result<Option<Arc<CompiledTheme>>> {if id == crate::DEFAULT_THEME_ID {- return Ok(None);+ return Ok(Some(embedded_default_theme()));}if let Some(theme) = theme_cache().lock()@@ -351,6 +504,26 @@ pub fn resolve_theme_selection(id: &str) -> Result<Option<Arc<CompiledTheme>>> {load_installed_theme(id)}+/// Decode the checked-in default artifact once per process.+///+/// The bytes are produced by `assets/build_default_theme.py`, validated by the+/// same authoring compiler as custom themes, and embedded in the binary. A+/// corrupt checked-in artifact is a build/test defect rather than a recoverable+/// user configuration error.+pub fn embedded_default_theme() -> Arc<CompiledTheme> {+ static DEFAULT: OnceLock<Arc<CompiledTheme>> = OnceLock::new();+ Arc::clone(DEFAULT.get_or_init(|| {+ let theme =+ decode_theme(DEFAULT_THEME_BYTES).expect("embedded cua.default theme must be valid");+ assert_eq!(+ theme.id,+ crate::DEFAULT_THEME_ID,+ "embedded default theme id must remain stable"+ );+ Arc::new(theme)+ }))+}+fn animation_frame<'a>(animation: &'a CompiledAnimation,elapsed_secs: f64,@@ -364,6 +537,201 @@ fn animation_frame<'a>(animation.frames.get(index)}+fn compiled_transform(transform: CompiledTransform) -> Transform {+ Transform::from_translate(-transform.anchor[0], -transform.anchor[1])+ .post_scale(transform.scale[0], transform.scale[1])+ .post_rotate(transform.rotation_degrees)+ .post_translate(transform.position[0], transform.position[1])+}++fn append_ellipse(builder: &mut PathBuilder, center: [f32; 2], size: [f32; 2]) {+ const K: f32 = 0.552_284_8;+ let rx = size[0] * 0.5;+ let ry = size[1] * 0.5;+ let [cx, cy] = center;+ builder.move_to(cx + rx, cy);+ builder.cubic_to(cx + rx, cy + ry * K, cx + rx * K, cy + ry, cx, cy + ry);+ builder.cubic_to(cx - rx * K, cy + ry, cx - rx, cy + ry * K, cx - rx, cy);+ builder.cubic_to(cx - rx, cy - ry * K, cx - rx * K, cy - ry, cx, cy - ry);+ builder.cubic_to(cx + rx * K, cy - ry, cx + rx, cy - ry * K, cx + rx, cy);+ builder.close();+}++fn append_rectangle(builder: &mut PathBuilder, center: [f32; 2], size: [f32; 2], roundness: f32) {+ const K: f32 = 0.552_284_8;+ let width = size[0];+ let height = size[1];+ let x = center[0] - width * 0.5;+ let y = center[1] - height * 0.5;+ let radius = roundness.min(width * 0.5).min(height * 0.5).max(0.0);+ builder.move_to(x + radius, y);+ builder.line_to(x + width - radius, y);+ builder.cubic_to(+ x + width - radius + radius * K,+ y,+ x + width,+ y + radius - radius * K,+ x + width,+ y + radius,+ );+ builder.line_to(x + width, y + height - radius);+ builder.cubic_to(+ x + width,+ y + height - radius + radius * K,+ x + width - radius + radius * K,+ y + height,+ x + width - radius,+ y + height,+ );+ builder.line_to(x + radius, y + height);+ builder.cubic_to(+ x + radius - radius * K,+ y + height,+ x,+ y + height - radius + radius * K,+ x,+ y + height - radius,+ );+ builder.line_to(x, y + radius);+ builder.cubic_to(+ x,+ y + radius - radius * K,+ x + radius - radius * K,+ y,+ x + radius,+ y,+ );+ builder.close();+}++fn append_geometry(builder: &mut PathBuilder, geometry: &CompiledGeometry) {+ match geometry {+ CompiledGeometry::Path {+ vertices,+ in_tangents,+ out_tangents,+ closed,+ } => {+ let Some(first) = vertices.first() else {+ return;+ };+ builder.move_to(first[0], first[1]);+ let segment_count = if *closed {+ vertices.len()+ } else {+ vertices.len().saturating_sub(1)+ };+ for index in 0..segment_count {+ let next = (index + 1) % vertices.len();+ let from = vertices[index];+ let to = vertices[next];+ let out = out_tangents[index];+ let incoming = in_tangents[next];+ if out != [0.0, 0.0] || incoming != [0.0, 0.0] {+ builder.cubic_to(+ from[0] + out[0],+ from[1] + out[1],+ to[0] + incoming[0],+ to[1] + incoming[1],+ to[0],+ to[1],+ );+ } else {+ builder.line_to(to[0], to[1]);+ }+ }+ if *closed {+ builder.close();+ }+ }+ CompiledGeometry::Ellipse { center, size } => append_ellipse(builder, *center, *size),+ CompiledGeometry::Rectangle {+ center,+ size,+ roundness,+ } => append_rectangle(builder, *center, *size, *roundness),+ }+}++fn resolved_color(mut color: [u8; 4], tint: Option<[u8; 4]>) -> [u8; 4] {+ if color[0..3] == crate::theme::DEFAULT_CURSOR_FILL[0..3] {+ if let Some(tint) = tint {+ color[0..3].copy_from_slice(&tint[0..3]);+ }+ }+ color+}++fn vector_paint(color: [u8; 4], opacity: f32, tint: Option<[u8; 4]>) -> Paint<'static> {+ let color = resolved_color(color, tint);+ let alpha = (f32::from(color[3]) / 255.0 * opacity.clamp(0.0, 1.0)).clamp(0.0, 1.0);+ Paint {+ shader: tiny_skia::Shader::SolidColor(+ Color::from_rgba(+ f32::from(color[0]) / 255.0,+ f32::from(color[1]) / 255.0,+ f32::from(color[2]) / 255.0,+ alpha,+ )+ .unwrap_or(Color::TRANSPARENT),+ ),+ anti_alias: true,+ ..Default::default()+ }+}++fn draw_frame(+ target: &mut tiny_skia::Pixmap,+ frame: &CompiledFrame,+ outer_transform: Transform,+ alpha: f32,+ tint: Option<[u8; 4]>,+) {+ for command in &frame.commands {+ let mut builder = PathBuilder::new();+ for geometry in &command.geometries {+ append_geometry(&mut builder, geometry);+ }+ let Some(path) = builder.finish() else {+ continue;+ };+ let transform = compiled_transform(command.transform).post_concat(outer_transform);+ let opacity = command.opacity * alpha;+ if let Some(fill) = command.fill {+ target.fill_path(+ &path,+ &vector_paint(fill, opacity, tint),+ FillRule::Winding,+ transform,+ None,+ );+ }+ if let Some(stroke) = command.stroke {+ let stroke_style = Stroke {+ width: stroke.width,+ line_cap: match stroke.line_cap {+ 1 => LineCap::Butt,+ 3 => LineCap::Square,+ _ => LineCap::Round,+ },+ line_join: match stroke.line_join {+ 1 => LineJoin::Miter,+ 3 => LineJoin::Bevel,+ _ => LineJoin::Round,+ },+ ..Default::default()+ };+ target.stroke_path(+ &path,+ &vector_paint(stroke.color, opacity, tint),+ &stroke_style,+ transform,+ None,+ );+ }+ }+}+fn draw_layer(target: &mut tiny_skia::Pixmap,animation: &CompiledAnimation,@@ -371,27 +739,44 @@ fn draw_layer(reduced_motion: bool,transform: Transform,alpha: f32,+ tint: Option<[u8; 4]>,) {let Some(frame) = animation_frame(animation, elapsed_secs, reduced_motion) else {return;};- let Some(source) = PixmapRef::from_bytes(&frame.pixels, CANVAS, CANVAS) else {- return;- };- target.draw_pixmap(- 0,- 0,- source,- &PixmapPaint {- opacity: alpha.clamp(0.0, 1.0),- ..Default::default()- },- transform,+ draw_frame(target, frame, transform, alpha, tint);+}++pub fn paint_compiled_theme(+ target: &mut tiny_skia::Pixmap,+ theme: &CompiledTheme,+ visual: &CursorVisualState,+ anchor_x: f32,+ anchor_y: f32,+ heading: f32,+ backing_scale: f32,+ alpha: f32,+) {+ paint_compiled_theme_with_tint(+ target,+ theme,+ visual,+ anchor_x,+ anchor_y,+ heading,+ backing_scale,+ alpha,None,);}-pub fn paint_compiled_theme(+/// Paint a compiled theme, optionally replacing the embedded default's blue+/// palette key with a stable per-session fill.+///+/// Custom themes pass `None` and retain their authored colors. Only the+/// checked-in `cua.default` path passes a tint.+#[allow(clippy::too_many_arguments)]+pub fn paint_compiled_theme_with_tint(target: &mut tiny_skia::Pixmap,theme: &CompiledTheme,visual: &CursorVisualState,@@ -400,12 +785,18 @@ pub fn paint_compiled_theme(heading: f32,backing_scale: f32,alpha: f32,+ tint: Option<[u8; 4]>,) {let scale = crate::theme::DISPLAY_SIZE * backing_scale / crate::theme::CANVAS_SIZE;+ let (float_dx, float_dy, float_rotation) = if theme.id == crate::DEFAULT_THEME_ID {+ crate::theme::shared_float_motion(visual)+ } else {+ (0.0, 0.0, 0.0)+ };let transform = Transform::from_translate(-64.0, -64.0).post_scale(scale, scale)- .post_rotate((heading - std::f32::consts::FRAC_PI_4).to_degrees())- .post_translate(anchor_x, anchor_y);+ .post_rotate((heading - std::f32::consts::FRAC_PI_4 + float_rotation).to_degrees())+ .post_translate(anchor_x + float_dx * scale, anchor_y + float_dy * scale);let reduced = visual.reduced_motion == crate::ReducedMotion::On;if let Some(animation) = theme.animation_for_action(visual.resolved_action) {draw_layer(@@ -415,6 +806,7 @@ pub fn paint_compiled_theme(reduced,transform,alpha,+ tint,);}if let Some(delivery) = visual.delivery {@@ -430,6 +822,7 @@ pub fn paint_compiled_theme(reduced,transform,alpha,+ tint,);}}@@ -448,6 +841,7 @@ pub fn paint_compiled_theme(reduced,transform,alpha,+ tint,);}}@@ -474,7 +868,16 @@ mod tests {fn frame() -> CompiledFrame {CompiledFrame {- pixels: vec![0; (CANVAS * CANVAS * 4) as usize],+ commands: vec![CompiledDrawCommand {+ geometries: vec![CompiledGeometry::Ellipse {+ center: [64.0, 64.0],+ size: [10.0, 10.0],+ }],+ transform: CompiledTransform::default(),+ opacity: 1.0,+ fill: Some([94, 192, 232, 255]),+ stroke: None,+ }],}}@@ -521,4 +924,55 @@ mod tests {theme.id = "../bad".into();assert!(validate_compiled_theme(&theme, false).is_err());}++ #[test]+ fn embedded_default_is_a_full_compiled_theme() {+ let theme = embedded_default_theme();+ assert_eq!(theme.id, crate::DEFAULT_THEME_ID);+ assert_eq!(theme.actions.len(), CursorAction::ALL.len());+ assert_eq!(theme.modifiers.len(), 6);+ assert!(theme+ .actions+ .values()+ .chain(theme.modifiers.values())+ .flat_map(|animation| &animation.frames)+ .any(|frame| !frame.commands.is_empty()));+ validate_compiled_theme(&theme, true).unwrap();+ assert!(load_installed_theme(crate::DEFAULT_THEME_ID)+ .unwrap()+ .is_some());+ }++ #[test]+ fn embedded_default_is_a_compact_vector_artifact() {+ assert!(+ DEFAULT_THEME_BYTES.len() < 100 * 1024,+ "the default vector artifact should remain compact, got {} bytes",+ DEFAULT_THEME_BYTES.len()+ );+ assert_eq!(+ &DEFAULT_THEME_BYTES[..MAGIC.len()],+ MAGIC,+ "the embedded theme must use the vector artifact version"+ );+ }++ #[test]+ fn embedded_default_was_compiled_from_the_checked_in_lottie() {+ let source = include_bytes!("../assets/cua.default.lottie");+ let expected: [u8; 32] = Sha256::digest(source).into();+ assert_eq!(embedded_default_theme().source_hash, expected);+ }++ #[test]+ fn default_tint_preserves_white_and_replaces_blue() {+ assert_eq!(+ resolved_color([94, 192, 232, 255], Some([12, 34, 56, 255])),+ [12, 34, 56, 255]+ );+ assert_eq!(+ resolved_color([255, 255, 255, 255], Some([12, 34, 56, 255])),+ [255, 255, 255, 255]+ );+ }}diff --git a/libs/cua-driver/rust/crates/cursor-theme-cli/Cargo.toml b/libs/cua-driver/rust/crates/cursor-theme-cli/Cargo.tomlindex 0fcea2226c..348e0ceffc 100644--- a/libs/cua-driver/rust/crates/cursor-theme-cli/Cargo.toml+++ b/libs/cua-driver/rust/crates/cursor-theme-cli/Cargo.toml@@ -14,10 +14,10 @@ path = "src/main.rs"anyhow.workspace = truecursor-overlay = { path = "../cursor-overlay", features = ["theme-authoring"] }image.workspace = true-rasterlottie = { version = "0.2.1", default-features = false, features = ["dotlottie"] }serde.workspace = trueserde_json.workspace = truesha2.workspace = true+tiny-skia = { version = "0.11", default-features = false, features = ["std"] }zip = { version = "8.6", default-features = false, features = ["deflate"] }[dev-dependencies]diff --git a/libs/cua-driver/rust/crates/cursor-theme-cli/src/main.rs b/libs/cua-driver/rust/crates/cursor-theme-cli/src/main.rsindex cb338c54c9..9ce3a0ae86 100644--- a/libs/cua-driver/rust/crates/cursor-theme-cli/src/main.rs+++ b/libs/cua-driver/rust/crates/cursor-theme-cli/src/main.rs@@ -3,11 +3,12 @@use anyhow::{anyhow, bail, Context, Result};use cursor_overlay::{encode_theme, inspect_artifact, install_artifact, list_installed_themes, uninstall_theme,- validate_compiled_theme, CompiledAnimation, CompiledFrame, CompiledTheme, CursorAction,- THEME_PROFILE,+ validate_compiled_theme, CompiledAnimation, CompiledDrawCommand, CompiledFrame,+ CompiledGeometry, CompiledStroke, CompiledTheme, CompiledTransform, CursorAction,+ CursorVisualState, DeliveryModifier, ReducedMotion, TargetModifier, THEME_PROFILE,};-use rasterlottie::{analyze_animation, Animation, RenderConfig, Renderer};use serde::Deserialize;+use serde_json::Value;use sha2::{Digest, Sha256};use std::{collections::{BTreeMap, BTreeSet},@@ -407,41 +408,489 @@ fn with_still_frame(Ok(animation)}+fn number(value: &Value, label: &str) -> Result<f32> {+ value+ .as_f64()+ .map(|value| value as f32)+ .filter(|value| value.is_finite())+ .ok_or_else(|| anyhow!("{label} must be a finite number"))+}++fn numeric_array(value: &Value, label: &str) -> Result<Vec<f32>> {+ if let Some(values) = value.as_array() {+ return values+ .iter()+ .map(|value| number(value, label))+ .collect::<Result<Vec<_>>>();+ }+ Ok(vec![number(value, label)?])+}++fn property_key<'a>(property: &'a Value, label: &str) -> Result<&'a Value> {+ property+ .get("k")+ .ok_or_else(|| anyhow!("{label} is missing its value"))+}++fn handle_component(keyframe: &Value, side: &str, axis: &str, fallback: f32) -> f32 {+ keyframe+ .get(side)+ .and_then(|value| value.get(axis))+ .and_then(|value| {+ value+ .as_f64()+ .or_else(|| value.as_array()?.first()?.as_f64())+ })+ .map(|value| value as f32)+ .filter(|value| value.is_finite())+ .unwrap_or(fallback)+}++fn cubic_coordinate(t: f32, first: f32, second: f32) -> f32 {+ let one_minus = 1.0 - t;+ 3.0 * one_minus * one_minus * t * first + 3.0 * one_minus * t * t * second + t * t * t+}++fn eased_progress(progress: f32, current: &Value, next: &Value) -> f32 {+ if current.get("h").and_then(Value::as_i64) == Some(1) {+ return 0.0;+ }+ let x1 = handle_component(current, "o", "x", 0.0).clamp(0.0, 1.0);+ let y1 = handle_component(current, "o", "y", 0.0);+ let x2 = handle_component(next, "i", "x", 1.0).clamp(0.0, 1.0);+ let y2 = handle_component(next, "i", "y", 1.0);+ let target = progress.clamp(0.0, 1.0);+ let mut low = 0.0;+ let mut high = 1.0;+ for _ in 0..14 {+ let middle = (low + high) * 0.5;+ if cubic_coordinate(middle, x1, x2) < target {+ low = middle;+ } else {+ high = middle;+ }+ }+ cubic_coordinate((low + high) * 0.5, y1, y2).clamp(0.0, 1.0)+}++fn property_value(property: &Value, frame: f32, label: &str) -> Result<Vec<f32>> {+ let animated = property.get("a").and_then(Value::as_i64).unwrap_or(0) == 1;+ let key = property_key(property, label)?;+ if !animated {+ return numeric_array(key, label);+ }+ let keyframes = key+ .as_array()+ .filter(|items| !items.is_empty())+ .ok_or_else(|| anyhow!("{label} has no keyframes"))?;+ let first = &keyframes[0];+ let first_time = first+ .get("t")+ .map(|value| number(value, label))+ .transpose()?+ .unwrap_or(0.0);+ if frame <= first_time {+ return numeric_array(+ first+ .get("s")+ .ok_or_else(|| anyhow!("{label} keyframe has no start value"))?,+ label,+ );+ }+ for pair in keyframes.windows(2) {+ let current = &pair[0];+ let next = &pair[1];+ let start_time = current+ .get("t")+ .map(|value| number(value, label))+ .transpose()?+ .unwrap_or(0.0);+ let end_time = next+ .get("t")+ .map(|value| number(value, label))+ .transpose()?+ .unwrap_or(start_time);+ if frame < end_time {+ let start = numeric_array(+ current+ .get("s")+ .ok_or_else(|| anyhow!("{label} keyframe has no start value"))?,+ label,+ )?;+ let end = if let Some(value) = current.get("e") {+ numeric_array(value, label)?+ } else {+ numeric_array(+ next.get("s")+ .ok_or_else(|| anyhow!("{label} keyframe has no end value"))?,+ label,+ )?+ };+ if start.len() != end.len() {+ bail!("{label} changes dimensionality between keyframes");+ }+ let linear = if end_time > start_time {+ (frame - start_time) / (end_time - start_time)+ } else {+ 0.0+ };+ let progress = eased_progress(linear, current, next);+ return Ok(start+ .iter()+ .zip(end.iter())+ .map(|(start, end)| start + (end - start) * progress)+ .collect());+ }+ }+ numeric_array(+ keyframes+ .last()+ .and_then(|value| value.get("s"))+ .ok_or_else(|| anyhow!("{label} final keyframe has no value"))?,+ label,+ )+}++fn property_scalar(property: &Value, frame: f32, label: &str) -> Result<f32> {+ property_value(property, frame, label)?+ .first()+ .copied()+ .ok_or_else(|| anyhow!("{label} is empty"))+}++fn property_pair(property: &Value, frame: f32, label: &str) -> Result<[f32; 2]> {+ let values = property_value(property, frame, label)?;+ if values.len() < 2 {+ bail!("{label} must contain two numbers");+ }+ Ok([values[0], values[1]])+}++fn transform_property(+ transform: &Value,+ key: &str,+ frame: f32,+ default: [f32; 2],+ label: &str,+) -> Result<[f32; 2]> {+ transform+ .get(key)+ .map(|property| property_pair(property, frame, label))+ .unwrap_or(Ok(default))+}++fn compile_transform(+ transform: &Value,+ frame: f32,+ label: &str,+) -> Result<(CompiledTransform, f32)> {+ let anchor = transform_property(transform, "a", frame, [0.0, 0.0], label)?;+ let position = transform_property(transform, "p", frame, [0.0, 0.0], label)?;+ let scale = transform_property(transform, "s", frame, [100.0, 100.0], label)?;+ let rotation = transform+ .get("r")+ .map(|property| property_scalar(property, frame, label))+ .transpose()?+ .unwrap_or(0.0);+ let opacity = transform+ .get("o")+ .map(|property| property_scalar(property, frame, label))+ .transpose()?+ .unwrap_or(100.0);+ Ok((+ CompiledTransform {+ anchor,+ position,+ scale: [scale[0] / 100.0, scale[1] / 100.0],+ rotation_degrees: rotation,+ },+ (opacity / 100.0).clamp(0.0, 1.0),+ ))+}++fn color(property: &Value, frame: f32, label: &str) -> Result<[u8; 4]> {+ let values = property_value(property, frame, label)?;+ if values.len() < 3 {+ bail!("{label} must contain at least three channels");+ }+ let channel = |index: usize, fallback: f32| {+ (values+ .get(index)+ .copied()+ .unwrap_or(fallback)+ .clamp(0.0, 1.0)+ * 255.0)+ .round() as u8+ };+ Ok([+ channel(0, 0.0),+ channel(1, 0.0),+ channel(2, 0.0),+ channel(3, 1.0),+ ])+}++fn static_pair(property: &Value, label: &str) -> Result<[f32; 2]> {+ if property.get("a").and_then(Value::as_i64).unwrap_or(0) != 0 {+ bail!("{label} geometry animation is not supported by the bounded vector profile");+ }+ property_pair(property, 0.0, label)+}++fn compile_geometry(shape: &Value, label: &str) -> Result<CompiledGeometry> {+ match shape.get("ty").and_then(Value::as_str) {+ Some("sh") => {+ let property = shape+ .get("ks")+ .ok_or_else(|| anyhow!("{label} path is missing geometry"))?;+ if property.get("a").and_then(Value::as_i64).unwrap_or(0) != 0 {+ bail!("{label} path animation is not supported by the bounded vector profile");+ }+ let path = property_key(property, label)?;+ let points = |key: &str| -> Result<Vec<[f32; 2]>> {+ path.get(key)+ .and_then(Value::as_array)+ .ok_or_else(|| anyhow!("{label} path is missing `{key}`"))?+ .iter()+ .map(|value| {+ let values = numeric_array(value, label)?;+ if values.len() < 2 {+ bail!("{label} path coordinate must contain two numbers");+ }+ Ok([values[0], values[1]])+ })+ .collect()+ };+ Ok(CompiledGeometry::Path {+ vertices: points("v")?,+ in_tangents: points("i")?,+ out_tangents: points("o")?,+ closed: path.get("c").and_then(Value::as_bool).unwrap_or(false),+ })+ }+ Some("el") => Ok(CompiledGeometry::Ellipse {+ center: static_pair(+ shape+ .get("p")+ .ok_or_else(|| anyhow!("{label} ellipse has no position"))?,+ label,+ )?,+ size: static_pair(+ shape+ .get("s")+ .ok_or_else(|| anyhow!("{label} ellipse has no size"))?,+ label,+ )?,+ }),+ Some("rc") => Ok(CompiledGeometry::Rectangle {+ center: static_pair(+ shape+ .get("p")+ .ok_or_else(|| anyhow!("{label} rectangle has no position"))?,+ label,+ )?,+ size: static_pair(+ shape+ .get("s")+ .ok_or_else(|| anyhow!("{label} rectangle has no size"))?,+ label,+ )?,+ roundness: shape+ .get("r")+ .map(|property| property_scalar(property, 0.0, label))+ .transpose()?+ .unwrap_or(0.0),+ }),+ Some(other) => bail!("{label} uses unsupported Lottie shape `{other}`"),+ None => bail!("{label} shape has no type"),+ }+}++enum CompiledStyle {+ Fill {+ color: [u8; 4],+ opacity: f32,+ },+ Stroke {+ stroke: CompiledStroke,+ opacity: f32,+ },+}++fn compile_layer(layer: &Value, frame: f32, id: &str) -> Result<Vec<CompiledDrawCommand>> {+ let label = format!("animation `{id}`");+ if layer.get("ty").and_then(Value::as_i64) != Some(4)+ || layer.get("ddd").and_then(Value::as_i64).unwrap_or(0) != 0+ || layer.get("parent").is_some()+ || layer.get("tt").is_some()+ || layer.get("masksProperties").is_some()+ || layer.get("ef").is_some()+ {+ bail!("{label} uses a layer outside the bounded vector profile");+ }+ let in_point = layer+ .get("ip")+ .map(|value| number(value, &label))+ .transpose()?+ .unwrap_or(0.0);+ let out_point = layer+ .get("op")+ .map(|value| number(value, &label))+ .transpose()?+ .unwrap_or(0.0);+ if frame < in_point || frame >= out_point {+ return Ok(Vec::new());+ }+ let (layer_transform, layer_opacity) = compile_transform(+ layer+ .get("ks")+ .ok_or_else(|| anyhow!("{label} layer has no transform"))?,+ frame,+ &label,+ )?;+ let shapes = layer+ .get("shapes")+ .and_then(Value::as_array)+ .ok_or_else(|| anyhow!("{label} shape layer has no shapes"))?;+ let mut geometries = Vec::new();+ let mut styles = Vec::new();+ for shape in shapes {+ match shape.get("ty").and_then(Value::as_str) {+ Some("sh" | "el" | "rc") => geometries.push(compile_geometry(shape, &label)?),+ Some("fl") => {+ let fill_color = color(+ shape+ .get("c")+ .ok_or_else(|| anyhow!("{label} fill has no color"))?,+ frame,+ &label,+ )?;+ let opacity = shape+ .get("o")+ .map(|property| property_scalar(property, frame, &label))+ .transpose()?+ .unwrap_or(100.0)+ / 100.0;+ styles.push(CompiledStyle::Fill {+ color: fill_color,+ opacity,+ });+ }+ Some("st") => {+ let stroke_color = color(+ shape+ .get("c")+ .ok_or_else(|| anyhow!("{label} stroke has no color"))?,+ frame,+ &label,+ )?;+ let opacity = shape+ .get("o")+ .map(|property| property_scalar(property, frame, &label))+ .transpose()?+ .unwrap_or(100.0)+ / 100.0;+ let width = property_scalar(+ shape+ .get("w")+ .ok_or_else(|| anyhow!("{label} stroke has no width"))?,+ frame,+ &label,+ )?;+ styles.push(CompiledStyle::Stroke {+ stroke: CompiledStroke {+ color: stroke_color,+ width,+ line_cap: shape.get("lc").and_then(Value::as_u64).unwrap_or(2) as u8,+ line_join: shape.get("lj").and_then(Value::as_u64).unwrap_or(2) as u8,+ },+ opacity,+ });+ }+ Some("tr") => {+ let (shape_transform, shape_opacity) = compile_transform(shape, frame, &label)?;+ if shape_transform != CompiledTransform::default()+ || (shape_opacity - 1.0).abs() > f32::EPSILON+ {+ bail!("{label} uses a non-identity shape transform; move it to the layer transform");+ }+ }+ Some(other) => bail!("{label} uses unsupported Lottie shape `{other}`"),+ None => bail!("{label} shape has no type"),+ }+ }+ if geometries.is_empty() || styles.is_empty() {+ bail!("{label} shape layer must contain geometry and paint");+ }+ Ok(styles+ .into_iter()+ .map(|style| match style {+ CompiledStyle::Fill { color, opacity } => CompiledDrawCommand {+ geometries: geometries.clone(),+ transform: layer_transform,+ opacity: (layer_opacity * opacity).clamp(0.0, 1.0),+ fill: Some(color),+ stroke: None,+ },+ CompiledStyle::Stroke { stroke, opacity } => CompiledDrawCommand {+ geometries: geometries.clone(),+ transform: layer_transform,+ opacity: (layer_opacity * opacity).clamp(0.0, 1.0),+ fill: None,+ stroke: Some(stroke),+ },+ })+ .collect())+}+fn compile_animation(bytes: &[u8], id: &str) -> Result<CompiledAnimation> {let text =std::str::from_utf8(bytes).with_context(|| format!("animation `{id}` is not UTF-8"))?;- let animation =- Animation::from_json_str(text).with_context(|| format!("parse animation `{id}`"))?;- if animation.width != CANVAS- || animation.height != CANVAS- || (animation.frame_rate - FPS).abs() > f32::EPSILON- {+ let animation: Value =+ serde_json::from_str(text).with_context(|| format!("parse animation `{id}`"))?;+ let width = animation.get("w").and_then(Value::as_u64).unwrap_or(0) as u32;+ let height = animation.get("h").and_then(Value::as_u64).unwrap_or(0) as u32;+ let frame_rate = animation+ .get("fr")+ .map(|value| number(value, id))+ .transpose()?+ .unwrap_or(0.0);+ if width != CANVAS || height != CANVAS || (frame_rate - FPS).abs() > f32::EPSILON {bail!("animation `{id}` must be 128×128 at 30 fps");}- let report = analyze_animation(&animation);- if !report.is_supported() {- bail!("animation `{id}` uses unsupported Lottie features: {report}");+ if animation+ .get("assets")+ .and_then(Value::as_array)+ .is_some_and(|assets| !assets.is_empty())+ {+ bail!("animation `{id}` cannot contain external or nested assets");}- let count = animation.duration_frames().ceil() as usize;+ let in_point = animation+ .get("ip")+ .map(|value| number(value, id))+ .transpose()?+ .unwrap_or(0.0);+ let out_point = animation+ .get("op")+ .map(|value| number(value, id))+ .transpose()?+ .unwrap_or(0.0);+ let count = (out_point - in_point).ceil() as usize;if count == 0 || count > MAX_FRAMES {bail!("animation `{id}` must contain 1..={MAX_FRAMES} frames");}- let renderer = Renderer::default();+ let layers = animation+ .get("layers")+ .and_then(Value::as_array)+ .ok_or_else(|| anyhow!("animation `{id}` has no layers"))?;let mut frames = Vec::with_capacity(count);for index in 0..count {- let frame = renderer- .render_frame(- &animation,- animation.in_point + index as f32,- RenderConfig::default(),- )- .with_context(|| format!("render animation `{id}` frame {index}"))?;- if frame.width != CANVAS || frame.height != CANVAS {- bail!("renderer returned an unexpected canvas for `{id}`");+ let frame_number = in_point + index as f32;+ let mut commands = Vec::new();+ for layer in layers.iter().rev() {+ commands.extend(compile_layer(layer, frame_number, id)?);}- frames.push(CompiledFrame {- pixels: premultiply_rgba(frame.pixels),- });+ frames.push(CompiledFrame { commands });}Ok(CompiledAnimation {still_frame: 0,@@ -449,25 +898,44 @@ fn compile_animation(bytes: &[u8], id: &str) -> Result<CompiledAnimation> {})}-fn premultiply_rgba(mut pixels: Vec<u8>) -> Vec<u8> {- for pixel in pixels.chunks_exact_mut(4) {- let alpha = u16::from(pixel[3]);- pixel[0] = ((u16::from(pixel[0]) * alpha + 127) / 255) as u8;- pixel[1] = ((u16::from(pixel[1]) * alpha + 127) / 255) as u8;- pixel[2] = ((u16::from(pixel[2]) * alpha + 127) / 255) as u8;- }- pixels-}-fn preview(theme: &CompiledTheme, output: &Path) -> Result<()> {fs::create_dir_all(output).with_context(|| format!("create {}", output.display()))?;- for (name, animation) in theme.actions.iter().chain(theme.modifiers.iter()) {- let frame = animation- .frames- .get(usize::from(animation.still_frame))- .ok_or_else(|| anyhow!("missing still frame for `{name}`"))?;- // The compiled pixels are premultiplied; PNG expects straight RGBA.- let pixels = unpremultiply_rgba(frame.pixels.clone());+ for name in theme.actions.keys().chain(theme.modifiers.keys()) {+ let mut visual = CursorVisualState {+ reduced_motion: ReducedMotion::On,+ ..CursorVisualState::default()+ };+ if let Some(action) = CursorAction::ALL+ .into_iter()+ .find(|action| action.as_str() == name)+ {+ visual.requested_action = action;+ visual.resolved_action = action;+ } else {+ match name.as_str() {+ "background" => visual.delivery = Some(DeliveryModifier::Background),+ "foreground" => visual.delivery = Some(DeliveryModifier::Foreground),+ "ax" => visual.target = Some(TargetModifier::Ax),+ "pixel" => visual.target = Some(TargetModifier::Pixel),+ "browser" => visual.target = Some(TargetModifier::Browser),+ "desktop" => visual.target = Some(TargetModifier::Desktop),+ _ => bail!("unknown compiled semantic `{name}`"),+ }+ }+ let mut pixmap = tiny_skia::Pixmap::new(CANVAS, CANVAS)+ .ok_or_else(|| anyhow!("create preview pixmap"))?;+ cursor_overlay::paint_compiled_theme(+ &mut pixmap,+ theme,+ &visual,+ CANVAS as f32 * 0.5,+ CANVAS as f32 * 0.5,+ std::f32::consts::FRAC_PI_4,+ CANVAS as f32 / 48.0,+ 1.0,+ );+ // tiny-skia stores premultiplied pixels; PNG expects straight RGBA.+ let pixels = unpremultiply_rgba(pixmap.data().to_vec());let path = output.join(format!("{name}.png"));image::save_buffer_with_format(&path,@@ -505,13 +973,12 @@ mod tests {use zip::{write::SimpleFileOptions, ZipWriter};#[test]- fn premultiplication_round_trip_is_bounded() {- let original = vec![200, 100, 50, 128, 0, 0, 0, 0];- let round_trip = unpremultiply_rgba(premultiply_rgba(original.clone()));- assert!(round_trip[0].abs_diff(original[0]) <= 1);- assert!(round_trip[1].abs_diff(original[1]) <= 1);- assert!(round_trip[2].abs_diff(original[2]) <= 1);- assert_eq!(&round_trip[4..], &[0, 0, 0, 0]);+ fn preview_unpremultiplication_is_bounded() {+ let straight = unpremultiply_rgba(vec![100, 50, 25, 128, 0, 0, 0, 0]);+ assert!(straight[0].abs_diff(199) <= 1);+ assert!(straight[1].abs_diff(100) <= 1);+ assert!(straight[2].abs_diff(50) <= 1);+ assert_eq!(&straight[4..], &[0, 0, 0, 0]);}#[test]@@ -584,6 +1051,48 @@ mod tests {file}+ fn vector_animation(extra_layer_fields: &str, ellipse_animated: u8) -> String {+ format!(+ r#"{{+ "v":"5.12.2",+ "fr":30,+ "ip":0,+ "op":1,+ "w":128,+ "h":128,+ "nm":"base",+ "ddd":0,+ "assets":[],+ "layers":[{{+ "ty":4,+ "ddd":0,+ "ip":0,+ "op":1,+ "ks":{{+ "a":{{"a":0,"k":[0,0]}},+ "p":{{"a":0,"k":[0,0]}},+ "s":{{"a":0,"k":[100,100]}},+ "r":{{"a":0,"k":0}},+ "o":{{"a":0,"k":100}}+ }},+ "shapes":[+ {{+ "ty":"el",+ "p":{{"a":0,"k":[64,64]}},+ "s":{{"a":{ellipse_animated},"k":[20,20]}}+ }},+ {{+ "ty":"fl",+ "c":{{"a":0,"k":[0.3686,0.7529,0.9098,1]}},+ "o":{{"a":0,"k":100}}+ }}+ ]+ {extra_layer_fields}+ }}]+ }}"#+ )+ }+#[test]fn compiles_a_bounded_development_theme() {let source = source_archive("base", "{}");@@ -595,6 +1104,33 @@ mod tests {assert!(encode_theme(&theme).is_ok());}+ #[test]+ fn compiles_supported_geometry_into_vector_commands() {+ let animation = vector_animation("", 0);+ let compiled = compile_animation(animation.as_bytes(), "base").unwrap();+ assert_eq!(compiled.frames.len(), 1);+ assert_eq!(compiled.frames[0].commands.len(), 1);+ assert!(matches!(+ compiled.frames[0].commands[0].geometries[0],+ CompiledGeometry::Ellipse { .. }+ ));+ }++ #[test]+ fn rejects_animated_geometry_and_masked_layers() {+ let animated = vector_animation("", 1);+ assert!(compile_animation(animated.as_bytes(), "base")+ .unwrap_err()+ .to_string()+ .contains("geometry animation is not supported"));++ let masked = vector_animation(r#","masksProperties":[] "#, 0);+ assert!(compile_animation(masked.as_bytes(), "base")+ .unwrap_err()+ .to_string()+ .contains("outside the bounded vector profile"));+ }+#[test]fn rejects_semantic_references_missing_from_standard_manifest() {let source = source_archive("different", "{}");diff --git a/libs/cua-driver/rust/crates/platform-linux/src/overlay.rs b/libs/cua-driver/rust/crates/platform-linux/src/overlay.rsindex da8d96e1dd..ec1253448f 100644--- a/libs/cua-driver/rust/crates/platform-linux/src/overlay.rs+++ b/libs/cua-driver/rust/crates/platform-linux/src/overlay.rs@@ -66,8 +66,9 @@ struct RenderMap {}fn render_state_for_key(template: &CursorConfig, key: &str) -> RenderState {- let _ = key;- RenderState::new(template.clone())+ let mut config = template.clone();+ config.cursor_id = key.to_owned();+ RenderState::new(config)}fn apply_msg(map: &mut RenderMap, msg: OverlayMsg) -> Option<CursorKey> {@@ -178,7 +179,10 @@ pub fn send_command_for(key: CursorKey, cmd: OverlayCommand) {#[cfg(target_os = "linux")]{if crate::wayland::is_wayland() {- if crate::wayland::shell_helper::available() {+ if crate::wayland::shell_helper::semantic_cursor_available() {+ crate::wayland::shell_helper::set_cursor_color(&cursor_overlay::session_fill_hex(+ &key,+ ));// GNOME has no layer-shell. Drive only the final positioning// commands through the compositor helper; it performs its own// easing and avoids starting a worker that must fail.@@ -186,12 +190,38 @@ pub fn send_command_for(key: CursorKey, cmd: OverlayCommand) {cursor_overlay::OverlayCommand::ClickPulse { x, y } => {crate::wayland::shell_helper::click_pulse(*x as i32, *y as i32);}+ cursor_overlay::OverlayCommand::MoveTo { x, y, .. } => {+ crate::wayland::shell_helper::move_cursor(*x as i32, *y as i32);+ }cursor_overlay::OverlayCommand::SnapTo { x, y, .. } => {crate::wayland::shell_helper::move_cursor(*x as i32, *y as i32);}+ cursor_overlay::OverlayCommand::BeginAction {+ action,+ delivery,+ target,+ } => {+ crate::wayland::shell_helper::set_cursor_state(+ action.as_str(),+ delivery.as_ref().map_or("", |value| value.as_str()),+ target.as_ref().map_or("", |value| value.as_str()),+ true,+ );+ }+ cursor_overlay::OverlayCommand::EndAction(action) => {+ crate::wayland::shell_helper::set_cursor_state(+ action.as_str(),+ "",+ "",+ false,+ );+ }+ cursor_overlay::OverlayCommand::SetEnabled(false) => {+ crate::wayland::shell_helper::hide_cursor();+ }_ => {}}- } else {+ } else if !crate::wayland::shell_helper::available() {let _ = crate::wayland::overlay::forward(&msg);}}@@ -1151,6 +1181,12 @@ fn bgra_and_visible_shape(mod tests {use super::*;+ #[test]+ fn keyed_render_state_carries_the_session_color_identity() {+ let state = render_state_for_key(&CursorConfig::default(), "session-blueprint");+ assert_eq!(state.core.cfg.cursor_id, "session-blueprint");+ }+fn default_render_map() -> RenderMap {let cfg = CursorConfig::default();let mut cursors = HashMap::new();diff --git a/libs/cua-driver/rust/crates/platform-linux/src/wayland/shell_helper.rs b/libs/cua-driver/rust/crates/platform-linux/src/wayland/shell_helper.rsindex 154177245b..335e44f756 100644--- a/libs/cua-driver/rust/crates/platform-linux/src/wayland/shell_helper.rs+++ b/libs/cua-driver/rust/crates/platform-linux/src/wayland/shell_helper.rs@@ -13,6 +13,8 @@//! (the GNOME analogue of the X11 `_GTK_FRAME_EXTENTS` reconstruction).//! - `MoveCursor(x,y)` / `ClickPulse(x,y)` / `HideCursor()` — draw the agent//! cursor as a Clutter actor on the compositor stage.+//! - `SetCursorState(...)` / `SetCursorColor(...)` — keep the compositor cursor+//! aligned with the shared semantic theme and active session identity.//!//! Everything here is **best-effort**: if the extension isn't installed/enabled//! the calls return `None` / no-op and callers keep the prior behaviour (no@@ -33,6 +35,7 @@ const DBUS_DEST: &str = "org.freedesktop.DBus";const DBUS_PATH: &str = "/org/freedesktop/DBus";const DBUS_IFACE: &str = "org.freedesktop.DBus";const BROWSER_HELPER_API_VERSION: u32 = 4;+const SEMANTIC_CURSOR_API_VERSION: u32 = 5;#[derive(Debug, Clone)]struct ShellWindow {@@ -44,6 +47,10 @@ pub fn available() -> bool {shell_owner(false).is_some()}+pub fn semantic_cursor_available() -> bool {+ shell_owner_with_min_version(Some(SEMANTIC_CURSOR_API_VERSION)).is_some()+}+fn gdbus_call(method: &str, args: &[String]) -> Option<String> {let owner = shell_owner(false)?;gdbus_call_to(@@ -110,6 +117,10 @@ fn gdbus_call_to(/// name closes the race where another process replaces the well-known name/// after ownership is checked.fn shell_owner(require_browser_api: bool) -> Option<String> {+ shell_owner_with_min_version(require_browser_api.then_some(BROWSER_HELPER_API_VERSION))+}++fn shell_owner_with_min_version(min_version: Option<u32>) -> Option<String> {let owner_raw = gdbus_call_to(DBUS_DEST,DBUS_PATH,@@ -142,7 +153,7 @@ fn shell_owner(require_browser_api: bool) -> Option<String> {return None;}- if require_browser_api {+ if let Some(min_version) = min_version {let version_raw = gdbus_call_to(&owner,PATH,@@ -150,7 +161,7 @@ fn shell_owner(require_browser_api: bool) -> Option<String> {&[],Duration::from_millis(800),)?;- if parse_first_u32(&version_raw)? < BROWSER_HELPER_API_VERSION {+ if parse_first_u32(&version_raw)? < min_version {return None;}}@@ -523,6 +534,27 @@ pub fn click_pulse(x: i32, y: i32) {let _ = gdbus_call("ClickPulse", &[x.to_string(), y.to_string()]);}+/// Set the stable session-specific fill color for the compositor cursor.+pub fn set_cursor_color(fill_color: &str) {+ let _ = gdbus_call("SetCursorColor", &[fill_color.to_owned()]);+}++/// Update the compositor-owned cursor's semantic action state.+///+/// Callers gate this method on helper v5 so an older helper cannot silently+/// render the retired cursor artwork.+pub fn set_cursor_state(action: &str, delivery: &str, target: &str, active: bool) {+ let _ = gdbus_call(+ "SetCursorState",+ &[+ action.to_owned(),+ delivery.to_owned(),+ target.to_owned(),+ active.to_string(),+ ],+ );+}+/// Hide the agent cursor.pub fn hide_cursor() {let _ = gdbus_call("HideCursor", &[]);@@ -532,6 +564,11 @@ pub fn hide_cursor() {mod tests {use super::*;+ const EXTENSION_SOURCE: &str =+ include_str!("../../../../../wayland-helper/winrects@cua/extension.js");+ const EXTENSION_METADATA: &str =+ include_str!("../../../../../wayland-helper/winrects@cua/metadata.json");+#[test]fn parses_and_filters_shell_windows() {let raw = r#"('[{"id":46,"pid":6079,"title":"Sentinel's window","x":66,"y":32,"w":958,"h":736,"focused":true,"minimized":false,"visible":true,"stacking":2},{"id":47,"pid":6080,"title":"Hidden","x":0,"y":0,"w":100,"h":100,"minimized":true,"visible":false,"stacking":1}]',)"#;@@ -583,4 +620,34 @@ mod tests {assert!(windows[1].focused);assert_eq!(windows[1].info.xid, 47);}++ #[test]+ fn bundled_helper_v5_uses_the_compact_semantic_cursor() {+ assert!(EXTENSION_SOURCE.contains("GetVersion() { return 5; }"));+ assert!(EXTENSION_SOURCE.contains("SetCursorState"));+ assert!(EXTENSION_SOURCE.contains("SetCursorColor"));+ assert!(EXTENSION_SOURCE.contains("const DISPLAY_SIZE = 48;"));+ assert!(EXTENSION_SOURCE.contains("const GLOW_PADDING = 24;"));+ assert!(EXTENSION_SOURCE.contains("function drawCursorGlowShape"));+ assert!(EXTENSION_SOURCE.contains("function glowPath"));+ assert!(EXTENSION_SOURCE.contains("strokePath(cr, width, alpha, fillColor)"));+ assert!(EXTENSION_SOURCE.contains("width + 1.5"));+ assert!(EXTENSION_SOURCE.contains("width - 1"));+ assert!(EXTENSION_SOURCE.contains("createGlowSurface(this._fillColor)"));+ assert!(EXTENSION_SOURCE.contains("cr.translate(-GLOW_PADDING, -GLOW_PADDING);"));+ assert!(EXTENSION_METADATA.contains("\"version\":5"));++ for action in [+ "idle", "observe", "click", "drag", "scroll", "text", "key", "navigate", "app",+ "transfer", "record", "system",+ ] {+ assert!(+ EXTENSION_SOURCE.contains(&format!("'{action}'")),+ "missing semantic cursor state {action}"+ );+ }++ assert!(!EXTENSION_SOURCE.contains("const VERTS"));+ assert!(!EXTENSION_SOURCE.contains("setSourceRGBA(0.10, 0.75, 1.00"));+ }}diff --git a/libs/cua-driver/rust/crates/platform-macos/src/cursor/overlay.rs b/libs/cua-driver/rust/crates/platform-macos/src/cursor/overlay.rsindex 8190102920..cca30f5a87 100644--- a/libs/cua-driver/rust/crates/platform-macos/src/cursor/overlay.rs+++ b/libs/cua-driver/rust/crates/platform-macos/src/cursor/overlay.rs@@ -104,8 +104,9 @@ struct RenderMap {/// Build the `RenderState` for a lazily-created session cursor from the/// process launch template.fn render_state_for_key(template: &CursorConfig, key: &str) -> RenderState {- let _ = key;- RenderState::new(template.clone())+ let mut config = template.clone();+ config.cursor_id = key.to_owned();+ RenderState::new(config)}/// Apply one inbound [`OverlayMsg`] to the render map (drain step). Factored@@ -1091,6 +1092,12 @@ mod tests {use super::*;use std::collections::HashMap;+ #[test]+ fn keyed_render_state_carries_the_session_color_identity() {+ let state = render_state_for_key(&CursorConfig::default(), "session-blueprint");+ assert_eq!(state.core.cfg.cursor_id, "session-blueprint");+ }+fn window(window_id: u32, pid: i32, z_index: usize) -> crate::windows::WindowInfo {crate::windows::WindowInfo {window_id,diff --git a/libs/cua-driver/rust/crates/platform-windows/src/overlay.rs b/libs/cua-driver/rust/crates/platform-windows/src/overlay.rsindex ecc98fd187..ef2c61a099 100644--- a/libs/cua-driver/rust/crates/platform-windows/src/overlay.rs+++ b/libs/cua-driver/rust/crates/platform-windows/src/overlay.rs@@ -113,8 +113,9 @@ struct RenderMap {/// Build the `RenderState` for a lazily-created session cursor from the/// process launch template.fn render_state_for_key(template: &CursorConfig, key: &str) -> RenderState {- let _ = key;- RenderState::new(template.clone())+ let mut config = template.clone();+ config.cursor_id = key.to_owned();+ RenderState::new(config)}/// Apply one inbound [`OverlayMsg`] to the render map (drain step). Factored@@ -1153,6 +1154,12 @@ impl ZOrderEnforcer for WinZOrderEnforcer {mod tests {use super::*;+ #[test]+ fn keyed_render_state_carries_the_session_color_identity() {+ let state = render_state_for_key(&CursorConfig::default(), "session-blueprint");+ assert_eq!(state.core.cfg.cursor_id, "session-blueprint");+ }+fn empty_map() -> RenderMap {let mut cursors = IndexMap::new();cursors.insert(diff --git a/libs/cua-driver/scripts/_install-local-rust.sh b/libs/cua-driver/scripts/_install-local-rust.shindex 99b75a76f7..8328ff402f 100755--- a/libs/cua-driver/scripts/_install-local-rust.sh+++ b/libs/cua-driver/scripts/_install-local-rust.sh@@ -258,6 +258,27 @@ if [ -d "$SOURCE_SKILLS" ]; thenecho "${GREEN}staged skill pack at $STAGED_SKILLS${NORMAL}"fi+# Keep an already-installed GNOME helper aligned with the source-built driver.+# Installing the helper is still opt-in. Once present, however, leaving old+# compositor artwork behind after install-local creates a misleading+# cross-platform mismatch.+if [ "$OS" = "Linux" ]; then+ SOURCE_WAYLAND_HELPER="$REPO_ROOT/../wayland-helper"+ if [ -d "$SOURCE_WAYLAND_HELPER/winrects@cua" ]; then+ STAGED_WAYLAND_HELPER="$VERSIONED_DIR/wayland-helper"+ mkdir -p "$STAGED_WAYLAND_HELPER"+ cp -R "$SOURCE_WAYLAND_HELPER/." "$STAGED_WAYLAND_HELPER/"++ INSTALLED_WAYLAND_HELPER="${XDG_DATA_HOME:-$HOME/.local/share}/gnome-shell/extensions/winrects@cua"+ if [ -d "$INSTALLED_WAYLAND_HELPER" ]; then+ cp "$SOURCE_WAYLAND_HELPER/winrects@cua/metadata.json" \+ "$SOURCE_WAYLAND_HELPER/winrects@cua/extension.js" \+ "$INSTALLED_WAYLAND_HELPER/"+ echo "${GREEN}updated installed GNOME helper; reload the GNOME session to activate it${NORMAL}"+ fi+ fi+fi+# Atomically point `current` at the new versioned release dir.## Previous version used `ln -s … current.new` + `mv -Tf current.new current`diff --git a/libs/cua-driver/scripts/_install-rust.sh b/libs/cua-driver/scripts/_install-rust.shindex 0d38cf1fbe..804250c09c 100644--- a/libs/cua-driver/scripts/_install-rust.sh+++ b/libs/cua-driver/scripts/_install-rust.sh@@ -604,6 +604,7 @@ case "$LABEL" in*)SRC="$TMP_DIR/$BINARY_NAME"SRC_THEME="$TMP_DIR/cua-cursor-theme"+ SRC_WAYLAND_HELPER="$TMP_DIR/wayland-helper"SRC_APP="";;esac@@ -787,6 +788,18 @@ elseif [[ "$THEME_AVAILABLE" == "1" ]]; theninstall -m 0755 "$SRC_THEME" "$VERSIONED_DIR/cua-cursor-theme"fi+ if [[ -d "${SRC_WAYLAND_HELPER:-}" ]]; then+ mkdir -p "$VERSIONED_DIR/wayland-helper"+ cp -R "$SRC_WAYLAND_HELPER/." "$VERSIONED_DIR/wayland-helper/"++ INSTALLED_WAYLAND_HELPER="${XDG_DATA_HOME:-$HOME/.local/share}/gnome-shell/extensions/winrects@cua"+ if [[ -d "$INSTALLED_WAYLAND_HELPER" ]]; then+ cp "$SRC_WAYLAND_HELPER/winrects@cua/metadata.json" \+ "$SRC_WAYLAND_HELPER/winrects@cua/extension.js" \+ "$INSTALLED_WAYLAND_HELPER/"+ log "updated installed GNOME helper; reload the GNOME session to activate it"+ fi+ filog "installed $VERSIONED_DIR/$BINARY_NAME (version $VERSION, target $TARGET)"# `ln -sfn` would replace an existing dir-symlink in place but isdiff --git a/libs/cua-driver/scripts/cursor-gallery.sh b/libs/cua-driver/scripts/cursor-gallery.shnew file mode 100755index 0000000000..f4cd46c631--- /dev/null+++ b/libs/cua-driver/scripts/cursor-gallery.sh@@ -0,0 +1,149 @@+#!/usr/bin/env bash+set -euo pipefail++SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)+DRIVER_DIR=$(CDPATH= cd -- "$SCRIPT_DIR/.." && pwd)+REPO_ROOT=$(git -C "$DRIVER_DIR" rev-parse --show-toplevel)+GALLERY_DIR="$DRIVER_DIR/tools/cursor-gallery"+TARGET_DIR="$REPO_ROOT/target/cursor-gallery"+FRAMES_DIR="$TARGET_DIR/renderer-frames"+GENERATED_DIR="$GALLERY_DIR/generated"+PORT="${CURSOR_GALLERY_PORT:-3001}"++require() {+ command -v "$1" >/dev/null 2>&1 || {+ echo "cursor-gallery: missing required command: $1" >&2+ exit 1+ }+}++export_assets() {+ require cargo+ require ffmpeg+ mkdir -p "$FRAMES_DIR" "$GENERATED_DIR"+ cargo run --quiet \+ --manifest-path "$DRIVER_DIR/rust/Cargo.toml" \+ -p cursor-overlay \+ --example export_gallery_frames \+ --features theme-authoring \+ -- "$FRAMES_DIR"++ for group in actions modifiers combined; do+ mkdir -p "$GENERATED_DIR/$group"+ for state_dir in "$FRAMES_DIR/$group"/*; do+ state=$(basename "$state_dir")+ ffmpeg -y -loglevel error -framerate 30 \+ -i "$state_dir/%04d.png" \+ -c:v libvpx-vp9 -pix_fmt yuva420p -auto-alt-ref 0 \+ -crf 28 -b:v 0 -row-mt 1 \+ "$GENERATED_DIR/$group/$state.webm"+ done+ done+}++find_chrome() {+ if [[ -n "${CURSOR_GALLERY_CHROME:-}" ]]; then+ printf '%s\n' "$CURSOR_GALLERY_CHROME"+ elif [[ -x "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" ]]; then+ printf '%s\n' "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"+ elif command -v google-chrome >/dev/null 2>&1; then+ command -v google-chrome+ elif command -v chromium >/dev/null 2>&1; then+ command -v chromium+ else+ echo "cursor-gallery: Chrome not found; set CURSOR_GALLERY_CHROME" >&2+ exit 1+ fi+}++wait_for_url() {+ local url="$1"+ for _ in 1 2 3 4 5 6 7 8 9 10; do+ if curl -fsS "$url" >/dev/null 2>&1; then+ return+ fi+ sleep 1+ done+ echo "cursor-gallery: timed out waiting for $url" >&2+ exit 1+}++available_port() {+ python3 -c 'import socket; s = socket.socket(); s.bind(("127.0.0.1", 0)); print(s.getsockname()[1]); s.close()'+}++make_gif() {+ local name="$1"+ local frames="$2"+ local output="$3"+ local palette="$TARGET_DIR/$name-palette.png"+ ffmpeg -y -loglevel error -framerate 15 -i "$frames/%04d.png" \+ -vf "fps=15,scale=1080:-1:flags=lanczos,palettegen=stats_mode=diff" \+ "$palette"+ ffmpeg -y -loglevel error -framerate 15 -i "$frames/%04d.png" -i "$palette" \+ -lavfi "fps=15,scale=1080:-1:flags=lanczos,paletteuse=dither=bayer:bayer_scale=5:diff_mode=rectangle" \+ "$output"+}++export_docs() {+ require curl+ require node+ require python3+ export_assets++ chrome=$(find_chrome)+ http_port="${CURSOR_GALLERY_EXPORT_PORT:-$(available_port)}"+ cdp_port="${CURSOR_GALLERY_EXPORT_CDP_PORT:-$(available_port)}"+ capture_dir="$TARGET_DIR/docs-frames"+ docs_dir="$REPO_ROOT/docs/public/img/cua-driver/cursor-themes"+ profile_dir="$TARGET_DIR/chrome-profile"+ mkdir -p "$capture_dir" "$docs_dir" "$profile_dir"++ python3 -m http.server "$http_port" --bind 127.0.0.1 --directory "$REPO_ROOT" \+ >"$TARGET_DIR/server.log" 2>&1 &+ server_pid=$!+ "$chrome" --headless=new --disable-gpu --hide-scrollbars \+ --autoplay-policy=no-user-gesture-required --force-device-scale-factor=1 \+ --window-size=1600,2200 --remote-debugging-port="$cdp_port" \+ --user-data-dir="$profile_dir" about:blank \+ >"$TARGET_DIR/chrome.log" 2>&1 &+ chrome_pid=$!+ trap 'kill "$server_pid" "$chrome_pid" 2>/dev/null || true' EXIT++ wait_for_url "http://127.0.0.1:$http_port/"+ wait_for_url "http://127.0.0.1:$cdp_port/json/version"+ CDP_ENDPOINT="http://127.0.0.1:$cdp_port" \+ PAGE_URL="http://127.0.0.1:$http_port/libs/cua-driver/tools/cursor-gallery/" \+ FRAME_URL_ROOT="http://127.0.0.1:$http_port/target/cursor-gallery/renderer-frames" \+ node --experimental-websocket "$GALLERY_DIR/capture-gallery.mjs" "$capture_dir"++ make_gif \+ "action-animations" \+ "$capture_dir/actions" \+ "$docs_dir/action-animations.gif"+ make_gif \+ "delivery-target-context" \+ "$capture_dir/modifiers" \+ "$docs_dir/delivery-target-context.gif"++ echo "cursor-gallery: wrote documentation GIFs to $docs_dir"+}++case "${1:-help}" in+ assets)+ export_assets+ ;;+ serve)+ require python3+ export_assets+ echo "cursor-gallery: http://127.0.0.1:$PORT"+ exec python3 -m http.server "$PORT" --bind 127.0.0.1 --directory "$GALLERY_DIR"+ ;;+ export-docs)+ export_docs+ ;;+ *)+ echo "usage: $0 {assets|serve|export-docs}" >&2+ exit 2+ ;;+esacdiff --git a/libs/cua-driver/scripts/tests/test_install_local.py b/libs/cua-driver/scripts/tests/test_install_local.pyindex e954785c66..a5d80c268b 100644--- a/libs/cua-driver/scripts/tests/test_install_local.py+++ b/libs/cua-driver/scripts/tests/test_install_local.py@@ -29,6 +29,11 @@ def test_installer_stages_binary_from_custom_cargo_target(shutil.copy2(INSTALL_LOCAL, scripts_dir / INSTALL_LOCAL.name)shutil.copy2(LOCAL_SIGNING, scripts_dir / LOCAL_SIGNING.name)+ wayland_helper = fixture_root / "wayland-helper/winrects@cua"+ wayland_helper.mkdir(parents=True)+ (wayland_helper / "metadata.json").write_text('{"version":5}\n', encoding="utf-8")+ (wayland_helper / "extension.js").write_text("// semantic cursor v5\n", encoding="utf-8")+stale_binary = rust_dir / "target/release/cua-driver"_write_executable(stale_binary, "printf 'stale workspace target\\n'")@@ -64,12 +69,17 @@ esac_write_executable(fake_bin / "pkill", "exit 0")local_home = tmp_path / "local-home"+ user_home = tmp_path / "home"+ installed_helper = user_home / ".local/share/gnome-shell/extensions/winrects@cua"+ installed_helper.mkdir(parents=True)+ (installed_helper / "metadata.json").write_text('{"version":4}\n', encoding="utf-8")+ (installed_helper / "extension.js").write_text("// legacy cursor\n", encoding="utf-8")install_bin = tmp_path / "install-bin"env = os.environ.copy()env.pop("SUDO_USER", None)env.update({- "HOME": str(tmp_path / "home"),+ "HOME": str(user_home),"PATH": f"{fake_bin}:/usr/bin:/bin","CARGO_TARGET_DIR": cargo_target_dir,"EXPECTED_CARGO_TARGET_DIR": str(custom_target),@@ -97,3 +107,8 @@ esacassert (local_home / "packages/current/cua-cursor-theme").read_text() == "fresh cursor theme compiler\n"+ assert (+ local_home / "packages/current/wayland-helper/winrects@cua/metadata.json"+ ).read_text() == '{"version":5}\n'+ assert (installed_helper / "metadata.json").read_text() == '{"version":5}\n'+ assert (installed_helper / "extension.js").read_text() == "// semantic cursor v5\n"diff --git a/libs/cua-driver/tools/cursor-gallery/.gitignore b/libs/cua-driver/tools/cursor-gallery/.gitignorenew file mode 100644index 0000000000..9ab870da89--- /dev/null+++ b/libs/cua-driver/tools/cursor-gallery/.gitignore@@ -0,0 +1 @@+generated/diff --git a/libs/cua-driver/tools/cursor-gallery/README.md b/libs/cua-driver/tools/cursor-gallery/README.mdnew file mode 100644index 0000000000..4b59c0f445--- /dev/null+++ b/libs/cua-driver/tools/cursor-gallery/README.md@@ -0,0 +1,16 @@+# Cursor gallery++Maintainer preview for the production `cua.default` renderer. Generated media+is built from `cursor-overlay` and is intentionally not committed.++From the repository root:++```bash+./libs/cua-driver/scripts/cursor-gallery.sh serve+./libs/cua-driver/scripts/cursor-gallery.sh export-docs+```++`serve` opens no browser and serves the gallery at `http://127.0.0.1:3001`.+`export-docs` requires Chrome, Node.js with WebSocket support, Python 3, and+ffmpeg. It regenerates the public documentation GIFs deterministically from the+same rendered frames.diff --git a/libs/cua-driver/tools/cursor-gallery/app.js b/libs/cua-driver/tools/cursor-gallery/app.jsnew file mode 100644index 0000000000..1251717c44--- /dev/null+++ b/libs/cua-driver/tools/cursor-gallery/app.js@@ -0,0 +1,94 @@+const actions = [+ ['idle', 'Idle', 'Waiting between actions'],+ ['observe', 'Observe', 'Reading the screen or interface'],+ ['click', 'Click', 'Clicking or selecting an element'],+ ['drag', 'Drag', 'Dragging an element or selection'],+ ['scroll', 'Scroll', 'Scrolling through content'],+ ['text', 'Text', 'Typing or filling text'],+ ['key', 'Key', 'Pressing a key or shortcut'],+ ['navigate', 'Navigate', 'Moving, navigating, or changing tabs'],+ ['app', 'App', 'Managing an application or window'],+ ['transfer', 'Transfer', 'Uploading, downloading, copying, or moving files'],+ ['record', 'Record', 'Recording or replaying a trajectory'],+ ['system', 'System', 'Managing sessions, permissions, or configuration'],+];++const modifiers = [+ ['background', 'Background', 'Delivering input without foreground focus'],+ ['foreground', 'Foreground', 'Delivering input to the active foreground window'],+ ['ax', 'AX', 'Using accessibility semantics'],+ ['pixel', 'Pixel', 'Using exact pixel coordinates'],+ ['browser', 'Browser', 'Using typed browser control'],+ ['desktop', 'Desktop', 'Using native desktop control'],+];++const tones = ['light', 'dark', 'blue'];+let playing = true;+let backgroundMode = 'mixed';++function card([id, label, description], index, group) {+ const article = document.createElement('article');+ article.className = `state-card card-${tones[index % tones.length]}`;+ article.tabIndex = 0;+ article.dataset.index = String(index);+ article.innerHTML = `+ <div class="demo">+ <video class="cursor-video" src="./generated/${group}/${id}.webm"+ data-group="${group}" data-state="${id}"+ autoplay loop muted playsinline aria-hidden="true"></video>+ </div>+ <div class="card-copy">+ <h3>${label}</h3>+ <p>${description}</p>+ </div>+ `;+ return article;+}++function render() {+ const actionGrid = document.querySelector('#actions-grid');+ const modifierGrid = document.querySelector('#modifiers-grid');+ actions.forEach((state, index) => actionGrid.append(card(state, index, 'actions')));+ modifiers.forEach((state, index) => modifierGrid.append(card(state, index, 'modifiers')));+}++function videos() {+ return [...document.querySelectorAll('.cursor-video')];+}++document.querySelector('#play-toggle').addEventListener('click', (event) => {+ playing = !playing;+ event.currentTarget.textContent = playing ? 'Pause' : 'Play';+ videos().forEach((video) => {+ if (playing) void video.play();+ else video.pause();+ });+});++document.querySelector('#replay').addEventListener('click', () => {+ videos().forEach((video) => {+ video.currentTime = 0;+ if (playing) void video.play();+ });+});++document.querySelector('#speed').addEventListener('change', (event) => {+ const speed = Number(event.currentTarget.value);+ videos().forEach((video) => {+ video.playbackRate = speed;+ });+});++document.querySelector('#background-toggle').addEventListener('click', (event) => {+ const options = ['mixed', 'light', 'dark', 'blue'];+ backgroundMode = options[(options.indexOf(backgroundMode) + 1) % options.length];+ event.currentTarget.textContent = backgroundMode[0].toUpperCase() + backgroundMode.slice(1);+ document.querySelectorAll('.state-card').forEach((element) => {+ element.classList.remove('card-light', 'card-dark', 'card-blue');+ const index = Number(element.dataset.index);+ const tone = backgroundMode === 'mixed' ? tones[index % tones.length] : backgroundMode;+ element.classList.add(`card-${tone}`);+ });+});++render();diff --git a/libs/cua-driver/tools/cursor-gallery/capture-gallery.mjs b/libs/cua-driver/tools/cursor-gallery/capture-gallery.mjsnew file mode 100644index 0000000000..03657c594a--- /dev/null+++ b/libs/cua-driver/tools/cursor-gallery/capture-gallery.mjs@@ -0,0 +1,147 @@+import fs from 'node:fs/promises';+import path from 'node:path';++const endpoint = process.env.CDP_ENDPOINT ?? 'http://127.0.0.1:9229';+const pageUrl = process.env.PAGE_URL ?? 'http://127.0.0.1:3001/';+const frameUrlRoot =+ process.env.FRAME_URL_ROOT ?? 'http://127.0.0.1:3001/target/cursor-gallery/renderer-frames';+const outputRoot = process.argv[2];+const fps = 15;+const duration = 4;++if (!outputRoot || typeof WebSocket === 'undefined') {+ throw new Error('usage: node --experimental-websocket capture-gallery.mjs OUTPUT_DIR');+}++const tabs = await fetch(`${endpoint}/json/list`).then((response) => response.json());+const tab = tabs.find((candidate) => candidate.type === 'page');+if (!tab?.webSocketDebuggerUrl) {+ throw new Error(`No page target found at ${endpoint}`);+}++const socket = new WebSocket(tab.webSocketDebuggerUrl);+await new Promise((resolve, reject) => {+ socket.addEventListener('open', resolve, { once: true });+ socket.addEventListener('error', reject, { once: true });+});++let nextId = 1;+const pending = new Map();+socket.addEventListener('message', (event) => {+ const message = JSON.parse(event.data);+ const waiter = pending.get(message.id);+ if (!waiter) return;+ pending.delete(message.id);+ if (message.error) waiter.reject(new Error(JSON.stringify(message.error)));+ else waiter.resolve(message.result);+});++function command(method, params = {}) {+ const id = nextId++;+ return new Promise((resolve, reject) => {+ pending.set(id, { resolve, reject });+ socket.send(JSON.stringify({ id, method, params }));+ });+}++async function evaluate(expression, awaitPromise = false) {+ const result = await command('Runtime.evaluate', {+ expression,+ awaitPromise,+ returnByValue: true,+ });+ if (result.exceptionDetails) throw new Error(result.exceptionDetails.text);+ return result.result.value;+}++await fs.mkdir(path.join(outputRoot, 'actions'), { recursive: true });+await fs.mkdir(path.join(outputRoot, 'modifiers'), { recursive: true });+await command('Page.enable');+await command('Runtime.enable');+await command('Emulation.setDeviceMetricsOverride', {+ width: 1600,+ height: 2200,+ deviceScaleFactor: 1,+ mobile: false,+});+await command('Page.navigate', { url: pageUrl });+await evaluate(+ `new Promise((resolve, reject) => {+ const deadline = Date.now() + 15000;+ const ready = () => {+ const videos = [...document.querySelectorAll(".cursor-video")];+ if (videos.length === 19 && videos.every((video) => video.readyState >= 2)) resolve(true);+ else if (Date.now() > deadline) reject(new Error("Timed out waiting for videos"));+ else setTimeout(ready, 50);+ };+ ready();+ })`,+ true+);++await evaluate(`(() => {+ for (const video of document.querySelectorAll("video.cursor-video")) {+ const image = document.createElement("img");+ image.className = video.className;+ image.dataset.group = video.dataset.group;+ image.dataset.state = video.dataset.state;+ image.alt = "";+ image.setAttribute("aria-hidden", "true");+ video.replaceWith(image);+ }+ return document.querySelectorAll("img.cursor-video").length;+})()`);++const clips = await evaluate(`(() => {+ const sections = [...document.querySelectorAll(".gallery-section")];+ const clipFor = (section, bottomPadding) => {+ const heading = section.querySelector(".section-heading").getBoundingClientRect();+ const grid = section.querySelector(".state-grid").getBoundingClientRect();+ const rect = section.getBoundingClientRect();+ return {+ x: Math.floor(rect.left - 30),+ y: Math.floor(heading.top - 28),+ width: Math.ceil(rect.width + 60),+ height: Math.ceil(grid.bottom - heading.top + 28 + bottomPadding)+ };+ };+ return { actions: clipFor(sections[0], 28), modifiers: clipFor(sections[1], 14) };+})()`);++for (let frame = 0; frame < fps * duration; frame += 1) {+ const sourceFrame = frame * 2;+ const loaded = await evaluate(+ `Promise.all([...document.querySelectorAll("img.cursor-video")].map((image) => {+ const src = ${JSON.stringify(frameUrlRoot)} + "/" ++ image.dataset.group + "/" + image.dataset.state + "/" ++ String(${sourceFrame}).padStart(4, "0") + ".png";+ if (image.src === src && image.complete) return Promise.resolve();+ return new Promise((resolve) => {+ const finish = () => resolve();+ image.addEventListener("load", finish, { once: true });+ image.addEventListener("error", finish, { once: true });+ image.src = src;+ setTimeout(finish, 1000);+ });+ })).then(() => [...document.querySelectorAll("img.cursor-video")]+ .every((image) => image.complete && image.naturalWidth > 0))`,+ true+ );+ if (!loaded) throw new Error(`Failed to load renderer frame ${sourceFrame}`);++ for (const [name, clip] of Object.entries(clips)) {+ const capture = await command('Page.captureScreenshot', {+ format: 'png',+ fromSurface: true,+ captureBeyondViewport: true,+ clip: { ...clip, scale: 1 },+ });+ await fs.writeFile(+ path.join(outputRoot, name, `${String(frame).padStart(4, '0')}.png`),+ Buffer.from(capture.data, 'base64')+ );+ }+}++socket.close();+console.log(JSON.stringify({ clips, fps, duration }, null, 2));diff --git a/libs/cua-driver/tools/cursor-gallery/index.html b/libs/cua-driver/tools/cursor-gallery/index.htmlnew file mode 100644index 0000000000..3e32e951c5--- /dev/null+++ b/libs/cua-driver/tools/cursor-gallery/index.html@@ -0,0 +1,90 @@+<!doctype html>+<html lang="en">+ <head>+ <meta charset="UTF-8" />+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />+ <title>Cua cursor gallery</title>+ <link rel="icon" href="data:," />+ <link rel="stylesheet" href="./styles.css" />+ </head>+ <body>+ <main class="page-shell">+ <header class="hero">+ <div>+ <p class="eyebrow">CUA.DEFAULT · EXACT RENDERER PREVIEW</p>+ <h1>Session-colored semantic motion</h1>+ <p class="lede">+ Exact frames from the Cua Driver native renderer. Every state keeps the shared floating+ motion, with its semantic animation layered on top.+ </p>+ </div>+ <div class="controls" aria-label="Animation controls">+ <button id="play-toggle" type="button">Pause</button>+ <button id="replay" type="button">Replay</button>+ <label>+ <span>Speed</span>+ <select id="speed" aria-label="Animation speed">+ <option value="0.5">0.5×</option>+ <option value="1" selected>1×</option>+ <option value="1.5">1.5×</option>+ <option value="2">2×</option>+ </select>+ </label>+ <button id="background-toggle" type="button">Mixed</button>+ </div>+ </header>++ <section class="gallery-section" aria-labelledby="actions-title">+ <div class="section-heading">+ <div>+ <p class="section-count">12 states</p>+ <h2 id="actions-title">Action animations</h2>+ </div>+ <p>Hover or focus a card to bring its motion forward.</p>+ </div>+ <div id="actions-grid" class="state-grid"></div>+ </section>++ <section class="gallery-section" aria-labelledby="modifiers-title">+ <div class="section-heading">+ <div>+ <p class="section-count">6 modifiers</p>+ <h2 id="modifiers-title">Delivery and target context</h2>+ </div>+ <p>Modifiers can appear together with any action.</p>+ </div>+ <div id="modifiers-grid" class="state-grid"></div>++ <article class="combined-card">+ <div>+ <p class="section-count">Combined state</p>+ <h3>Foreground click at an exact pixel</h3>+ <p>Delivery stays on the left and target context stays on the right.</p>+ </div>+ <div class="demo">+ <video+ class="cursor-video"+ src="./generated/combined/foreground-pixel-click.webm"+ data-group="combined"+ data-state="foreground-pixel-click"+ autoplay+ loop+ muted+ playsinline+ ></video>+ </div>+ <div class="legend">+ <span>○ Foreground delivery</span>+ <span>□ Pixel target</span>+ </div>+ </article>+ </section>++ <footer>+ <span>Preview scale is enlarged for review.</span>+ <span>Production cursor size remains 48 points.</span>+ </footer>+ </main>+ <script src="./app.js"></script>+ </body>+</html>diff --git a/libs/cua-driver/tools/cursor-gallery/styles.css b/libs/cua-driver/tools/cursor-gallery/styles.cssnew file mode 100644index 0000000000..4dc33563c8--- /dev/null+++ b/libs/cua-driver/tools/cursor-gallery/styles.css@@ -0,0 +1,287 @@+:root {+ --ink: #15171b;+ --muted: #61646b;+ --paper: #e9e9e5;+ --line: rgba(21, 23, 27, 0.11);+}++* {+ box-sizing: border-box;+}++html,+body {+ margin: 0;+ color: var(--ink);+ background: var(--paper);+ font-family:+ Inter,+ ui-sans-serif,+ system-ui,+ -apple-system,+ sans-serif;+}++button,+select {+ font: inherit;+}++.page-shell {+ width: min(1480px, 100%);+ margin: 0 auto;+ padding: 66px 62px 38px;+}++.hero {+ display: grid;+ grid-template-columns: minmax(0, 1fr) auto;+ gap: 44px;+ align-items: end;+ margin-bottom: 58px;+}++.eyebrow,+.section-count {+ margin: 0 0 12px;+ font:+ 700 11px/1 ui-monospace,+ monospace;+ letter-spacing: 0.14em;+ text-transform: uppercase;+}++h1 {+ max-width: 760px;+ margin: 0;+ font-size: clamp(40px, 5vw, 72px);+ font-weight: 650;+ letter-spacing: -0.055em;+ line-height: 0.98;+}++.lede {+ max-width: 750px;+ margin: 22px 0 0;+ color: var(--muted);+ font-size: 17px;+ line-height: 1.55;+}++.controls {+ display: flex;+ flex-wrap: wrap;+ justify-content: flex-end;+ gap: 9px;+}++.controls button,+.controls label {+ min-height: 42px;+ border: 1px solid var(--line);+ border-radius: 12px;+ background: rgba(255, 255, 255, 0.62);+}++.controls button {+ padding: 0 14px;+ cursor: pointer;+}++.controls label {+ display: flex;+ align-items: center;+ gap: 8px;+ padding: 0 8px 0 13px;+ color: var(--muted);+ font-size: 13px;+}++.controls select {+ border: 0;+ border-radius: 8px;+ background: white;+ padding: 6px 8px;+}++.gallery-section + .gallery-section {+ margin-top: 52px;+}++.section-heading {+ display: flex;+ justify-content: space-between;+ gap: 24px;+ align-items: end;+ margin-bottom: 18px;+}++.section-heading h2 {+ margin: 0;+ font-size: 24px;+ letter-spacing: -0.025em;+}++.section-heading p:last-child {+ margin: 0 0 2px;+ color: var(--muted);+ font-size: 14px;+}++.state-grid {+ display: grid;+ grid-template-columns: repeat(6, minmax(0, 1fr));+ gap: 14px;+}++.state-card {+ min-height: 282px;+ border: 1px solid var(--line);+ border-radius: 22px;+ overflow: hidden;+ transition:+ transform 180ms ease,+ box-shadow 180ms ease;+}++.state-card:hover,+.state-card:focus-visible {+ transform: translateY(-4px);+ box-shadow: 0 18px 44px rgba(25, 31, 38, 0.13);+}++.card-light {+ background: #fafaf8;+}++.card-dark {+ background: #181a1f;+ color: white;+}++.card-blue {+ background: #70c3e4;+}++.demo {+ display: grid;+ place-items: center;+ height: 206px;+ overflow: hidden;+}++.cursor-video {+ display: block;+ /*+ * Renderer frames preserve the full 256 px transparent capture canvas.+ * The frame exporter renders at 1.5× backing scale. Scale its centered+ * 164 px layout box to preserve that 72 px review size after the 256 px+ * capture canvas is fitted into the card.+ */+ width: 164px;+ height: 164px;+ object-fit: contain;+ transform: scale(1.56);+ transition: transform 180ms ease;+}++.state-card:hover .cursor-video,+.state-card:focus-visible .cursor-video {+ transform: scale(1.69);+}++.card-copy {+ padding: 0 17px 17px;+ text-align: center;+}++.card-copy h3 {+ margin: 2px 0 7px;+ font:+ 700 12px/1 ui-monospace,+ monospace;+ letter-spacing: 0.13em;+ text-transform: uppercase;+}++.card-copy p {+ min-height: 34px;+ margin: 0;+ opacity: 0.58;+ font-size: 12px;+ line-height: 1.4;+}++.combined-card {+ display: grid;+ grid-template-columns: minmax(280px, 1fr) 260px minmax(250px, 0.75fr);+ gap: 32px;+ align-items: center;+ margin-top: 16px;+ padding: 28px 34px;+ border-radius: 22px;+ background: #181a1f;+ color: white;+}++.combined-card h3 {+ margin: 0 0 10px;+ font-size: 22px;+}++.combined-card p:last-child,+.legend {+ color: rgba(255, 255, 255, 0.65);+ font-size: 13px;+}++.legend {+ display: grid;+ gap: 13px;+}++footer {+ display: flex;+ justify-content: space-between;+ margin-top: 28px;+ padding: 18px 22px;+ border: 1px solid var(--line);+ border-radius: 16px;+ background: rgba(255, 255, 255, 0.56);+ color: var(--muted);+ font-size: 13px;+}++@media (max-width: 1160px) {+ .state-grid {+ grid-template-columns: repeat(4, minmax(0, 1fr));+ }++ .hero {+ grid-template-columns: 1fr;+ }++ .controls {+ justify-content: flex-start;+ }+}++@media (max-width: 760px) {+ .page-shell {+ padding: 40px 18px 26px;+ }++ .state-grid {+ grid-template-columns: repeat(2, minmax(0, 1fr));+ }++ .section-heading,+ .combined-card {+ grid-template-columns: 1fr;+ }++ .section-heading {+ align-items: start;+ flex-direction: column;+ }+}diff --git a/libs/cua-driver/wayland-helper/README.md b/libs/cua-driver/wayland-helper/README.mdindex f6437f2056..523a0eb7e3 100644--- a/libs/cua-driver/wayland-helper/README.md+++ b/libs/cua-driver/wayland-helper/README.md@@ -22,8 +22,16 @@ It exposes `org.cua.WinRects` on the session bus:input from leaking into whichever application happened to be focused.- `Capture() -> png_base64` — capture the compositor stage through Shell'sscreenshot API. cua-driver crops it with the same authoritative geometry.-- `MoveCursor(x,y)` / `ClickPulse(x,y)` / `HideCursor()` — render the agent- cursor as a Clutter actor on the compositor stage.+- `MoveCursor(x,y)` / `ClickPulse(x,y)` / `HideCursor()` — position and hide+ the agent cursor as a Clutter actor on the compositor stage.+- `SetCursorState(action,delivery,target,active)` — render the same 12 semantic+ action states and delivery/target modifiers as the cross-platform+ `cua.default` cursor theme. The marks use session-colored centers, white+ outlines, and a tighter matching glow, while the pointer uses the larger+ cursor-shaped glow. This method was added in helper v5.+- `SetCursorColor(fill_color)` — apply the stable per-session fill selected by+ cua-driver. The helper validates the `#RRGGBB` value, updates the matching+ glow, and keeps a white pointer outline.It runs in the shell's privileged context, so **no xdg-desktop-portal grant** isneeded (unlike libei/RemoteDesktop).@@ -31,7 +39,8 @@ needed (unlike libei/RemoteDesktop).## Install```-./install.sh # copies to ~/.local/share/gnome-shell/extensions + enables+~/.cua-driver/packages/current/wayland-helper/install.sh+# From a source checkout, use ./install.sh in this directory.# then log out/in once (GNOME loads extensions only at session startup)gnome-extensions info winrects@cua # -> State: ACTIVE```@@ -41,6 +50,10 @@ still work when it is absent, but pixel geometry, the Shell cursor, and safeforeground portal input are unavailable. cua-driver refuses focus-bound inputinstead of injecting into an unverified target.+The semantic cursor requires helper v5. When an older helper is still loaded,+cua-driver does not draw its legacy cursor. Re-run the helper installer, then+reload the GNOME session so the new compositor-owned artwork becomes active.+Browser setup and consent are held to a stricter boundary: helper API v4 ornewer must be served by the verified GNOME Shell owner. The driver addressesthat owner's unique D-Bus name, so another same-session process cannot replacediff --git a/libs/cua-driver/wayland-helper/winrects@cua/extension.js b/libs/cua-driver/wayland-helper/winrects@cua/extension.jsindex 87ee3f7066..c51927b662 100644--- a/libs/cua-driver/wayland-helper/winrects@cua/extension.js+++ b/libs/cua-driver/wayland-helper/winrects@cua/extension.js@@ -17,21 +17,420 @@ const IFACE = `<node><interface name="org.cua.WinRects"><method name="Activate"><arg type="u" direction="in" name="id"/><arg type="b" direction="out" name="activated"/></method><method name="MoveCursor"><arg type="i" direction="in" name="x"/><arg type="i" direction="in" name="y"/></method><method name="ClickPulse"><arg type="i" direction="in" name="x"/><arg type="i" direction="in" name="y"/></method>+<method name="SetCursorColor"><arg type="s" direction="in" name="fill_color"/></method>+<method name="SetCursorState"><arg type="s" direction="in" name="action"/><arg type="s" direction="in" name="delivery"/><arg type="s" direction="in" name="target"/><arg type="b" direction="in" name="active"/></method><method name="HideCursor"></method></interface></node>`;-// The same agent cursor cua-driver renders on every other platform: the-// procedural gradient arrow from cursor-overlay (verts tip-at-+x, `default_blue`-// palette). Rotated to point up-left and translated so the tip sits at the-// actor's (TIPX, TIPY); MoveCursor/ClickPulse place that tip on the target.-const VERTS = [[14, 0], [-8, -9], [-3, 0], [-8, 9]];-const ANGLE = Math.PI * 1.25; // tip points up-left-const TIPX = 2, TIPY = 2;-function arrowPoints() {- const ca = Math.cos(ANGLE), sa = Math.sin(ANGLE);- const rot = VERTS.map(([x, y]) => [ca * x - sa * y, sa * x + ca * y]);- const tx = TIPX - rot[0][0], ty = TIPY - rot[0][1];- return rot.map(([x, y]) => [x + tx, y + ty]);+// GNOME cannot host the Rust renderer directly, so this Shell actor mirrors+// the embedded cua.default vector theme and semantic state vocabulary.+const CANVAS_SIZE = 128;+const DISPLAY_SIZE = 48;+const ACTOR_SIZE = 112;+const ACTOR_CENTER = ACTOR_SIZE / 2;+const SCALE = DISPLAY_SIZE / CANVAS_SIZE;+const FLOAT_DURATION = 4.0;+const GLOW_SURFACE_SCALE = 3;+const GLOW_PADDING = 24;+const ACTIONS = new Set([+ 'idle', 'observe', 'click', 'drag', 'scroll', 'text',+ 'key', 'navigate', 'app', 'transfer', 'record', 'system',+]);+const ONE_SHOT_ACTIONS = new Set(['click', 'key', 'navigate', 'app', 'system']);+const ACTION_DURATIONS = {+ idle: 4.0,+ click: 0.67,+ observe: 1.6,+ drag: 1.6,+ scroll: 1.6,+ text: 1.6,+ key: 1.6,+ navigate: 1.6,+ app: 1.6,+ transfer: 1.6,+ record: 1.6,+ system: 1.6,+};++function nowSeconds() {+ return GLib.get_monotonic_time() / 1_000_000;+}++function easeInOut(value) {+ const t = Math.max(0, Math.min(1, value));+ return t * t * (3 - 2 * t);+}++function triangleWave(value) {+ const t = ((value % 1) + 1) % 1;+ return t < 0.5 ? t * 2 : (1 - t) * 2;+}++function setInk(cr, alpha = 1) {+ cr.setSourceRGBA(1, 1, 1, alpha);+}++function setPaper(cr, alpha = 1) {+ cr.setSourceRGBA(1, 1, 1, alpha);+}++function setFill(cr, color, alpha = 1) {+ cr.setSourceRGBA(color[0] / 255, color[1] / 255, color[2] / 255, alpha);+}++function glowPath(cr, width, alpha, glowColor) {+ if (!glowColor)+ return;+ const layers = 12;+ const outerExpansion = 13;+ const innerExpansion = 2.5;+ const maxOpacity = 0.17;+ let accumulatedOpacity = 0;+ for (let layer = 0; layer < layers; layer++) {+ const progress = (layer + 1) / layers;+ const expansion = outerExpansion + (innerExpansion - outerExpansion) * progress;+ const targetOpacity = maxOpacity * Math.max(0, Math.min(1, alpha)) *+ Math.pow(progress, 1.6);+ const layerOpacity = (targetOpacity - accumulatedOpacity) /+ Math.max(0.001, 1 - accumulatedOpacity);+ accumulatedOpacity = targetOpacity;+ cr.setLineWidth(width + expansion);+ cr.setLineCap(Cairo.LineCap.ROUND);+ cr.setLineJoin(Cairo.LineJoin.ROUND);+ setFill(cr, glowColor, layerOpacity);+ cr.strokePreserve();+ }+}++function strokePath(cr, width, alpha = 1, glowColor = null) {+ glowPath(cr, width, alpha, glowColor);+ cr.setLineWidth(glowColor ? width + 1.5 : width);+ cr.setLineCap(Cairo.LineCap.ROUND);+ cr.setLineJoin(Cairo.LineJoin.ROUND);+ setInk(cr, alpha);+ if (!glowColor) {+ cr.stroke();+ return;+ }+ cr.strokePreserve();+ cr.setLineWidth(Math.max(1.5, width - 1));+ setFill(cr, glowColor, alpha);+ cr.stroke();+}++function fillPath(cr, glowWidth, alpha = 1, glowColor = null) {+ glowPath(cr, glowWidth, alpha, glowColor);+ cr.setLineWidth(3);+ cr.setLineCap(Cairo.LineCap.ROUND);+ cr.setLineJoin(Cairo.LineJoin.ROUND);+ setInk(cr, alpha);+ cr.strokePreserve();+ setFill(cr, glowColor, alpha);+ cr.fill();+}++function linePath(cr, points, width = 4, alpha = 1, glowColor = null) {+ if (points.length === 0)+ return;+ cr.moveTo(points[0][0], points[0][1]);+ for (let i = 1; i < points.length; i++)+ cr.lineTo(points[i][0], points[i][1]);+ strokePath(cr, width, alpha, glowColor);+}++function roundedRect(cr, x, y, width, height, radius) {+ const r = Math.max(0, Math.min(radius, width / 2, height / 2));+ const k = 0.5522848;+ cr.moveTo(x + r, y);+ cr.lineTo(x + width - r, y);+ cr.curveTo(x + width - r + r * k, y, x + width, y + r - r * k, x + width, y + r);+ cr.lineTo(x + width, y + height - r);+ cr.curveTo(x + width, y + height - r + r * k, x + width - r + r * k, y + height, x + width - r, y + height);+ cr.lineTo(x + r, y + height);+ cr.curveTo(x + r - r * k, y + height, x, y + height - r + r * k, x, y + height - r);+ cr.lineTo(x, y + r);+ cr.curveTo(x, y + r - r * k, x + r - r * k, y, x + r, y);+ cr.closePath();+}++function traceCursorBody(cr) {+ cr.moveTo(55, 30);+ cr.curveTo(48, 28, 42, 33, 43, 41);+ cr.lineTo(64, 98);+ cr.curveTo(67, 106, 73, 106, 77, 99);+ cr.lineTo(86, 79);+ cr.curveTo(88, 75, 91, 72, 95, 70);+ cr.lineTo(108, 63);+ cr.curveTo(115, 59, 114, 53, 107, 50);+ cr.closePath();+}++function drawCursorGlowShape(cr, fillColor) {+ const layers = 36;+ const outerWidth = 44;+ const innerWidth = 7;+ const maxOpacity = 0.34;+ let accumulatedOpacity = 0;++ for (let layer = 0; layer < layers; layer++) {+ const progress = (layer + 1) / layers;+ const width = outerWidth + (innerWidth - outerWidth) * progress;+ const targetOpacity = maxOpacity * Math.pow(progress, 1.65);+ const layerOpacity =+ (targetOpacity - accumulatedOpacity) / Math.max(0.001, 1 - accumulatedOpacity);+ accumulatedOpacity = targetOpacity;+ if (layerOpacity <= 0)+ continue;++ traceCursorBody(cr);+ cr.setLineWidth(width);+ cr.setLineCap(Cairo.LineCap.ROUND);+ cr.setLineJoin(Cairo.LineJoin.ROUND);+ setFill(cr, fillColor, layerOpacity);+ cr.stroke();+ }+}++function createGlowSurface(fillColor) {+ const surface = new Cairo.ImageSurface(+ Cairo.Format.ARGB32,+ (CANVAS_SIZE + GLOW_PADDING * 2) * GLOW_SURFACE_SCALE,+ (CANVAS_SIZE + GLOW_PADDING * 2) * GLOW_SURFACE_SCALE+ );+ const cr = new Cairo.Context(surface);+ cr.scale(GLOW_SURFACE_SCALE, GLOW_SURFACE_SCALE);+ cr.translate(GLOW_PADDING, GLOW_PADDING);+ drawCursorGlowShape(cr, fillColor);+ cr.$dispose();+ return surface;+}++function sharedFloatMotion(progress) {+ const angle = progress * Math.PI * 2;+ return {+ dx: Math.sin(angle) * 5,+ dy: Math.cos(angle) * 6 - 5,+ rotation: Math.cos(angle) * (2.5 * Math.PI / 180),+ scale: 1,+ };+}++function cursorBodyMotion(progress, action) {+ let dx = 0;+ let dy = 0;+ let rotation = 0;+ let scale = 1;++ if (action === 'click') {+ if (progress < 0.35)+ scale = 1 - easeInOut(progress / 0.35) * 0.07;+ else if (progress < 0.6)+ scale = 0.93 + easeInOut((progress - 0.35) / 0.25) * 0.10;+ else+ scale = 1.03 - easeInOut((progress - 0.6) / 0.4) * 0.03;+ } else if (action === 'drag') {+ const held = easeInOut(triangleWave(progress));+ dx = held * 7;+ dy = held * 3;+ }++ return {dx, dy, rotation, scale};+}++function applyCursorBodyMotion(cr, motion) {+ cr.translate(64 + motion.dx, 64 + motion.dy);+ cr.rotate(motion.rotation);+ cr.scale(motion.scale, motion.scale);+ cr.translate(-64, -64);+}++function drawCursorGlow(cr, progress, action, glowSurface) {+ const motion = cursorBodyMotion(progress, action);+ cr.save();+ applyCursorBodyMotion(cr, motion);+ cr.translate(-GLOW_PADDING, -GLOW_PADDING);+ cr.scale(1 / GLOW_SURFACE_SCALE, 1 / GLOW_SURFACE_SCALE);+ cr.setSourceSurface(glowSurface, 0, 0);+ cr.paint();+ cr.restore();+}++function drawCursorBody(cr, progress, action, fillColor) {+ const motion = cursorBodyMotion(progress, action);+ cr.save();+ applyCursorBodyMotion(cr, motion);+ traceCursorBody(cr);+ setFill(cr, fillColor);+ cr.fillPreserve();+ cr.setLineWidth(5);+ cr.setLineCap(Cairo.LineCap.ROUND);+ cr.setLineJoin(Cairo.LineJoin.ROUND);+ setPaper(cr);+ cr.stroke();+ cr.restore();+}++function drawActionCue(cr, action, progress, fillColor) {+ const wave = triangleWave(progress);+ const strokeCue = (width, alpha = 1) =>+ strokePath(cr, width, alpha, fillColor);+ const lineCue = (points, width = 4, alpha = 1) =>+ linePath(cr, points, width, alpha, fillColor);+ cr.save();+ switch (action) {+ case 'observe': {+ const opacity = Math.min(1, progress * 7);+ cr.translate(8, -10);+ cr.moveTo(38, 28);+ cr.curveTo(27, 29, 20, 38, 20, 49);+ strokeCue(4, opacity);+ cr.moveTo(42, 19);+ cr.curveTo(23, 19, 11, 33, 11, 51);+ strokeCue(4, opacity);+ break;+ }+ case 'click': {+ const cueProgress = Math.max(0, Math.min(1, progress / 0.65));+ const opacity = Math.max(0, Math.min(1,+ Math.min(1 - Math.pow(cueProgress, 1.35), cueProgress * 5)));+ const cueScale = 1.1 + easeInOut(cueProgress) * 0.4;+ cr.translate(35, 28);+ cr.scale(cueScale, cueScale);+ cr.translate(-25, -25);+ lineCue([[35, 20], [34, 11]], 4, opacity);+ lineCue([[27, 25], [19, 19]], 4, opacity);+ lineCue([[25, 34], [15, 34]], 4, opacity);+ break;+ }+ case 'drag': {+ const offset = easeInOut(wave) * 7;+ cr.translate(offset, offset * 0.43);+ lineCue([[28, 38], [16, 35]], 4, 0.2 + wave * 0.8);+ lineCue([[26, 48], [12, 45]], 4, 0.2 + wave * 0.8);+ break;+ }+ case 'scroll': {+ cr.translate(-5, 4 - wave * 8);+ lineCue([[23, 31], [31, 22], [39, 31]], 4, 0.42 + wave * 0.58);+ lineCue([[23, 49], [31, 58], [39, 49]], 4, 0.42 + wave * 0.58);+ break;+ }+ case 'text': {+ const opacity = progress < 0.34 || progress > 0.64 ? 1 : 0.18;+ cr.translate(-4, 0);+ lineCue([[31, 22], [31, 58]], 4, opacity);+ lineCue([[24, 22], [38, 22]], 4, opacity);+ lineCue([[24, 58], [38, 58]], 4, opacity);+ break;+ }+ case 'key': {+ const bounce = Math.sin(progress * Math.PI * 2) * (1 - progress) * 3;+ cr.translate(-9, bounce);+ roundedRect(cr, 14, 25, 28, 28, 6);+ strokeCue(3.5);+ lineCue([[23, 32], [23, 46], [23, 39], [33, 32], [24, 39], [34, 46]], 3.5);+ break;+ }+ case 'navigate': {+ cr.translate(-10 + easeInOut(progress) * 9, 0);+ lineCue([[15, 29], [25, 40], [15, 51]], 4, 0.2 + wave * 0.8);+ lineCue([[29, 29], [39, 40], [29, 51]], 4, 0.2 + wave * 0.8);+ break;+ }+ case 'app': {+ const s = 0.2 + easeInOut(Math.min(1, progress * 2)) * 0.8;+ cr.translate(21, 39);+ cr.scale(s, s);+ cr.translate(-26, -39);+ for (const [x, y] of [[13, 26], [29, 26], [13, 42], [29, 42]]) {+ roundedRect(cr, x, y, 10, 10, 2);+ strokeCue(3.5);+ }+ break;+ }+ case 'transfer':+ cr.translate(-9, 6 - wave * 12);+ lineCue([[22, 50], [22, 20], [14, 28], [22, 20], [30, 28]], 4, 0.38 + wave * 0.62);+ lineCue([[37, 28], [37, 58], [29, 50], [37, 58], [45, 50]], 4, 0.38 + wave * 0.62);+ break;+ case 'record':+ cr.translate(-12, 0);+ cr.arc(29, 39, 17, 0, Math.PI * 2);+ strokeCue(4);+ cr.arc(29, 39, 3.6 + wave * 2.1, 0, Math.PI * 2);+ fillPath(cr, (3.6 + wave * 2.1) * 1.25, 0.42 + wave * 0.58, fillColor);+ break;+ case 'system': {+ cr.translate(15, 39);+ cr.rotate((easeInOut(progress) * 68 - 18) * Math.PI / 180);+ cr.translate(-29, -39);+ for (const radius of [12, 4]) {+ cr.arc(29, 39, radius, 0, Math.PI * 2);+ strokeCue(3.5);+ }+ for (const points of [+ [[29, 20], [29, 25]], [[29, 53], [29, 58]],+ [[10, 39], [15, 39]], [[43, 39], [48, 39]],+ [[16, 26], [20, 30]], [[38, 48], [42, 52]],+ [[16, 52], [20, 48]], [[38, 30], [42, 26]],+ ])+ lineCue(points, 3.5);+ break;+ }+ default:+ break;+ }+ cr.restore();+}++function drawModifiers(cr, delivery, target, fillColor) {+ const strokeCue = (width, alpha = 1) =>+ strokePath(cr, width, alpha, fillColor);+ const lineCue = (points, width = 4, alpha = 1) =>+ linePath(cr, points, width, alpha, fillColor);+ if (delivery === 'background') {+ cr.save();+ cr.setDash([1, 5], 0);+ cr.moveTo(34, 23);+ cr.curveTo(20, 31, 17, 48, 21, 63);+ cr.curveTo(25, 80, 38, 95, 53, 106);+ strokeCue(2.5, 0.75);+ cr.restore();+ } else if (delivery === 'foreground') {+ cr.arc(25, 90, 9, 0, Math.PI * 2);+ strokeCue(3);+ }++ switch (target) {+ case 'ax':+ for (const [x, y] of [[104, 89], [94, 104], [114, 104]]) {+ cr.arc(x, y, 3, 0, Math.PI * 2);+ strokeCue(2.5);+ }+ lineCue([[104, 92], [104, 97], [94, 101], [104, 97], [114, 101]], 2.5);+ break;+ case 'pixel':+ cr.save();+ cr.setDash([2, 3], 0);+ cr.rectangle(94, 91, 19, 19);+ strokeCue(2.5);+ cr.restore();+ break;+ case 'browser':+ cr.arc(104, 100, 10, 0, Math.PI * 2);+ strokeCue(2.5);+ lineCue([[94, 100], [114, 100]], 2.5);+ lineCue([[104, 90], [100, 100], [104, 110]], 2.5);+ lineCue([[104, 90], [108, 100], [104, 110]], 2.5);+ break;+ case 'desktop':+ roundedRect(cr, 93, 90, 21, 15, 2);+ strokeCue(2.5);+ lineCue([[103.5, 105], [103.5, 110], [97, 110], [110, 110]], 2.5);+ break;+ default:+ break;+ }}export default class WinRectsExtension extends Extension {@@ -40,36 +439,68 @@ export default class WinRectsExtension extends Extension {this._impl.export(Gio.DBus.session, '/org/cua/WinRects');this._nameId = Gio.bus_own_name(Gio.BusType.SESSION, 'org.cua.WinRects',Gio.BusNameOwnerFlags.REPLACE, null, null, null);- this._cursor = new St.DrawingArea({width: 30, height: 30, visible: false, reactive: false, can_focus: false});+ this._action = 'idle';+ this._delivery = '';+ this._target = '';+ this._actionStarted = nowSeconds();+ this._endingAt = null;+ this._fillColor = [94, 192, 232];+ this._glowSurface = createGlowSurface(this._fillColor);+ this._cursor = new St.DrawingArea({+ width: ACTOR_SIZE,+ height: ACTOR_SIZE,+ visible: false,+ reactive: false,+ can_focus: false,+ });this._cursor.connect('repaint', (area) => {const cr = area.get_context();- const P = arrowPoints();- cr.moveTo(P[0][0], P[0][1]);- for (let i = 1; i < P.length; i++) cr.lineTo(P[i][0], P[i][1]);- cr.closePath();- const tail = [(P[1][0] + P[3][0]) / 2, (P[1][1] + P[3][1]) / 2];- try {- const g = new Cairo.LinearGradient(P[0][0], P[0][1], tail[0], tail[1]);- g.addColorStopRGBA(0.00, 219 / 255, 238 / 255, 255 / 255, 0.97);- g.addColorStopRGBA(0.53, 94 / 255, 192 / 255, 232 / 255, 0.97);- g.addColorStopRGBA(1.00, 84 / 255, 205 / 255, 160 / 255, 0.97);- cr.setSource(g);- } catch (e) {- cr.setSourceRGBA(94 / 255, 192 / 255, 232 / 255, 0.97);- }- cr.fillPreserve();- cr.setLineWidth(1.4); cr.setSourceRGBA(1, 1, 1, 0.95); cr.stroke();+ const duration = ACTION_DURATIONS[this._action] ?? 1.6;+ const elapsed = nowSeconds() - this._actionStarted;+ const progress = (elapsed % duration) / duration;+ const floatProgress = (elapsed % FLOAT_DURATION) / FLOAT_DURATION;+ cr.save();+ cr.translate(ACTOR_CENTER, ACTOR_CENTER);+ cr.scale(SCALE, SCALE);+ cr.translate(-CANVAS_SIZE / 2, -CANVAS_SIZE / 2);+ applyCursorBodyMotion(cr, sharedFloatMotion(floatProgress));+ drawCursorGlow(cr, progress, this._action, this._glowSurface);+ drawActionCue(cr, this._action, progress, this._fillColor);+ drawCursorBody(cr, progress, this._action, this._fillColor);+ drawModifiers(cr, this._delivery, this._target, this._fillColor);+ cr.restore();cr.$dispose();});- this._cursor.set_pivot_point(TIPX / 30, TIPY / 30);+ this._cursor.set_pivot_point(0.5, 0.5);Main.layoutManager.addTopChrome(this._cursor);+ this._frameId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 33, () => {+ if (!this._cursor)+ return GLib.SOURCE_REMOVE;+ const now = nowSeconds();+ if (this._endingAt !== null && now >= this._endingAt)+ this._setCursorState('idle', '', '');+ if (ONE_SHOT_ACTIONS.has(this._action) &&+ now - this._actionStarted >= ACTION_DURATIONS[this._action])+ this._setCursorState('idle', '', '');+ if (this._cursor.visible)+ this._cursor.queue_repaint();+ return GLib.SOURCE_CONTINUE;+ });}disable() {+ if (this._frameId) {+ GLib.source_remove(this._frameId);+ this._frameId = 0;+ }if (this._cursor) { this._cursor.destroy(); this._cursor = null; }+ if (this._glowSurface) {+ this._glowSurface.finish();+ this._glowSurface = null;+ }if (this._impl) { this._impl.unexport(); this._impl = null; }if (this._nameId) { Gio.bus_unown_name(this._nameId); this._nameId = 0; }}- GetVersion() { return 4; }+ GetVersion() { return 5; }GetRects() {const actors = global.get_window_actors();const actorByWindow = new Map();@@ -148,14 +579,49 @@ export default class WinRectsExtension extends Extension {MoveCursor(x, y) {if (!this._cursor) return;this._cursor.show();- this._cursor.ease({x: x - TIPX, y: y - TIPY, duration: 480, mode: Clutter.AnimationMode.EASE_OUT_CUBIC});+ this._cursor.ease({+ x: x - ACTOR_CENTER,+ y: y - ACTOR_CENTER,+ duration: 480,+ mode: Clutter.AnimationMode.EASE_OUT_CUBIC,+ });}ClickPulse(x, y) {if (!this._cursor) return;- this._cursor.set_position(x - TIPX, y - TIPY);+ this._cursor.set_position(x - ACTOR_CENTER, y - ACTOR_CENTER);+ this._setCursorState('click', this._delivery, this._target);this._cursor.show();- this._cursor.ease({scale_x: 1.5, scale_y: 1.5, duration: 130, mode: Clutter.AnimationMode.EASE_OUT_QUAD,- onComplete: () => { if (this._cursor) this._cursor.ease({scale_x: 1, scale_y: 1, duration: 130}); }});+ this._cursor.queue_repaint();+ }+ SetCursorColor(fillColor) {+ const match = /^#([0-9a-fA-F]{6})$/.exec(fillColor);+ if (!match)+ return;+ const rgb = Number.parseInt(match[1], 16);+ this._fillColor = [(rgb >> 16) & 0xff, (rgb >> 8) & 0xff, rgb & 0xff];+ if (this._glowSurface)+ this._glowSurface.finish();+ this._glowSurface = createGlowSurface(this._fillColor);+ if (this._cursor)+ this._cursor.queue_repaint();+ }+ SetCursorState(action, delivery, target, active) {+ if (!ACTIONS.has(action))+ return;+ if (active) {+ this._setCursorState(action, delivery, target);+ } else if (this._action === action && !ONE_SHOT_ACTIONS.has(action)) {+ this._endingAt = nowSeconds() + 0.4;+ }+ }+ _setCursorState(action, delivery, target) {+ this._action = ACTIONS.has(action) ? action : 'idle';+ this._delivery = delivery ?? '';+ this._target = target ?? '';+ this._actionStarted = nowSeconds();+ this._endingAt = null;+ if (this._cursor)+ this._cursor.queue_repaint();}HideCursor() { if (this._cursor) this._cursor.hide(); }}diff --git a/libs/cua-driver/wayland-helper/winrects@cua/metadata.json b/libs/cua-driver/wayland-helper/winrects@cua/metadata.jsonindex 1eb4884ef8..8c9c7d5e32 100644--- a/libs/cua-driver/wayland-helper/winrects@cua/metadata.json+++ b/libs/cua-driver/wayland-helper/winrects@cua/metadata.json@@ -1 +1 @@-{"uuid":"winrects@cua","name":"WinRects","description":"Expose window geometry, capture, cursor, and verified activation for cua-driver on Wayland.","shell-version":["45","46","47","48"],"version":4}+{"uuid":"winrects@cua","name":"WinRects","description":"Expose window geometry, capture, cursor, and verified activation for cua-driver on Wayland.","shell-version":["45","46","47","48"],"version":5}