Skip to content

Conversation

@pml68
Copy link
Contributor

@pml68 pml68 commented Apr 24, 2025

Extends #2728 to support Windows in addition to MacOS and Linux.

@airstrike
Copy link
Contributor

airstrike commented Apr 26, 2025

I was just playing around with this PR. For some reason, I can only really see the blur effect when I use a dark background theme.

I could be wrong, but it is my understanding that the actual app background color comes from the Theme's implementation of the Base trait, which for iced::Theme is:

/// The default [`Style`] of a built-in [`Theme`].
pub fn default(theme: &Theme) -> Style {
    let palette = theme.extended_palette();

    Style {
        background_color: palette.background.base.color,
        text_color: palette.background.base.text,
    }
}

Below is a screenshot of a sample app if you run it with an iced::Theme::Custom defined as:

impl App {
    fn theme(&self) -> iced::Theme {
        let default = iced::Theme::default();
        let palette = iced::theme::Palette {
            background: default.palette().background.scale_alpha(0.05),
            ..default.palette()
        };
        iced::Theme::custom("Transparent".to_string(), palette)
    }
    // ...
}

image

The top one is what I get when the system theme is set to dark, bottom when set to light.

@watsaig
Copy link
Contributor

watsaig commented Jun 5, 2025

@airstrike I know this was a while ago but have you looked into it any more since your comment? This actually isn't tied to blurring, it also happens on master and 0.13 with a transparent window. It's easy to test with the styling example (tying slider value to background opacity, adding .transparent(true) to the app initialization and making basically the same changes as you to the theme)

But if you set the background color to iced::Color::TRANSPARENT, it does go completely clear. It seems to be related to the rgb values of the color, so that even setting alpha = 0 actually causes different results depending on the color's components. There's some weird mac shenanigans there because when I first ran into this, screenshotting the window made the issue disappear (discord link with photo + screenshot)

@watsaig
Copy link
Contributor

watsaig commented Jun 5, 2025

FWIW I get a similar issue on Windows, too, where the light background isn't transparent but the dark background is. I have a modified styling example in this branch to quickly play around with this (slider value affects background alpha).

Also on Windows, a fully transparent background is still blurred whereas on mac, blur only kicks in with alpha > 0.0 (the latter is quite nice, would be great if that behavior could be achieved in windows too)

@pml68 pml68 marked this pull request as draft September 23, 2025 20:52
@hecrj
Copy link
Member

hecrj commented Nov 19, 2025

@watsaig We likely need to pre-multiply the alpha in the final framebuffer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants