Skip to content

Commit c455e92

Browse files
committed
feat(bar): show icons for uwp apps
This commit integrates the excellent investigation and work done by @davor-skontra on the windows-icons repo to enable the retrieval of UWP applications, including all those annoying Microsoft applications which all share the ApplicationFrameHost.exe executable and the ApplicationFrameWindow class. Since these applications share the same executable, the icon cache in komorei-bar has been updated to use the window hwnd as a key intead of the window executable. resolve #1226
1 parent 64d29d6 commit c455e92

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

Cargo.lock

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

komorebi-bar/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ tracing = { workspace = true }
3737
tracing-subscriber = { workspace = true }
3838
windows = { workspace = true }
3939
windows-core = { workspace = true }
40-
windows-icons = { git = "https://github.com/LGUG2Z/windows-icons", rev = "d67cc9920aa9b4883393e411fb4fa2ddd4c498b5" }
40+
windows-icons = { git = "https://github.com/LGUG2Z/windows-icons", rev = "e12e7bf2b91c49987a5e7de2e16e8556960ca1f5" }
4141

4242
[features]
4343
default = ["schemars"]

komorebi-bar/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub static MONITOR_INDEX: AtomicUsize = AtomicUsize::new(0);
4747
pub static BAR_HEIGHT: f32 = 50.0;
4848
pub static DEFAULT_PADDING: f32 = 10.0;
4949

50-
pub static ICON_CACHE: LazyLock<Mutex<HashMap<String, RgbaImage>>> =
50+
pub static ICON_CACHE: LazyLock<Mutex<HashMap<isize, RgbaImage>>> =
5151
LazyLock::new(|| Mutex::new(HashMap::new()));
5252

5353
#[derive(Parser)]

komorebi-bar/src/widgets/komorebi.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -837,11 +837,11 @@ impl From<&Container> for KomorebiNotificationStateContainerInformation {
837837
for window in windows {
838838
let mut icon_cache = ICON_CACHE.lock().unwrap();
839839
let mut update_cache = false;
840-
let exe = window.exe().unwrap_or_default();
840+
let hwnd = window.hwnd;
841841

842-
match icon_cache.get(&exe) {
842+
match icon_cache.get(&hwnd) {
843843
None => {
844-
icons.push(windows_icons::get_icon_by_process_id(window.process_id()));
844+
icons.push(windows_icons::get_icon_by_hwnd(window.hwnd));
845845
update_cache = true;
846846
}
847847
Some(icon) => {
@@ -851,7 +851,7 @@ impl From<&Container> for KomorebiNotificationStateContainerInformation {
851851

852852
if update_cache {
853853
if let Some(Some(icon)) = icons.last() {
854-
icon_cache.insert(exe, icon.clone());
854+
icon_cache.insert(hwnd, icon.clone());
855855
}
856856
}
857857
}
@@ -873,11 +873,11 @@ impl From<&Window> for KomorebiNotificationStateContainerInformation {
873873
let mut icon_cache = ICON_CACHE.lock().unwrap();
874874
let mut update_cache = false;
875875
let mut icons = vec![];
876-
let exe = value.exe().unwrap_or_default();
876+
let hwnd = value.hwnd;
877877

878-
match icon_cache.get(&exe) {
878+
match icon_cache.get(&hwnd) {
879879
None => {
880-
icons.push(windows_icons::get_icon_by_process_id(value.process_id()));
880+
icons.push(windows_icons::get_icon_by_hwnd(value.hwnd));
881881
update_cache = true;
882882
}
883883
Some(icon) => {
@@ -887,7 +887,7 @@ impl From<&Window> for KomorebiNotificationStateContainerInformation {
887887

888888
if update_cache {
889889
if let Some(Some(icon)) = icons.last() {
890-
icon_cache.insert(exe, icon.clone());
890+
icon_cache.insert(hwnd, icon.clone());
891891
}
892892
}
893893

0 commit comments

Comments
 (0)