Skip to content

Commit

Permalink
Honoring Window::inner_size's initial value
Browse files Browse the repository at this point in the history
Refs #160
  • Loading branch information
ecton committed Jul 8, 2024
1 parent 4d6196f commit 60c7ef8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions examples/unsaved-changes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
6 changes: 6 additions & 0 deletions src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 60c7ef8

Please sign in to comment.