Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/fix-ico-largest-entry.md
Original file line number Diff line number Diff line change
@@ -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.
6 changes: 5 additions & 1 deletion crates/tauri-codegen/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just opened #15274, with that, I think we might be able to remove this limit here

.unwrap();
let rgba = entry
.decode()
.unwrap_or_else(|e| panic!("failed to decode icon {}: {}", icon.display(), e))
Expand Down
10 changes: 9 additions & 1 deletion crates/tauri-runtime-wry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is a good default, the task bar icon seems to fallback from ICON_BIG > ICON_SMALL > exe icon 🤔

And I don't think this belongs to here, it should be in the build method

self.inner = self.inner.with_taskbar_icon(Some(resource_icon));
}
}

Ok(self)
}

Expand Down
Loading