Repository navigation
WIP feature: add driftwm decal drawing - #344
Draft
Granitosaurus wants to merge 4 commits into
Draft
Granitosaurus wants to merge 4 commits into
Granitosaurus wants to merge 4 commits into
Conversation
`driftwm msg decal add|list|remove` places a still image at a canvas point, drawn by the compositor below every window and widget. A decal is not a window, so no drag, snap, fit, tiling or Alt-Tab machinery ever sees it, and it needs no client process or relaunch to survive a restart. - decals.rs: serde types, bounds, atomic read/write of decals.json beside session.json (always saved, independent of the [session] restore flags). - state/decals.rs: registry, hit-test for `remove` under the pointer; the image size is read from the file header when placed, so bad or oversized files are refused at the command. - render/decals.rs: one cached TextureBuffer per image (stable element id for damage tracking), premultiplied on upload, explicit texel src so a scaled decal samples the whole texture. - IPC verb, CLI subcommand, docs/decals.md, regenerated docs/cli.md. Tests: 15 headless fixture tests (placement, cursor placement, hit-test, bounds, persistence) and 3 GL pixel tests (placement, premultiplied blend, scaling, drawn below a window). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A flipped decal uploads horizontally mirrored pixels as its own texture, cached per (path, flip). Flipping with a GPU transform is not an option: smithay converts the source rect of a Transform::Flipped element against the destination size, so any scale other than 1 samples the wrong region. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add decal drawing API for drawing images directly on canvas. Using
dirft msg decalcommands images can be added, moved, scaled, fliped and discovered which creates opportunity for cool applications like https://github.com/Granitosaurus/driftwm-stickers:Progress:
What it does
A decal is a still image the compositor draws at a fixed canvas position: a landmark for a cluster of windows, or an anchor you can spot from a zoomed-out view. No window, no client process.
Commits
The branch is four commits that each build with
cargo check --all-targets, so it can be read or split in pieces:Decalmodel,decals.jsonpersistence, rendering below windows,decal add | list | remove.move-decalmouse action,decal move,msg pointer.scale-decalscroll action,decal scale.decal flip.If you would rather review (1) alone and take the rest as follow-ups, they apply in order.
Design notes
TextureRenderElementper decal, pixel-snapped like other canvas elements, drawn between the background and the windows. Pixels are premultiplied at upload; textures are cached per path (and per flip state) and dropped when the last decal using them is removed.Transform::Flipped: smithay converts the source rect of a flipped element against the destination size, so any scale other than 1 samples the wrong region. There is a pixel test at scale 0.5 for this. The cost is a second texture for an image that is shown both ways.move-decal/scale-decalonly act where no client is under the pointer (decals are below windows), and otherwise fall through to the binding's normal behaviour. A drag is aPointerGrabthat keeps the offset from the pointer. Scrolling is a continuousMouseActionbecause wheel-up / wheel-down only run keyboard actions.decals.jsonin the state dir, written on change (debounced for drags and scroll, 300 ms) and flushed on quit and on signals. Additive fields (flip) useserde(default)so older files load.Request::Decal(..)andRequest::Pointer; nothing changes for existing requests.decalwrites are classed as mutating.Known limitations
decal remove/flipwith no id.decalcommands still reach it by id.imagecrate decodes); no animation.Verification
cargo fmt --check,cargo clippy --all-targets -- -D warnings,cargo test -- --include-ignored --skip soakand the soak test: all green locally viadev/scripts/ci-local.flip, bad files); IPC dispatch for add / list / remove / move / scale / flip / pointer, incl. refusals; mouse drag and scroll through the real input path; rendering pixel tests (below windows, transparency, flip mirrors in place, at scale 1 and 0.5);docs/cli.mdexamples parse.decal addthrough a picker,move-decaldragging andscale-decalwith the wheel all behave as described. Not yet exercised by hand:decal flipafter the final rendering fix (it is covered by the pixel tests at scales 1 and 0.5), and a trackpad.Docs
docs/decals.md(new),docs/ipc.md, the generateddocs/cli.mdanddocs/config.md(fromconfig.reference.toml).