Skip to main content

lumen_app_on_close

Function lumen_app_on_close 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn lumen_app_on_close( app: *mut LumenApp, cb: Option<LumenCloseFn>, user_data: *mut c_void, ) -> LumenStatus
Expand description

Register an app-level close hook (ABI 0.5).

cb fires once per OS close request - the window close button, or (Unix) the first SIGINT/SIGTERM - on the Lumen tick thread, before the runtime tears down the window, GPU state, or script host. Return nonzero to allow the close; return 0 to veto it and keep the window open (the hook fires again on the next close request). A second registration replaces the first. Must be called before lumen_app_run. The hook never fires under lumen_app_run_headless (no window, no OS close request).

The native hook coexists with any script-side on_close() - both observe the same close request, and either may veto it.