Skip to content

Commit

Permalink
fix(bar): use custom windows-icons w/o panics
Browse files Browse the repository at this point in the history
This commit uses a custom fork of windows-icons which removes runtime
panics and instead exposes a safe Option<T> based API.
  • Loading branch information
LGUG2Z committed Sep 18, 2024
1 parent 7005a01 commit 254fcc9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion komorebi-bar/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ tracing = "0.1"
tracing-appender = "0.2"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
windows = { workspace = true }
windows-icons = "0.1"
windows-icons = { git = "/~https://github.com/LGUG2Z/windows-icons", rev = "d67cc9920aa9b4883393e411fb4fa2ddd4c498b5" }
18 changes: 14 additions & 4 deletions komorebi-bar/src/komorebi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,13 @@ impl KomorebiNotificationState {
if let Ok(title) = window.title() {
self.focused_window_title.clone_from(&title);
self.focused_window_pid = Some(window.process_id());
let img = windows_icons::get_icon_by_process_id(window.process_id());
self.focused_window_icon = Some(img);
if let Some(img) =
windows_icons::get_icon_by_process_id(window.process_id())
{
self.focused_window_icon = Some(img);
} else {
self.focused_window_icon = None;
}
}
}
} else if let Some(container) =
Expand All @@ -234,8 +239,13 @@ impl KomorebiNotificationState {
if let Ok(title) = window.title() {
self.focused_window_title.clone_from(&title);
self.focused_window_pid = Some(window.process_id());
let img = windows_icons::get_icon_by_process_id(window.process_id());
self.focused_window_icon = Some(img);
if let Some(img) =
windows_icons::get_icon_by_process_id(window.process_id())
{
self.focused_window_icon = Some(img);
} else {
self.focused_window_icon = None;
}
}
}
} else {
Expand Down

0 comments on commit 254fcc9

Please sign in to comment.