mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-03-29 21:52:05 +02:00
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
This commit is contained in:
10
Cargo.lock
generated
10
Cargo.lock
generated
@@ -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",
|
||||
]
|
||||
|
||||
@@ -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"]
|
||||
|
||||
@@ -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<Mutex<HashMap<String, RgbaImage>>> =
|
||||
pub static ICON_CACHE: LazyLock<Mutex<HashMap<isize, RgbaImage>>> =
|
||||
LazyLock::new(|| Mutex::new(HashMap::new()));
|
||||
|
||||
#[derive(Parser)]
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user