From b71a7c9edffa6b278836da90106976ded9e90159 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vuka=C5=A1in=20Vojinovi=C4=87?= <150025636+git-f0x@users.noreply.github.com> Date: Wed, 28 Jan 2026 00:38:23 +0100 Subject: [PATCH] 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. --- src/app/mod.rs | 2 +- src/theme/style/iced.rs | 8 +++++++- src/widget/header_bar.rs | 5 +++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/app/mod.rs b/src/app/mod.rs index 090698df..67636dac 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -689,7 +689,6 @@ impl ApplicationExt for App { .apply(container) .width(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"))) .into() } else { @@ -713,6 +712,7 @@ impl ApplicationExt for App { .focused(focused) .maximized(maximized) .sharp_corners(sharp_corners) + .transparent(content_container) .title(&core.window.header_title) .on_drag(crate::Action::Cosmic(Action::Drag)) .on_right_click(crate::Action::Cosmic(Action::ShowWindowMenu)) diff --git a/src/theme/style/iced.rs b/src/theme/style/iced.rs index 32309860..937ee388 100644 --- a/src/theme/style/iced.rs +++ b/src/theme/style/iced.rs @@ -396,6 +396,7 @@ pub enum Container<'a> { HeaderBar { focused: bool, sharp_corners: bool, + transparent: bool, }, List, Primary, @@ -511,6 +512,7 @@ impl iced_container::Catalog for Theme { Container::HeaderBar { focused, sharp_corners, + transparent, } => { let (icon_color, text_color) = if *focused { ( @@ -527,7 +529,11 @@ impl iced_container::Catalog for Theme { iced_container::Style { icon_color: Some(icon_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 { radius: [ if *sharp_corners { diff --git a/src/widget/header_bar.rs b/src/widget/header_bar.rs index d500bde3..c5bde28f 100644 --- a/src/widget/header_bar.rs +++ b/src/widget/header_bar.rs @@ -28,6 +28,7 @@ pub fn header_bar<'a, Message>() -> HeaderBar<'a, Message> { is_ssd: false, on_double_click: None, is_condensed: false, + transparent: false, } } @@ -92,6 +93,9 @@ pub struct HeaderBar<'a, Message> { /// Whether the headerbar should be compact is_condensed: bool, + + /// Whether the headerbar should be transparent + transparent: bool, } 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 { focused: self.focused, sharp_corners: self.sharp_corners, + transparent: self.transparent, }) .center_y(Length::Shrink) .apply(widget::mouse_area);