-
Notifications
You must be signed in to change notification settings - Fork 905
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
Window icons #497
Window icons #497
Conversation
I tested in my windows machine, with different image formats. On the other hand, would the pub struct Icon { ...}
#[cfg(feature = "icon_loading")]
pub trait IconLoading { ...}
#[cfg(feature = "icon_loading")]
impl IconLoading for Icon ... |
And could we use |
@edwin0cheng what would be the benefits of using a trait for this?
|
|
Well, people using winit won't have to worry about the feature gate in their own code, though I suppose the example doesn't do a good job reflecting that. What I mean about the icon being temporary is in regards to this blurb from the
My concern is that people might use this instead of making a |
On this vein, I will add that the only way currently to set an icon for an app in wayland is to provide an appropriate |
Tested, works for me on Windows 10 and Debian Linux. |
@icefoxen thanks for testing this! (Thanks @edwin0cheng, too!) @vberger is setting the |
Allowing to set the app id is not yet exposed afaik, but would be a trivial fix via the unix extension trait. I'm not familiar enough to know with X11 to know if/how this can be unified, maybe? The wayland |
@vberger on X11, you have to set the |
Okay, it should be the same thing then. I guess we should add some API to allow modifying it. Wayland allows to modify this at basically any time, and it's a very straightforward thing: just call the So I guess the best would be to design some platform-specific API fitting the X11 requirements, and plug the wayland backend on that. What do you think? |
@vberger yeah, that sounds good. Anyway, I've finished rebasing the Windows DPI PR, so now I'll look into getting the DPI API situation sorted out. |
Fixes #69
I ended up changing the design of this several times, so this fairly innocuous feature is the thing that finally burned me out.
WindowBuilder::with_window_icon
andWindow::set_window_icon
exist now, and are implemented on X11 and Windows (which are the only applicable platforms). I didn't put this behind platform ext traits, simply for ergonomic reasons.Icon::from_rgba
is a checked way to create icons from raw RGBA data. It's not possible to create an icon that isn't valid (which is to say, an icon that can't be indexed as RGBA).icon_loading
feature enabled, there's integration with the image crate.Icon::from_path
,Icon::from_bytes
(you can use this withinclude_bytes!
),Icon::from_reader
,From<image::DynamicImage>
, andFrom<image::RgbaImage>
.WindowAttributes
andPlatformSpecificWindowBuilderAttributes
are now moved to window constructors instead of borrowed. It didn't look like there was any reason for them to need to be borrowed, and taking ownership of the icon data gives us more opportunity to do things in-place. Though, it doesn't really matter, since on Windows we still have to clone for other reasons (which will probably be resolved in the future), and on X11 we can't use the data in-place either way.WindowBuilderExt::with_taskbar_icon
andWindowExt::set_taskbar_icon
. It's likely better to use manifests for this..desktop
files, but we don't yet set (or expose) enough hints for those to be used. That should be easy to resolve in future work.In my personal opinion, the example program I made for this is really cool. Someone should make a game played entirely in the window icon...