diff --git a/CHANGELOG.md b/CHANGELOG.md index 12b3074..5669cf7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 persist function. - Fixed a deadlock that could occur when multiple threads were attempting to execute change callbacks for the same dynamic at the same time. +- The initial `inner_size` of a `Window` is now used if it is non-zero and + `WindowAttributes::inner_size` is `None`. ### Added diff --git a/examples/unsaved-changes.rs b/examples/unsaved-changes.rs index b57198f..69cfeaa 100644 --- a/examples/unsaved-changes.rs +++ b/examples/unsaved-changes.rs @@ -3,13 +3,16 @@ use cushy::{ widget::MakeWidget, Run, }; +use figures::{units::UPx, Size}; fn main() -> cushy::Result { let has_unsaved_changes = Dynamic::new(true); + let inner_size = Dynamic::new(Size::new(UPx::new(1000), UPx::new(800))); "Prevent Closing" .into_checkbox(has_unsaved_changes.clone()) .into_window() .on_close_requested(move |()| !has_unsaved_changes.get()) + .inner_size(inner_size) .run() } diff --git a/src/window.rs b/src/window.rs index 86e21bd..afc1a99 100644 --- a/src/window.rs +++ b/src/window.rs @@ -1828,6 +1828,12 @@ where attrs.preferred_theme = Some((*theme_mode).into()); } attrs.title = settings.title.get(); + if attrs.inner_size.is_none() { + let dynamic_inner = settings.inner_size.get(); + if !dynamic_inner.is_zero() { + attrs.inner_size = Some(winit::dpi::Size::Physical(dynamic_inner.into())); + } + } attrs }