Skip to content

Commit

Permalink
feat: expose Icon::from_handle (#109)
Browse files Browse the repository at this point in the history
* Expose from_handle

* Update src/icon.rs

* change file

* Update .changes/icon_from_handle.md

---------

Co-authored-by: Eric Chu <[email protected]>
  • Loading branch information
ericchu94 and Eric Chu authored Jan 29, 2024
1 parent e035e90 commit ca3bed5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changes/icon_from_handle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tray-icon": "patch"
---

On Windows, add `Icon::from_handle`
7 changes: 7 additions & 0 deletions src/icon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,11 @@ impl Icon {
let win_icon = PlatformIcon::from_resource(ordinal, size)?;
Ok(Icon { inner: win_icon })
}

/// Create an icon from an HICON
#[cfg(windows)]
pub fn from_handle(handle: isize) -> Self {
let win_icon = PlatformIcon::from_handle(handle);
Icon { inner: win_icon }
}
}
2 changes: 1 addition & 1 deletion src/platform_impl/windows/icon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl WinIcon {
rgba_icon.into_windows_icon()
}

fn from_handle(handle: HICON) -> Self {
pub(crate) fn from_handle(handle: HICON) -> Self {
Self {
inner: Arc::new(RaiiIcon { handle }),
}
Expand Down

0 comments on commit ca3bed5

Please sign in to comment.