Skip to content

fix(macos): prevent bidirectional capture loops - #473

Open
mrcha033 wants to merge 1 commit into
feschber:mainfrom
mrcha033:fix/macos-bidirectional-return
Open

fix(macos): prevent bidirectional capture loops#473
mrcha033 wants to merge 1 commit into
feschber:mainfrom
mrcha033:fix/macos-bidirectional-return

Conversation

@mrcha033

Copy link
Copy Markdown

Problem

On a bidirectional Linux/Wayland ↔ macOS setup, Lan Mouse's macOS event tap
observes the pointer events posted by its own emulation backend. A synthesized
edge event can therefore be mistaken for a new local capture and immediately
send the pointer back, producing an Arch → macOS → Arch capture loop.

Changes

  • tag every macOS event posted by the emulation backend and retain a process-ID
    fallback when CoreGraphics does not preserve the tag
  • keep separate physical and emulated edge-arm state
  • ignore the initial outward crossing, then re-arm on the first inward motion
    so short reversals work
  • send a synthesized return crossing only to the matching EnterOnly capture
    while preserving normal default capture for chained topologies
  • handle dragged-pointer crossings as motion
  • make capture state updates synchronous and release the state lock before
    bounded event delivery
  • add routing, short-reversal, drag, and stream-progress regression tests

Validation

  • cargo fmt --all -- --check
  • cargo test --workspace --all-features --locked
  • cargo clippy -p input-capture --all-targets --all-features --locked -- -D warnings
  • macOS app bundle launches at commit 3d202975
  • recursive @rpath dependency closure and codesign --verify --deep --strict
    pass locally

Physical Arch → macOS → Arch verification is still running against the Arch
binary from #471 (83e66bc), so this is a draft.

Scope

  • the unsuccessful layer-shell re-entry experiment is not included
  • macOS dylib packaging changes are not included
  • this patch targets one active incoming peer; carrying peer identity through
    CoreGraphics event provenance is left for a follow-up

This is independent of #471, which contains the input post-processing changes.

@mrcha033
mrcha033 marked this pull request as ready for review July 27, 2026 13:29
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.

1 participant