Desktop: Add taskbar icon on Windows (#3225)
* include icon as resource on windows * load icon
This commit is contained in:
parent
d06c8164e1
commit
4bb1d05fc3
|
|
@ -685,7 +685,7 @@ dependencies = [
|
||||||
"serde-untagged",
|
"serde-untagged",
|
||||||
"serde-value",
|
"serde-value",
|
||||||
"thiserror 2.0.16",
|
"thiserror 2.0.16",
|
||||||
"toml",
|
"toml 0.8.23",
|
||||||
"unicode-xid",
|
"unicode-xid",
|
||||||
"url",
|
"url",
|
||||||
]
|
]
|
||||||
|
|
@ -2267,6 +2267,7 @@ dependencies = [
|
||||||
"wgpu",
|
"wgpu",
|
||||||
"windows",
|
"windows",
|
||||||
"winit",
|
"winit",
|
||||||
|
"winres",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -5550,7 +5551,7 @@ dependencies = [
|
||||||
"cfg-expr",
|
"cfg-expr",
|
||||||
"heck",
|
"heck",
|
||||||
"pkg-config",
|
"pkg-config",
|
||||||
"toml",
|
"toml 0.8.23",
|
||||||
"version-compare",
|
"version-compare",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -5816,6 +5817,15 @@ dependencies = [
|
||||||
"tokio",
|
"tokio",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "toml"
|
||||||
|
version = "0.5.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toml"
|
name = "toml"
|
||||||
version = "0.8.23"
|
version = "0.8.23"
|
||||||
|
|
@ -7357,6 +7367,15 @@ dependencies = [
|
||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winres"
|
||||||
|
version = "0.1.12"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b68db261ef59e9e52806f688020631e987592bd83619edccda9c47d42cde4f6c"
|
||||||
|
dependencies = [
|
||||||
|
"toml 0.5.11",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wit-bindgen"
|
name = "wit-bindgen"
|
||||||
version = "0.45.0"
|
version = "0.45.0"
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ serde = { workspace = true }
|
||||||
ash = { version = "0.38", optional = true }
|
ash = { version = "0.38", optional = true }
|
||||||
|
|
||||||
# Windows-specific dependencies
|
# Windows-specific dependencies
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(target_os = "windows")'.dependencies]
|
||||||
windows = { version = "0.58.0", features = [
|
windows = { version = "0.58.0", features = [
|
||||||
"Win32_Foundation",
|
"Win32_Foundation",
|
||||||
"Win32_Graphics_Direct3D11",
|
"Win32_Graphics_Direct3D11",
|
||||||
|
|
@ -72,3 +72,6 @@ core-foundation = { version = "0.9", optional = true }
|
||||||
# Linux-specific dependencies
|
# Linux-specific dependencies
|
||||||
[target.'cfg(target_os = "linux")'.dependencies]
|
[target.'cfg(target_os = "linux")'.dependencies]
|
||||||
libc = { version = "0.2", optional = true }
|
libc = { version = "0.2", optional = true }
|
||||||
|
|
||||||
|
[target.'cfg(target_os = "windows")'.build-dependencies]
|
||||||
|
winres = "0.1"
|
||||||
|
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 310 KiB |
|
|
@ -0,0 +1,8 @@
|
||||||
|
fn main() {
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
{
|
||||||
|
let mut res = winres::WindowsResource::new();
|
||||||
|
res.set_icon("assets/graphite-icon-color.ico");
|
||||||
|
res.compile().expect("Failed to compile Windows resources");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -39,8 +39,17 @@ impl NativeWindowHandle {
|
||||||
} else {
|
} else {
|
||||||
let x11_window = WindowAttributesX11::default().with_name(APP_ID, APP_NAME);
|
let x11_window = WindowAttributesX11::default().with_name(APP_ID, APP_NAME);
|
||||||
window.with_platform_attributes(Box::new(x11_window))
|
window.with_platform_attributes(Box::new(x11_window))
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
{
|
||||||
|
if let Ok(win_icon) = winit::platform::windows::WinIcon::from_resource(1, None) {
|
||||||
|
let icon = winit::icon::Icon(std::sync::Arc::new(win_icon));
|
||||||
|
window = window.with_window_icon(Some(icon));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window
|
window
|
||||||
}
|
}
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue