Add window icon on X11 and Windows

This commit is contained in:
UK992 2018-06-24 19:58:05 +02:00
parent a3767de9fe
commit 4225cd52a8
3 changed files with 9 additions and 2 deletions

View file

@ -43,7 +43,7 @@ lazy_static = "1"
libservo = {path = "../../components/servo"}
log = "0.4"
tinyfiledialogs = "3.0"
winit = "0.15"
winit = {version = "0.15", features = ["icon_loading"]}
[target.'cfg(not(target_os = "android"))'.dependencies]
sig = "0.1"

View file

@ -201,6 +201,13 @@ impl Window {
.with_visibility(visible)
.with_multitouch();
#[cfg(any(target_os = "linux", target_os = "windows"))]
{
let icon_bytes = include_bytes!("../../../resources/servo64.png");
let icon = Some(winit::Icon::from_bytes(icon_bytes).expect("Failed to open icon"));
window_builder = window_builder.with_window_icon(icon);
}
window_builder = builder_with_platform_options(window_builder);
let mut context_builder = ContextBuilder::new()
@ -525,7 +532,7 @@ impl Window {
..
} => self.event_queue.borrow_mut().push(WindowEvent::Refresh),
Event::WindowEvent {
event: winit::WindowEvent::Closed,
event: winit::WindowEvent::CloseRequested,
..
} => {
self.event_queue.borrow_mut().push(WindowEvent::Quit);

BIN
resources/servo64.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB