Swizzle sendEvent: instead of subclassing NSApplication (#4036)

This is done to avoid order-dependent behavior that you'd otherwise
encounter where `EventLoop::new` had to be called at the beginning of
`fn main` to ensure that Winit's application was the one being
registered as the main application by calling `sharedApplication`.

Fixes https://github.com/rust-windowing/winit/issues/3772.

This should also make it (more) possible to use multiple versions of
Winit in the same application (though that's still untested).

Finally, it should allow the user to override `NSApplication` themselves
if they need to do that for some reason.
This commit is contained in:
Mads Marquart 2025-02-24 10:38:10 +01:00 committed by GitHub
parent 4d6fe7e35c
commit 675582bd46
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 145 additions and 42 deletions

View file

@ -185,6 +185,7 @@ changelog entry.
- Updated `windows-sys` to `v0.59`.
- To match the corresponding changes in `windows-sys`, the `HWND`, `HMONITOR`, and `HMENU` types
now alias to `*mut c_void` instead of `isize`.
- On macOS, no longer need control of the main `NSApplication` class (which means you can now override it yourself).
### Removed