remove app indicator from dock item when window closed

This commit is contained in:
Ashley Wulber 2021-12-23 13:25:56 -05:00
parent 66c5574498
commit 195470c4e0

View file

@ -145,11 +145,10 @@ fn main() {
let mut cached_results = cached_results.as_mut(); let mut cached_results = cached_results.as_mut();
results.sort_by(|a, b| a.name.cmp(&b.name)); results.sort_by(|a, b| a.name.cmp(&b.name));
dbg!(&results); // dbg!(&results);
dbg!(&cached_results); // dbg!(&cached_results);
// // check if cache equals the new polled results // // check if cache equals the new polled results
// skip if equal // skip if equal
// TODO removed closed apps from the models
if cached_results.len() == results.len() if cached_results.len() == results.len()
&& results.iter().zip(cached_results.iter()).fold( && results.iter().zip(cached_results.iter()).fold(
0, 0,
@ -188,8 +187,8 @@ fn main() {
// then put the rest in the active app model (which doesn't include saved apps) // then put the rest in the active app model (which doesn't include saved apps)
let saved_app_model = window.saved_app_model(); let saved_app_model = window.saved_app_model();
let mut i: u32 = 0; let mut saved_i: u32 = 0;
while let Some(item) = saved_app_model.item(i) { while let Some(item) = saved_app_model.item(saved_i) {
if let Ok(dock_obj) = item.downcast::<DockObject>() { if let Ok(dock_obj) = item.downcast::<DockObject>() {
if let Ok(Some(cur_app_info)) = dock_obj if let Ok(Some(cur_app_info)) = dock_obj
.property("appinfo") .property("appinfo")
@ -206,11 +205,30 @@ fn main() {
dock_obj dock_obj
.set_property("active", active.to_value()) .set_property("active", active.to_value())
.expect("failed to update dock active apps"); .expect("failed to update dock active apps");
saved_app_model.items_changed(i.try_into().unwrap(), 0, 0); saved_app_model.items_changed(
saved_i.try_into().unwrap(),
0,
0,
);
} else if let Some(_) = cached_results
.iter()
.find(|s| s.description == cur_app_info.name())
{
dock_obj
.set_property(
"active",
BoxedWindowList(Vec::new()).to_value(),
)
.expect("failed to update dock active apps");
saved_app_model.items_changed(
saved_i.try_into().unwrap(),
0,
0,
);
} }
} }
} }
i += 1; saved_i += 1;
} }
let active_app_model = window.active_app_model(); let active_app_model = window.active_app_model();