Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve macOS mouse latency and stale positioning #483

Merged
merged 1 commit into from
Feb 22, 2021

Commits on Feb 19, 2021

  1. Improve macOS mouse latency and stale positioning

    This commit makes several changes to input event handling in macOS:
    
    _sapp_macos_update_mouse() has been changed to take an NSEvent*
    argument, instead of no arguments. And instead of using [window
    mouseLocationOutsideOfEventStream] to get the position of the mouse, it
    uses event.locationInWindow. This seems to sometimes eliminate a frame
    of mouse latency.
    
    _sapp_macos_update_mouse() is no longer called immediately before
    rendering a frame. Instead, it's called at the beginning of each of the
    mouseMoved:, mouseDragged:, mouseDown:, etc. methods with its associated
    NSEvent*. Immediately after, _sapp_macos_mouse_event() is called. This
    eliminates a full frame of mouse latency. This also fixes situations
    where the mouse cursor's resting apparent position would lag behind its
    resting true position after the user stops moving the mouse.
    
    _sapp_macos_poll_input_events() has been added, which calls [NSApp
    nextEventMatchingMask: ...] to manually read and dispatch input events
    from the event queue. _sapp_macos_poll_input_events() is called
    immediately before _sapp_macos_frame(). This will sometimes catch and
    dispatch input events that occurred shortly before the frame is to be
    rendered, but hadn't yet been dispatched by other mechanisms. This
    occasionally eliminates a frame of latency, and improves the worst-case
    bounds. This seems to happen to 5% or fewer mouse events.
    
    [NSEvent setMouseCoalescingEnabled:NO], if it even still does anything,
    is now called once at during application startup instead of toggled off
    and on along with mouse lock.
    cancel committed Feb 19, 2021
    Configuration menu
    Copy the full SHA
    9ea9c48 View commit details
    Browse the repository at this point in the history