Skip to content

Add axRemoveMessages to drop queued events by target and type - #49

Merged
corepunch merged 1 commit into
mainfrom
claude/remove-messages
Oct 27, 2026
Merged

corepunch merged 1 commit into
mainfrom
claude/remove-messages

Conversation

@corepunch

Copy link
Copy Markdown
Owner

Summary

axRemoveFromQueue(target) drops everything queued for a target and cancels its timers. That's right for a destroyed window, but too broad for removing one stale event. This adds:

#define AX_ANY_WPARAM ((uint32_t)-1)
AX_API void axRemoveMessages(void *target, uint32_t message, uint32_t wparam);

It removes the queued events of one type for one target. AX_ANY_WPARAM matches any wParam; a specific value removes only the events that carry it, for example the already-queued ticks of one cancelled timer. Other events keep their order, and the target's timers keep running.

ORCA needs this so that cancelling a timer also drops its already-queued ticks. On macOS a late first tick of a repeating timer could find the next tick already queued, so a handler that cancelled the timer still received a stale tick (corepunch/orca#392).

Per backend:

  • X11, Wayland, Windows, WebGL, QNX: compact the ring buffer.
  • macOS: clears matching slots in place, because Cocoa events refer to queue slots by index; peek_message already skips cleared slots.
  • iOS: ios_remove_messages gains a type and wParam filter (type 0 matches any type), shared with axRemoveFromQueue.

Tests

  • tests/test_messages.c: removing one timer of one target keeps other timers, targets and types in order; AX_ANY_WPARAM removes the type whatever its wParam.
  • tests/test_macos_events.m: the same checks on the real NSApp-backed queue.
  • tests/test_ios_message_queue.c: the same checks on the iOS queue.
  • Ran make test locally with the X11 and the Wayland backend: all green. The macOS, iOS, Windows and WebGL code is compiled and tested only by CI.

Generated by Claude Code

axRemoveFromQueue drops everything queued for a target and cancels its
timers, which is right for a destroyed window but too broad for one stale
event. axRemoveMessages(target, message, wparam) removes only the events of
one type for one target; AX_ANY_WPARAM ((uint32_t)-1) matches any wParam,
and a specific value removes, for example, the queued ticks of one
cancelled timer. Other events keep their order and the target's timers keep
running.

The ring-buffer backends (X11, Wayland, Windows, WebGL, QNX) compact the
queue. macOS clears matches in place because Cocoa events refer to queue
slots by index, and peek already skips cleared slots. iOS shares one
matcher with axRemoveFromQueue.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gft4mytn9t9qr1ANVAo2gW
@corepunch
corepunch merged commit 2f2c2ca into main Oct 27, 2026
6 checks passed
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.

2 participants