MacOS: Implement EventLoopExtPumpEvents and EventLoopExtRunOnDemand
The implementation of `pump_events` essentially works by hooking into the `RunLoopObserver` and requesting that the app should be stopped the next time that the `RunLoop` prepares to wait for new events. Originally I had thought I would poke the `CFRunLoop` for the app directly and I was originally going to implement `pump_events` based on a timeout which I'd seen SDL doing. I found that `[NSApp run]` wasn't actually being stopped by asking the RunLoop to stop directly and inferred that `NSApp run` will actually catch this and re-start the loop. Hooking into the observer and calling `[NSApp stop]` actually seems like a better solution that doesn't need a hacky constant timeout. The end result is quite similar to what happens with existing apps that call `run_return` inside an external loop and cause the loop to exit for each iteration (that also results in the `NSApp` stopping each iteration).
This commit is contained in:
parent
420840278b
commit
461efaf99f
3 changed files with 415 additions and 50 deletions
|
|
@ -11,8 +11,8 @@
|
|||
//!
|
||||
//! And the following platform-specific modules:
|
||||
//!
|
||||
//! - `run_ondemand` (available on `windows`, `android`)
|
||||
//! - `pump_events` (available on `windows`, `android`)
|
||||
//! - `run_ondemand` (available on `windows`, `macos`, `android`)
|
||||
//! - `pump_events` (available on `windows`, `macos`, `android`)
|
||||
//! - `run_return` (available on `windows`, `unix`, `macos`, and `android`)
|
||||
//!
|
||||
//! However only the module corresponding to the platform you're compiling to will be available.
|
||||
|
|
@ -36,10 +36,10 @@ pub mod windows;
|
|||
#[cfg(x11_platform)]
|
||||
pub mod x11;
|
||||
|
||||
#[cfg(any(windows_platform, android_platform))]
|
||||
#[cfg(any(windows_platform, macos_platform, android_platform))]
|
||||
pub mod run_ondemand;
|
||||
|
||||
#[cfg(any(windows_platform, android_platform,))]
|
||||
#[cfg(any(windows_platform, macos_platform, android_platform,))]
|
||||
pub mod pump_events;
|
||||
|
||||
#[cfg(any(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue