Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transparent window does not work on master branch (regression from 0.13) #2727

Open
4 tasks done
rhysd opened this issue Jan 13, 2025 · 3 comments
Open
4 tasks done
Labels
bug Something isn't working

Comments

@rhysd
Copy link

rhysd commented Jan 13, 2025

Is your issue REALLY a bug?

  • My issue is indeed a bug!
  • I am not crazy! I will not fill out this form just to ask a question or request a feature. Pinky promise.

Is there an existing issue for this?

  • I have searched the existing issues.

Is this issue related to iced?

  • My hardware is compatible and my graphics drivers are up-to-date.

What happened?

I have created a minimal reproduction:

use iced::theme::Style;
use iced::widget::{container, text};
use iced::{Element, Length::Fill, Theme};

pub fn main() -> iced::Result {
    iced::application("Test", Test::update, Test::view)
        .transparent(true)
        .style(Test::style)
        .run()
}

#[derive(Default)]
struct Test;

impl Test {
    fn update(&mut self, _: ()) {}

    fn view(&self) -> impl Into<Element<()>> {
        container(text("This is test")).center(Fill)
    }

    fn style(&self, theme: &Theme) -> Style {
        Style {
            background_color: iced::Color::TRANSPARENT,
            text_color: theme.palette().text,
        }
    }
}

This example should create a transparent window, but it was actually opaque:

What is the expected behavior?

With iced v0.13.1, it works fine:

image

Here is the code (slightly modified due to API changes since 0.13):

use iced::daemon::Appearance;
use iced::widget::{container, text};
use iced::{Element, Length::Fill, Theme};

pub fn main() -> iced::Result {
    iced::application("Test", Test::update, Test::view)
        .transparent(true)
        .style(Test::style)
        .run()
}

#[derive(Default)]
struct Test;

impl Test {
    fn update(&mut self, _: ()) {}

    fn view(&self) -> impl Into<Element<()>> {
        container(text("This is test")).center(Fill)
    }

    fn style(&self, theme: &Theme) -> Appearance {
        Appearance {
            background_color: iced::Color::TRANSPARENT,
            text_color: theme.palette().text,
        }
    }
}

Version

master

Operating System

macOS

Do you have any log output?

No response

@rhysd rhysd added the bug Something isn't working label Jan 13, 2025
@rhysd
Copy link
Author

rhysd commented Jan 13, 2025

I'm not sure but this looks related to the downgrade of winit crate.

  • iced v0.13.1 uses winit 0.30.8 from crates.io
  • iced master uses winit 0.30.1 from the forked repository

@rhysd
Copy link
Author

rhysd commented Jan 13, 2025

I'm not sure but this looks related to the downgrade of winit crate.

I confirmed this. The following patch fixed this issue. Is there any reason to stick with winit 0.30.1? Or is it just out-dated?

diff --git a/Cargo.toml b/Cargo.toml
index 9059cfd9..f51b3717 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -189,7 +189,8 @@ web-time = "1.1"
 wgpu = "23.0"
 winapi = "0.3"
 window_clipboard = "0.4.1"
-winit = { git = "https://github.com/iced-rs/winit.git", rev = "254d6b3420ce4e674f516f7a2bd440665e05484d" }
+winit = "0.30"
 
 [workspace.lints.rust]
 rust_2018_idioms = { level = "forbid", priority = -1 }
diff --git a/winit/src/program.rs b/winit/src/program.rs
index 499c6252..3e04f52e 100644
--- a/winit/src/program.rs
+++ b/winit/src/program.rs
@@ -401,22 +401,22 @@ where
             );
         }
 
-        fn received_url(
-            &mut self,
-            event_loop: &winit::event_loop::ActiveEventLoop,
-            url: String,
-        ) {
-            self.process_event(
-                event_loop,
-                Event::EventLoopAwakened(
-                    winit::event::Event::PlatformSpecific(
-                        winit::event::PlatformSpecific::MacOS(
-                            winit::event::MacOS::ReceivedUrl(url),
-                        ),
-                    ),
-                ),
-            );
-        }
 
         fn about_to_wait(
             &mut self,
@@ -762,19 +762,19 @@ async fn run_instance<P, C>(
                             }
                         }
                     }
-                    event::Event::PlatformSpecific(
-                        event::PlatformSpecific::MacOS(
-                            event::MacOS::ReceivedUrl(url),
-                        ),
-                    ) => {
-                        runtime.broadcast(
-                            subscription::Event::PlatformSpecific(
-                                subscription::PlatformSpecific::MacOS(
-                                    subscription::MacOS::ReceivedUrl(url),
-                                ),
-                            ),
-                        );
-                    }
                     event::Event::UserEvent(action) => {
                         run_action(
                             action,

@rhysd
Copy link
Author

rhysd commented Jan 13, 2025

I have created a PR to update our winit fork to v0.30.8 for fixing this issue at iced-rs/winit: iced-rs/winit#15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant