diff --git a/.changes/fix-ico-largest-entry.md b/.changes/fix-ico-largest-entry.md new file mode 100644 index 000000000000..eceebc37741a --- /dev/null +++ b/.changes/fix-ico-largest-entry.md @@ -0,0 +1,6 @@ +--- +"tauri-codegen": patch:bug +"tauri-runtime-wry": patch:bug +--- + +On Windows, set `ICON_BIG` from the exe-embedded ICO resource via `IconExtWindows::from_resource` for crisp taskbar and alt-tab icons. Cap the codegen ICO entry at 32x32 for `ICON_SMALL` to reduce binary size. diff --git a/crates/tauri-codegen/src/image.rs b/crates/tauri-codegen/src/image.rs index 49546082a9b7..e9c7384104f4 100644 --- a/crates/tauri-codegen/src/image.rs +++ b/crates/tauri-codegen/src/image.rs @@ -54,7 +54,11 @@ impl CachedIcon { let icon_dir = ico::IconDir::read(Cursor::new(&buf)) .unwrap_or_else(|e| panic!("failed to parse icon {}: {}", icon.display(), e)); - let entry = &icon_dir.entries()[0]; + let entry = icon_dir + .entries() + .iter() + .min_by_key(|e| e.width().abs_diff(32)) + .unwrap(); let rgba = entry .decode() .unwrap_or_else(|e| panic!("failed to decode icon {}: {}", icon.display(), e)) diff --git a/crates/tauri-runtime-wry/src/lib.rs b/crates/tauri-runtime-wry/src/lib.rs index 6c537de6cf43..b6cb3baadb6a 100644 --- a/crates/tauri-runtime-wry/src/lib.rs +++ b/crates/tauri-runtime-wry/src/lib.rs @@ -48,7 +48,7 @@ use tao::platform::macos::{EventLoopWindowTargetExtMacOS, WindowBuilderExtMacOS} ))] use tao::platform::unix::{WindowBuilderExtUnix, WindowExtUnix}; #[cfg(windows)] -use tao::platform::windows::{WindowBuilderExtWindows, WindowExtWindows}; +use tao::platform::windows::{IconExtWindows, WindowBuilderExtWindows, WindowExtWindows}; #[cfg(windows)] use webview2_com::{ContainsFullScreenElementChangedEventHandler, FocusChangedEventHandler}; #[cfg(windows)] @@ -1222,6 +1222,14 @@ impl WindowBuilder for WindowBuilderWrapper { self.inner = self .inner .with_window_icon(Some(TaoIcon::try_from(icon)?.0)); + + #[cfg(windows)] + { + if let Ok(resource_icon) = TaoWindowIcon::from_resource(32512, None) { + self.inner = self.inner.with_taskbar_icon(Some(resource_icon)); + } + } + Ok(self) }