Skip to content

Commit 6be3f43

Browse files
authored
feat(core): add Resumed and MainEventsCleared events, closes #2127 (#2439)
1 parent 28c6b7a commit 6be3f43

File tree

5 files changed

+33
-0
lines changed

5 files changed

+33
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri": patch
3+
---
4+
5+
Adds `Resumed` and `MainEventsCleared` variants to the `Event` enum.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"tauri-runtime": minor
3+
"tauri-runtime-wry": minor
4+
---
5+
6+
Adds `Resumed` and `MainEventsCleared` variants to the `RunEvent` enum.

core/tauri-runtime-wry/src/lib.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1785,6 +1785,14 @@ fn handle_event_loop(
17851785
callback(RunEvent::Ready);
17861786
}
17871787

1788+
Event::NewEvents(StartCause::Poll) => {
1789+
callback(RunEvent::Resumed);
1790+
}
1791+
1792+
Event::MainEventsCleared => {
1793+
callback(RunEvent::MainEventsCleared);
1794+
}
1795+
17881796
Event::GlobalShortcutEvent(accelerator_id) => {
17891797
for (id, handler) in &*global_shortcut_manager_handle.listeners.lock().unwrap() {
17901798
if accelerator_id == *id {

core/tauri-runtime/src/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,12 @@ pub enum RunEvent {
186186
WindowClose(String),
187187
/// Application ready.
188188
Ready,
189+
/// Sent if the event loop is being resumed.
190+
Resumed,
191+
/// Emitted when all of the event loop’s input events have been processed and redraw processing is about to begin.
192+
///
193+
/// 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.
194+
MainEventsCleared,
189195
}
190196

191197
/// Action to take when the event loop is about to exit

core/tauri/src/app.rs

+8
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ pub enum Event {
9797
WindowClosed(String),
9898
/// Application ready.
9999
Ready,
100+
/// Sent if the event loop is being resumed.
101+
Resumed,
102+
/// Emitted when all of the event loop’s input events have been processed and redraw processing is about to begin.
103+
///
104+
/// 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.
105+
MainEventsCleared,
100106
}
101107

102108
/// A menu event that was triggered on a window.
@@ -441,6 +447,8 @@ impl<R: Runtime> App<R> {
441447
},
442448
RunEvent::WindowClose(label) => Event::WindowClosed(label),
443449
RunEvent::Ready => Event::Ready,
450+
RunEvent::Resumed => Event::Resumed,
451+
RunEvent::MainEventsCleared => Event::MainEventsCleared,
444452
_ => unimplemented!(),
445453
},
446454
);

0 commit comments

Comments
 (0)