Implement size_limits for winit

This commit is contained in:
Jeremy Soller 2024-01-31 10:51:31 -07:00
parent 0299878508
commit ca1469a6b2
No known key found for this signature in database
GPG key ID: D02FD439211AF56F
2 changed files with 8 additions and 3 deletions

View file

@ -123,6 +123,14 @@ pub(crate) fn iced_settings<App: Application>(
}
iced.window.decorations = !settings.client_decorations;
iced.window.size = settings.size;
let min_size = settings.size_limits.min();
if min_size != iced::Size::ZERO {
iced.window.min_size = Some(min_size);
}
let max_size = settings.size_limits.max();
if max_size != iced::Size::INFINITY {
iced.window.max_size = Some(max_size);
}
iced.window.transparent = settings.transparent;
}

View file

@ -4,7 +4,6 @@
//! Configure a new COSMIC application.
use crate::{font, Theme};
#[cfg(feature = "wayland")]
use iced_core::layout::Limits;
use iced_core::Font;
@ -51,7 +50,6 @@ pub struct Settings {
pub(crate) size: iced::Size,
/// Limitations of the window size
#[cfg(feature = "wayland")]
pub(crate) size_limits: Limits,
/// The theme to apply to the application.
@ -92,7 +90,6 @@ impl Default for Settings {
.and_then(|scale| scale.parse::<f32>().ok())
.unwrap_or(1.0),
size: iced::Size::new(1024.0, 768.0),
#[cfg(feature = "wayland")]
size_limits: Limits::NONE.min_height(1.0).min_width(1.0),
theme: crate::theme::system_preference(),
transparent: true,