diff --git a/Cargo.lock b/Cargo.lock index 0258de71..3ce12370 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4472,6 +4472,11 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "roxmltree" +version = "0.20.0" +source = "git+https://github.com/RazrFalcon/roxmltree?tag=v0.20.0#6dffb22cb4113a168928ca9a2eec3c2961820a98" + [[package]] name = "rustc-demangle" version = "0.1.24" @@ -6273,10 +6278,13 @@ dependencies = [ [[package]] name = "windows-icons" version = "0.1.0" -source = "git+https://github.com/LGUG2Z/windows-icons?rev=d67cc9920aa9b4883393e411fb4fa2ddd4c498b5#d67cc9920aa9b4883393e411fb4fa2ddd4c498b5" +source = "git+https://github.com/LGUG2Z/windows-icons?rev=e12e7bf2b91c49987a5e7de2e16e8556960ca1f5#e12e7bf2b91c49987a5e7de2e16e8556960ca1f5" dependencies = [ "base64", "image", + "regex", + "roxmltree", + "sysinfo", "winapi", "windows 0.58.0", ] diff --git a/komorebi-bar/Cargo.toml b/komorebi-bar/Cargo.toml index b33b2d57..cd3461e9 100644 --- a/komorebi-bar/Cargo.toml +++ b/komorebi-bar/Cargo.toml @@ -37,7 +37,7 @@ tracing = { workspace = true } tracing-subscriber = { workspace = true } windows = { workspace = true } windows-core = { workspace = true } -windows-icons = { git = "https://github.com/LGUG2Z/windows-icons", rev = "d67cc9920aa9b4883393e411fb4fa2ddd4c498b5" } +windows-icons = { git = "https://github.com/LGUG2Z/windows-icons", rev = "0c9d7ee1b807347c507d3a9862dd007b4d3f4354" } [features] default = ["schemars"] diff --git a/komorebi-bar/src/main.rs b/komorebi-bar/src/main.rs index bb92b7de..0f17495f 100644 --- a/komorebi-bar/src/main.rs +++ b/komorebi-bar/src/main.rs @@ -47,7 +47,7 @@ pub static MONITOR_INDEX: AtomicUsize = AtomicUsize::new(0); pub static BAR_HEIGHT: f32 = 50.0; pub static DEFAULT_PADDING: f32 = 10.0; -pub static ICON_CACHE: LazyLock>> = +pub static ICON_CACHE: LazyLock>> = LazyLock::new(|| Mutex::new(HashMap::new())); #[derive(Parser)] diff --git a/komorebi-bar/src/widgets/komorebi.rs b/komorebi-bar/src/widgets/komorebi.rs index c4d51057..a19cab52 100644 --- a/komorebi-bar/src/widgets/komorebi.rs +++ b/komorebi-bar/src/widgets/komorebi.rs @@ -837,11 +837,11 @@ impl From<&Container> for KomorebiNotificationStateContainerInformation { for window in windows { let mut icon_cache = ICON_CACHE.lock().unwrap(); let mut update_cache = false; - let exe = window.exe().unwrap_or_default(); + let hwnd = window.hwnd; - match icon_cache.get(&exe) { + match icon_cache.get(&hwnd) { None => { - icons.push(windows_icons::get_icon_by_process_id(window.process_id())); + icons.push(windows_icons::get_icon_by_hwnd(window.hwnd)); update_cache = true; } Some(icon) => { @@ -851,7 +851,7 @@ impl From<&Container> for KomorebiNotificationStateContainerInformation { if update_cache { if let Some(Some(icon)) = icons.last() { - icon_cache.insert(exe, icon.clone()); + icon_cache.insert(hwnd, icon.clone()); } } } @@ -873,11 +873,11 @@ impl From<&Window> for KomorebiNotificationStateContainerInformation { let mut icon_cache = ICON_CACHE.lock().unwrap(); let mut update_cache = false; let mut icons = vec![]; - let exe = value.exe().unwrap_or_default(); + let hwnd = value.hwnd; - match icon_cache.get(&exe) { + match icon_cache.get(&hwnd) { None => { - icons.push(windows_icons::get_icon_by_process_id(value.process_id())); + icons.push(windows_icons::get_icon_by_hwnd(value.hwnd)); update_cache = true; } Some(icon) => { @@ -887,7 +887,7 @@ impl From<&Window> for KomorebiNotificationStateContainerInformation { if update_cache { if let Some(Some(icon)) = icons.last() { - icon_cache.insert(exe, icon.clone()); + icon_cache.insert(hwnd, icon.clone()); } }