Skip to content

macOS: fix incorrect fullscreen pointer motion on macOS 26 - #4797

Closed
Moomo wants to merge 1 commit into
rust-windowing:masterfrom
Moomo:fix/macos-26-fullscreen-pointer
Closed

Moomo wants to merge 1 commit into
rust-windowing:masterfrom
Moomo:fix/macos-26-fullscreen-pointer

Conversation

@Moomo

@Moomo Moomo commented Oct 25, 2026

Copy link
Copy Markdown

On macOS 26, after switching away from a native fullscreen Space and back,
clicking near the top of the window can deliver a bogus motion event between
otherwise correct press/release positions. This makes click handlers interpret
a stationary click as a drag and cancel it.

A captured downstream sequence on macOS 26.7.1 was:

  • press at (142.6, 27.1)
  • motion to (-668.4, -1052.9), sometimes followed by an exit
  • release at (142.6, 27.1)

For motion/drag callbacks in native fullscreen windows on macOS 26+, query the
live pointer position through NSWindow and convert it to the receiving
NSView. Button, wheel and other gesture callbacks retain their event-time
coordinates. During a held gesture, suppress an exit only while the live pointer
is actually inside the view; genuine outside movement and releases remain valid.
Windowed mode and older macOS versions retain the existing path.

This follows the scoped workaround described in
SDL's implementation.
Using Cocoa's window/view conversion avoids manually subtracting display origins.
There is a tradeoff: affected motion uses the position at dispatch time rather
than the historical event position.

Validation:

  • cargo test -p winit-appkit --lib: 8 passed on macOS 26.7.1.
  • cargo clippy -p winit-appkit --all-targets -- -D warnings: passed.
  • The equivalent fix was backported to 0.30.13 in an egui application; the user
    confirmed that repeated header clicks work after restarting with the fix.
  • Downstream event-sequence tests cover the captured click failure, corrected
    stationary clicks, genuine outside drags and moving out and back before release.
  • Interactive confirmation is for the 0.30.13 backport, not a separate interactive
    run of this master-branch port. Multiple-display/scale combinations and other
    macOS versions have not been exhaustively tested.
  • Nightly rustfmt is not installed locally. Stable rustfmt was used on the edited
    code, with unrelated formatting changes removed; nightly formatting may need
    to be applied by CI/maintainers.

Checklist:

  • Tested on the changed platform (see scope above)
  • Added a changelog entry
  • Documented the platform-specific behavior in code and this description
  • No new API/example required

@Moomo
Moomo requested a review from madsmtm as a code owner October 25, 2026 11:42
@Moomo Moomo closed this Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant