emoon / rust_minifb

Cross platfrom window and framebuffer crate for Rust
MIT License
1k stars 95 forks source link

Add `set_icon()` method to set a window icon at runtime #274

Closed xkevio closed 2 years ago

xkevio commented 2 years ago

I don't know if there is any interest in this functionality or if it was deliberately left out for simplicity but I went ahead and tried my best at adding a set_icon() method under Windows and X11.

Wayland is not supported since they use .desktop files to link icons and executable files. RedoxOS I am not sure they even have such a thing as icons yet. MacOS I cannot test but it seems relatively easy from what I have seen.

Now for Windows (and probably MacOS) one can just use a file and a path to it, though not with X11. X11 needs a u64 ARGB buffer and I think implementing an "any image to ARGB" converter is out of scope, so I tried to split up the functionality but probably didn't do it in the best way possible.

If there is any interest in adding this functionality, I hope someone can help adding the missing operating systems or just generally take a look at the code.

emoon commented 2 years ago

Thanks!