mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-05-07 22:58:05 +03:00
InputCaptureState fetches the active-display bounds once in new() via CGDisplay::active_displays(), and crossed() / start_capture() both consult those frozen bounds for every barrier check and cursor warp. Plug in a monitor, change resolution, or rearrange displays in System Settings and the bounds go stale immediately: the cursor either stops crossing at the new edge or warps to the old edge coordinates. Register a Quartz CGDisplayRegisterReconfigurationCallback on the event-tap thread's CFRunLoop and route a new ProducerEvent::DisplayReconfigured into the existing producer channel. The producer task re-runs update_bounds() on the live state, so subsequent barrier checks use the current geometry. The callback fires twice per change — once with the kCGDisplayBeginConfigurationFlag (BEFORE the bounds update) and once after — we filter the begin-phase out and only refresh on the post-change notification. The callback registration is removed and the leaked sender Box is reclaimed when the run loop exits, so create/destroy cycles don't leak channel senders. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>