diff --git a/cosmic-theme/src/model/corner.rs b/cosmic-theme/src/model/corner.rs index ecd18c0b..68651fd4 100644 --- a/cosmic-theme/src/model/corner.rs +++ b/cosmic-theme/src/model/corner.rs @@ -15,6 +15,13 @@ pub struct CornerRadii { pub radius_l: [f32; 4], /// extra large corner radii pub radius_xl: [f32; 4], + /// window corner radii (used by compositor for window decorations) + #[serde(default = "default_radius_window")] + pub radius_window: [f32; 4], +} + +fn default_radius_window() -> [f32; 4] { + [22.0; 4] } impl Default for CornerRadii { @@ -26,6 +33,7 @@ impl Default for CornerRadii { radius_m: [16.0; 4], radius_l: [32.0; 4], radius_xl: [160.0; 4], + radius_window: [22.0; 4], } } } diff --git a/cosmic-theme/src/model/theme.rs b/cosmic-theme/src/model/theme.rs index 1f94f5a2..250e61cb 100644 --- a/cosmic-theme/src/model/theme.rs +++ b/cosmic-theme/src/model/theme.rs @@ -653,6 +653,14 @@ impl Theme { self.corner_radii.radius_s } + #[must_use] + #[allow(clippy::doc_markdown)] + #[inline] + /// get @radius_window (window corner radius for compositor) + pub fn radius_window(&self) -> [f32; 4] { + self.corner_radii.radius_window + } + #[must_use] #[allow(clippy::doc_markdown)] #[inline] diff --git a/src/app/cosmic.rs b/src/app/cosmic.rs index ae554846..2f61972c 100644 --- a/src/app/cosmic.rs +++ b/src/app/cosmic.rs @@ -657,7 +657,7 @@ impl Cosmic { let theme = THEME.lock().unwrap(); let t = theme.cosmic(); - let radii = t.radius_s().map(|x| if x < 4.0 { x } else { x + 4.0 }); + let radii = t.radius_window(); let cur_rad = CornerRadius { top_left: radii[0].round() as u32, top_right: radii[1].round() as u32, @@ -797,7 +797,7 @@ impl Cosmic { let t = cosmic_theme.cosmic(); - let radii = t.radius_s().map(|x| if x < 4.0 { x } else { x + 4.0 }); + let radii = t.radius_window(); let cur_rad = CornerRadius { top_left: radii[0].round() as u32, top_right: radii[1].round() as u32, @@ -943,7 +943,7 @@ impl Cosmic { let t = cosmic_theme.cosmic(); - let radii = t.radius_s().map(|x| if x < 4.0 { x } else { x + 4.0 }); + let radii = t.radius_window(); let cur_rad = CornerRadius { top_left: radii[0].round() as u32, top_right: radii[1].round() as u32, @@ -1219,7 +1219,7 @@ impl Cosmic { let theme = THEME.lock().unwrap(); let t = theme.cosmic(); - let radii = t.radius_s().map(|x| if x < 4.0 { x } else { x + 4.0 }); + let radii = t.radius_window(); let cur_rad = CornerRadius { top_left: radii[0].round() as u32, top_right: radii[1].round() as u32, diff --git a/src/theme/style/iced.rs b/src/theme/style/iced.rs index 937ee388..36870cff 100644 --- a/src/theme/style/iced.rs +++ b/src/theme/style/iced.rs @@ -470,8 +470,8 @@ impl iced_container::Catalog for Theme { fn style(&self, class: &Self::Class<'_>) -> iced_container::Style { let cosmic = self.cosmic(); - // Ensures visually aligned radii for content and window corners - let window_corner_radius = cosmic.radius_s().map(|x| if x < 4.0 { x } else { x + 4.0 }); + // Use dedicated window radius from theme + let window_corner_radius = cosmic.radius_window(); match class { Container::Transparent => iced_container::Style::default(),