Skip to content

fix(animation): animate both paws concurrently (#78)#79

Open
Aestylis wants to merge 6 commits into
saatvik333:mainfrom
Aestylis:fix/concurrent-paw-animation
Open

fix(animation): animate both paws concurrently (#78)#79
Aestylis wants to merge 6 commits into
saatvik333:mainfrom
Aestylis:fix/concurrent-paw-animation

Conversation

@Aestylis

Copy link
Copy Markdown

Fixes #78.

Problem

Only one paw animates at a time. Pressing a left-side and a right-side key together moves just one paw (the last pressed) — the both-down frame is never shown.

Root cause

The input child overwrites a single shared last_key_code, and the animation thread maps that one code to frame 1 or 2 with a single hold_until. The existing bongo-both-down.svg frame is unreachable.

Approach

The issue suggested separate surfaces per paw. Since the artwork is whole-cat frames (including an existing both-down frame) rather than isolated paw layers, I took a lighter route that needs no new surfaces or art:

  • Lock-free single-producer/multi-consumer ring buffer carries every keycode from the input child to each monitor's animation thread.
  • Two independent per-paw deadlines; the displayed frame is derived from which paws are live (both → both-down).
  • Retires last_key_code/any_key_pressed, which also fixes a multi-monitor reset race on the old shared flag.

Testing

  • New unit tests: ring (wraparound, multi-consumer, overflow-drop) + frame mapping.
  • make test, make format-check, make release all clean.
  • ThreadSanitizer: no races on the ring under two-hand stress typing.
  • Valgrind: 0 definitely/indirectly lost.
  • Verified live on KWin/KDE (Wayland): both paws animate, both-down confirmed.

Net: +337/−141 across 11 files; no new dependencies; ~260 bytes shared memory (removes two prior mmaps).

Aestylis and others added 6 commits June 20, 2026 21:49
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The keycode ring + eventfd now cover code delivery and wake-up, so the
single shared last_key_code, the any_key_pressed flag, and animation_trigger
are removed. This also eliminates the multi-monitor reset race where each
monitor process cleared the shared any_key_pressed flag.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Only one of the cat's animations can play at a time.

1 participant