Add support for setting window icon#285
Conversation
hecrj
left a comment
There was a problem hiding this comment.
Looks like a good start!
We should probably add this to iced_winit only for the time being. We can figure out how to reconcile it with iced_web later.
| #[derive(Debug, Clone, PartialEq, Eq)] | ||
| pub struct Icon { | ||
| /// | ||
| rgba: Box<[u8]>, |
c21d298 to
b9fdfb8
Compare
|
@hecrj Do you mean that no code should be added to the main iced package? As far as I can see, the web package is very experimental, but I could try implementing the favicon there, too. I don't really get the build process, tough... |
This adds a new property from Settings::window::iconand a Icon struct which can be converted to winit::window::Icon. It also adds code to display this icon in Application::run. Due to the fact that the Icon struct is non copyable, I also had to remove the Copy trait from all Settings, both in `iced` and `iced_winit`.
b9fdfb8 to
9a037a2
Compare
There was a problem hiding this comment.
I have moved the Icon type to the iced crate to properly hide the iced_winit dependency and avoid breaking the Wasm target.
Additionally, I have changed Icon::from_rgba to return a proper error instead. We avoid panicking in a From trait this way.
I believe this is ready to be merged. Let me know what you think!
This PR is just to start the discussion around this topic, the code is currently a hack, the naming is not final and I just added it somewhere, not even in the right place. But since this is my first contribution to the library and my experience with Rust is not extensive, I would like if somebody more experienced can have a look an tell me if I'm on the right track.
This adds a new property from
Settings::window::iconand anIconstruct which can be converted towinit::window::Icon.It also adds code to display this icon in
Application::run.Due to the fact that the Icon struct cannot be copied, I had to remove the Copy trait from all Settings,
both in
icedandiced_winit. This is an API breaking change.Currently, I'm able to set an icon with the code:

Thanks to

winitit gets correctly displayed also on the taskbar:And of course in the window switcher (alt+tab).
Fixes #433.