improv: remove double coloring of content_container windows

This sets the main content and the header bar to transparent when `content_container` is true, so that things aren't colored twice and overlayed on top of each other.
This ensures that modifying color alpha behaves as expected, especially for frosted glass.
This commit is contained in:
Vukašin Vojinović 2026-01-28 00:38:23 +01:00 committed by Jeremy Soller
parent 9fcd449611
commit b71a7c9edf
3 changed files with 13 additions and 2 deletions

View file

@ -689,7 +689,6 @@ impl<App: Application> ApplicationExt for App {
.apply(container) .apply(container)
.width(iced::Length::Fill) .width(iced::Length::Fill)
.height(iced::Length::Fill) .height(iced::Length::Fill)
.class(crate::theme::Container::WindowBackground)
.apply(|w| id_container(w, iced_core::id::Id::new("COSMIC_content_container"))) .apply(|w| id_container(w, iced_core::id::Id::new("COSMIC_content_container")))
.into() .into()
} else { } else {
@ -713,6 +712,7 @@ impl<App: Application> ApplicationExt for App {
.focused(focused) .focused(focused)
.maximized(maximized) .maximized(maximized)
.sharp_corners(sharp_corners) .sharp_corners(sharp_corners)
.transparent(content_container)
.title(&core.window.header_title) .title(&core.window.header_title)
.on_drag(crate::Action::Cosmic(Action::Drag)) .on_drag(crate::Action::Cosmic(Action::Drag))
.on_right_click(crate::Action::Cosmic(Action::ShowWindowMenu)) .on_right_click(crate::Action::Cosmic(Action::ShowWindowMenu))

View file

@ -396,6 +396,7 @@ pub enum Container<'a> {
HeaderBar { HeaderBar {
focused: bool, focused: bool,
sharp_corners: bool, sharp_corners: bool,
transparent: bool,
}, },
List, List,
Primary, Primary,
@ -511,6 +512,7 @@ impl iced_container::Catalog for Theme {
Container::HeaderBar { Container::HeaderBar {
focused, focused,
sharp_corners, sharp_corners,
transparent,
} => { } => {
let (icon_color, text_color) = if *focused { let (icon_color, text_color) = if *focused {
( (
@ -527,7 +529,11 @@ impl iced_container::Catalog for Theme {
iced_container::Style { iced_container::Style {
icon_color: Some(icon_color), icon_color: Some(icon_color),
text_color: Some(text_color), text_color: Some(text_color),
background: Some(iced::Background::Color(cosmic.background.base.into())), background: if *transparent {
None
} else {
Some(iced::Background::Color(cosmic.background.base.into()))
},
border: Border { border: Border {
radius: [ radius: [
if *sharp_corners { if *sharp_corners {

View file

@ -28,6 +28,7 @@ pub fn header_bar<'a, Message>() -> HeaderBar<'a, Message> {
is_ssd: false, is_ssd: false,
on_double_click: None, on_double_click: None,
is_condensed: false, is_condensed: false,
transparent: false,
} }
} }
@ -92,6 +93,9 @@ pub struct HeaderBar<'a, Message> {
/// Whether the headerbar should be compact /// Whether the headerbar should be compact
is_condensed: bool, is_condensed: bool,
/// Whether the headerbar should be transparent
transparent: bool,
} }
impl<'a, Message: Clone + 'static> HeaderBar<'a, Message> { impl<'a, Message: Clone + 'static> HeaderBar<'a, Message> {
@ -412,6 +416,7 @@ impl<'a, Message: Clone + 'static> HeaderBar<'a, Message> {
.class(crate::theme::Container::HeaderBar { .class(crate::theme::Container::HeaderBar {
focused: self.focused, focused: self.focused,
sharp_corners: self.sharp_corners, sharp_corners: self.sharp_corners,
transparent: self.transparent,
}) })
.center_y(Length::Shrink) .center_y(Length::Shrink)
.apply(widget::mouse_area); .apply(widget::mouse_area);