diff --git a/CHANGELOG.md b/CHANGELOG.md index 01fe99da7..21452eb84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 area of the window. - `App::prevent_shutdown()` returns a guard that prevents the application from closing automatically when the final window is closed. +- `WindowBehavior::initialized` is invoked once the window has been fully + initialized. ## v0.10.0 (2024-08-20) diff --git a/Cargo.lock b/Cargo.lock index 5be94d903..1b0ce9e4d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -106,7 +106,7 @@ checksum = "4e1496f8fb1fbf272686b8d37f523dab3e4a7443300055e74cdaa449f3114356" [[package]] name = "appit" version = "0.3.2" -source = "git+https://github.com/khonsulabs/appit#331bfdd3534a2f6a7c44f24017b4d52aee40da5b" +source = "git+https://github.com/khonsulabs/appit#68530e7d69713ca2c5fc1d7003debe0ba616a50b" dependencies = [ "winit", ] @@ -1253,9 +1253,9 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "memmap2" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe751422e4a8caa417e13c3ea66452215d7d63e19e604f4980461212f3ae1322" +checksum = "fd3f7eed9d3848f8b98834af67102b720745c4ec028fcd0aa0239277e7de374f" dependencies = [ "libc", ] @@ -2615,9 +2615,9 @@ checksum = "ad8d71f5726e5f285a935e9fe8edfd53f0491eb6e9a5774097fdabee7cd8c9cd" [[package]] name = "unicode-segmentation" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" [[package]] name = "unicode-width" diff --git a/src/app.rs b/src/app.rs index 9963e5924..7b1b292ef 100644 --- a/src/app.rs +++ b/src/app.rs @@ -509,6 +509,10 @@ where NonZeroU32::new(4).assert("4 is less than u32::MAX") } + /// Executed once after the window has been fully initialized. + #[allow(unused_variables)] + fn initialized(&mut self, window: Window<'_, WindowEvent>, kludgine: &mut Kludgine) {} + /// Prepare the window to render. /// /// This is called directly before [`render()`](Self::render()) and is a @@ -1299,6 +1303,17 @@ where } } + fn initialized(&mut self, window: &mut RunningWindow>) { + self.behavior.initialized( + Window::new( + window, + self.last_render.elapsed(), + self.last_render_duration, + ), + &mut self.kludgine, + ); + } + fn redraw(&mut self, window: &mut RunningWindow>) { if self.config.width > 0 && self.config.height > 0 { let Some(surface) = self.current_surface_texture(window) else {