diff --git a/iced b/iced index 788be2f7..f581f19f 160000 --- a/iced +++ b/iced @@ -1 +1 @@ -Subproject commit 788be2f7825b648ec3ce33697c6e675a7b7265ec +Subproject commit f581f19f897e1ccc4393c8867d4ae3ed532742b4 diff --git a/src/app/cosmic.rs b/src/app/cosmic.rs index 1d52ee0f..58b73b81 100644 --- a/src/app/cosmic.rs +++ b/src/app/cosmic.rs @@ -426,6 +426,12 @@ where ) => { return Some(Action::SuggestedBounds(b)); } + #[cfg(feature = "wayland")] + wayland::Event::Window(iced::event::wayland::WindowEvent::WindowState( + s, + )) => { + return Some(Action::WindowState(id, s)); + } _ => (), } } @@ -588,6 +594,7 @@ impl Cosmic { fn cosmic_update(&mut self, message: Action) -> iced::Task> { match message { Action::WindowMaximized(id, maximized) => { + #[cfg(not(feature = "wayland"))] if self .app .core() @@ -635,6 +642,24 @@ impl Cosmic { | WindowState::TILED_BOTTOM, ); } + if self.app.core().sync_window_border_radii_to_theme() { + use iced_runtime::platform_specific::wayland::CornerRadius; + use iced_winit::platform_specific::commands::corner_radius::corner_radius; + + 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 cur_rad = CornerRadius { + top_left: radii[0].round() as u32, + top_right: radii[1].round() as u32, + bottom_right: radii[2].round() as u32, + bottom_left: radii[3].round() as u32, + }; + let rounded = !self.app.core().window.sharp_corners; + return Task::batch(vec![ + corner_radius(id, rounded.then_some(cur_rad)).discard(), + ]); + } } #[cfg(feature = "wayland")] diff --git a/src/app/mod.rs b/src/app/mod.rs index 1b10b68d..11053142 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -759,16 +759,25 @@ impl ApplicationExt for App { header .apply(container) .class(crate::theme::Container::custom(move |theme| { + let cosmic = theme.cosmic(); container::Style { background: Some(iced::Background::Color( - theme.cosmic().background.base.into(), + cosmic.background.base.into(), )), border: iced::Border { radius: [ - window_corner_radius[0] - 1.0, - window_corner_radius[1] - 1.0, - theme.cosmic().radius_0()[2], - theme.cosmic().radius_0()[3], + if sharp_corners { + cosmic.radius_0()[0] + } else { + window_corner_radius[0] - 1.0 + }, + if sharp_corners { + cosmic.radius_0()[1] + } else { + window_corner_radius[1] - 1.0 + }, + cosmic.radius_0()[2], + cosmic.radius_0()[3], ] .into(), ..Default::default() diff --git a/src/theme/style/iced.rs b/src/theme/style/iced.rs index 764c1654..1f212d13 100644 --- a/src/theme/style/iced.rs +++ b/src/theme/style/iced.rs @@ -395,6 +395,7 @@ pub enum Container<'a> { Dropdown, HeaderBar { focused: bool, + sharp_corners: bool, }, List, Primary, @@ -507,7 +508,10 @@ impl iced_container::Catalog for Theme { } } - Container::HeaderBar { focused } => { + Container::HeaderBar { + focused, + sharp_corners, + } => { let (icon_color, text_color) = if *focused { ( Color::from(cosmic.accent_text_color()), @@ -526,8 +530,16 @@ impl iced_container::Catalog for Theme { background: Some(iced::Background::Color(cosmic.background.base.into())), border: Border { radius: [ - window_corner_radius[0], - window_corner_radius[1], + if *sharp_corners { + cosmic.corner_radii.radius_0[0] + } else { + window_corner_radius[0] + }, + if *sharp_corners { + cosmic.corner_radii.radius_0[1] + } else { + window_corner_radius[1] + }, cosmic.corner_radii.radius_0[2], cosmic.corner_radii.radius_0[3], ] diff --git a/src/widget/header_bar.rs b/src/widget/header_bar.rs index 3763ae32..bed7d363 100644 --- a/src/widget/header_bar.rs +++ b/src/widget/header_bar.rs @@ -409,6 +409,7 @@ impl<'a, Message: Clone + 'static> HeaderBar<'a, Message> { .apply(widget::container) .class(crate::theme::Container::HeaderBar { focused: self.focused, + sharp_corners: self.maximized, }) .center_y(Length::Shrink) .apply(widget::mouse_area);