mirror of
https://github.com/rust-windowing/winit.git
synced 2026-06-27 15:13:13 -04:00
macOS: Emit LoopDestroyed on CMD+Q (#2073)
override applicationWillTerminate: Co-authored-by: Mads Marquart <mads@marquart.dk>
This commit is contained in:
@@ -34,6 +34,11 @@ pub static APP_DELEGATE_CLASS: Lazy<AppDelegateClass> = Lazy::new(|| unsafe {
|
||||
sel!(applicationDidFinishLaunching:),
|
||||
did_finish_launching as extern "C" fn(&Object, Sel, id),
|
||||
);
|
||||
decl.add_method(
|
||||
sel!(applicationWillTerminate:),
|
||||
will_terminate as extern "C" fn(&Object, Sel, id),
|
||||
);
|
||||
|
||||
decl.add_ivar::<*mut c_void>(AUX_DELEGATE_STATE_NAME);
|
||||
|
||||
AppDelegateClass(decl.register())
|
||||
@@ -75,3 +80,10 @@ extern "C" fn did_finish_launching(this: &Object, _: Sel, _: id) {
|
||||
trace_scope!("applicationDidFinishLaunching:");
|
||||
AppState::launched(this);
|
||||
}
|
||||
|
||||
extern "C" fn will_terminate(_this: &Object, _: Sel, _: id) {
|
||||
trace!("Triggered `applicationWillTerminate`");
|
||||
// TODO: Notify every window that it will be destroyed, like done in iOS?
|
||||
AppState::exit();
|
||||
trace!("Completed `applicationWillTerminate`");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user