diff --git a/.changes/main-events-cleared-and-resumed.md b/.changes/main-events-cleared-and-resumed.md new file mode 100644 index 000000000..8d4e65d48 --- /dev/null +++ b/.changes/main-events-cleared-and-resumed.md @@ -0,0 +1,5 @@ +--- +"tauri": patch +--- + +Adds `Resumed` and `MainEventsCleared` variants to the `Event` enum. diff --git a/.changes/runtime-main-events-cleared-and-resumed.md b/.changes/runtime-main-events-cleared-and-resumed.md new file mode 100644 index 000000000..b163fe01a --- /dev/null +++ b/.changes/runtime-main-events-cleared-and-resumed.md @@ -0,0 +1,6 @@ +--- +"tauri-runtime": minor +"tauri-runtime-wry": minor +--- + +Adds `Resumed` and `MainEventsCleared` variants to the `RunEvent` enum. diff --git a/core/tauri-runtime-wry/src/lib.rs b/core/tauri-runtime-wry/src/lib.rs index 70fc132f8..30c0b5cf4 100644 --- a/core/tauri-runtime-wry/src/lib.rs +++ b/core/tauri-runtime-wry/src/lib.rs @@ -1785,6 +1785,14 @@ fn handle_event_loop( callback(RunEvent::Ready); } + Event::NewEvents(StartCause::Poll) => { + callback(RunEvent::Resumed); + } + + Event::MainEventsCleared => { + callback(RunEvent::MainEventsCleared); + } + Event::GlobalShortcutEvent(accelerator_id) => { for (id, handler) in &*global_shortcut_manager_handle.listeners.lock().unwrap() { if accelerator_id == *id { diff --git a/core/tauri-runtime/src/lib.rs b/core/tauri-runtime/src/lib.rs index 247d7bf09..80a8a833b 100644 --- a/core/tauri-runtime/src/lib.rs +++ b/core/tauri-runtime/src/lib.rs @@ -186,6 +186,12 @@ pub enum RunEvent { WindowClose(String), /// Application ready. Ready, + /// Sent if the event loop is being resumed. + Resumed, + /// Emitted when all of the event loop’s input events have been processed and redraw processing is about to begin. + /// + /// This event is useful as a place to put your code that should be run after all state-changing events have been handled and you want to do stuff (updating state, performing calculations, etc) that happens as the “main body” of your event loop. + MainEventsCleared, } /// Action to take when the event loop is about to exit diff --git a/core/tauri/src/app.rs b/core/tauri/src/app.rs index 92864818c..fad113978 100644 --- a/core/tauri/src/app.rs +++ b/core/tauri/src/app.rs @@ -97,6 +97,12 @@ pub enum Event { WindowClosed(String), /// Application ready. Ready, + /// Sent if the event loop is being resumed. + Resumed, + /// Emitted when all of the event loop’s input events have been processed and redraw processing is about to begin. + /// + /// This event is useful as a place to put your code that should be run after all state-changing events have been handled and you want to do stuff (updating state, performing calculations, etc) that happens as the “main body” of your event loop. + MainEventsCleared, } /// A menu event that was triggered on a window. @@ -441,6 +447,8 @@ impl App { }, RunEvent::WindowClose(label) => Event::WindowClosed(label), RunEvent::Ready => Event::Ready, + RunEvent::Resumed => Event::Resumed, + RunEvent::MainEventsCleared => Event::MainEventsCleared, _ => unimplemented!(), }, );