Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
perf(windows-picker): cache process info and speed icon PNG
Kyzer2604e5a73daa
diff --git a/apps/desktop-gpui/src/devices.rs b/apps/desktop-gpui/src/devices.rsindex de540e0b5..c2fa1cf56 100644--- a/apps/desktop-gpui/src/devices.rs+++ b/apps/desktop-gpui/src/devices.rs@@ -888,20 +888,37 @@ pub fn list_windows() -> Vec<WindowOption> {/// `collect_windows_with_thumbnails` (`thumbnails/mod.rs:107-137`), which needs/// the handle for both the ScreenCaptureKit filter and `Window::app_icon()`.pub fn list_window_targets() -> Vec<(WindowOption, Window)> {+ list_window_targets_inner(+ #[cfg(target_os = "windows")]+ &mut scap_targets::platform::WindowListCache::default(),+ )+}++pub(crate) fn list_window_targets_inner(+ #[cfg(target_os = "windows")] cache: &mut scap_targets::platform::WindowListCache,+) -> Vec<(WindowOption, Window)> {#[cfg(target_os = "linux")]if let Some(targets) = linux_window_targets_from_snapshot() {return targets;}- Window::list()+ #[cfg(target_os = "windows")]+ let windows = cache.list();+ #[cfg(not(target_os = "windows"))]+ let windows = Window::list();++ windows.into_iter().filter_map(|window| {#[cfg(target_os = "windows")]- if !window.raw_handle().is_valid() || !window.raw_handle().is_on_screen() {+ if !cache.is_valid(&window) || !cache.is_on_screen(&window) {return None;}let label = window.name().filter(|name| !name.trim().is_empty())?;+ #[cfg(target_os = "windows")]+ let app = cache.owner_name(&window)?;+ #[cfg(not(target_os = "windows"))]let app = window.owner_name()?;if app == "Window Server" {diff --git a/apps/desktop-gpui/src/target_thumbnails.rs b/apps/desktop-gpui/src/target_thumbnails.rsindex b3019eab0..91c3a3a5c 100644--- a/apps/desktop-gpui/src/target_thumbnails.rs+++ b/apps/desktop-gpui/src/target_thumbnails.rs@@ -669,6 +669,11 @@ async fn capture_windows_inner(events: flume::Sender<WindowEvent>,current: HashMap<String, CapturedWindow>,) {+ #[cfg(target_os = "windows")]+ let mut window_cache = scap_targets::platform::WindowListCache::default();+ #[cfg(target_os = "windows")]+ let targets = crate::devices::list_window_targets_inner(&mut window_cache);+ #[cfg(not(target_os = "windows"))]let targets = crate::devices::list_window_targets();let total = targets.len();let mut captured = 0usize;@@ -716,7 +721,11 @@ async fn capture_windows_inner(return;};let image = capture.map(crate::library::rgba_to_render_image);- let app_icon = window.app_icon().filter(|bytes| !bytes.is_empty());+ #[cfg(target_os = "windows")]+ let app_icon = window_cache.app_icon(&window);+ #[cfg(not(target_os = "windows"))]+ let app_icon = window.app_icon();+ let app_icon = app_icon.filter(|bytes| !bytes.is_empty());if image.is_some() {captured += 1;}diff --git a/crates/scap-targets/examples/windows_picker_bench.rs b/crates/scap-targets/examples/windows_picker_bench.rsnew file mode 100644index 000000000..13f6e1785--- /dev/null+++ b/crates/scap-targets/examples/windows_picker_bench.rs@@ -0,0 +1,186 @@+#[cfg(windows)]+mod windows_bench {+ use scap_targets::Window;+ use scap_targets::platform::WindowListCache;+ use std::{hint::black_box, time::Instant};++ fn picker_windows(cache: &mut WindowListCache) -> Vec<(Window, String, String)> {+ cache+ .list()+ .into_iter()+ .filter_map(|window| {+ if !cache.is_valid(&window) || !cache.is_on_screen(&window) {+ return None;+ }+ let name = window.name().filter(|name| !name.trim().is_empty())?;+ let owner = cache.owner_name(&window)?;+ if owner == "Window Server" {+ return None;+ }+ black_box(+ window+ .logical_size()+ .map(|size| (size.width() as u32, size.height() as u32)),+ );+ black_box(+ window+ .display_relative_logical_bounds()+ .map(|bounds| (bounds.position().x(), bounds.position().y())),+ );+ black_box(window.display().map(|display| display.refresh_rate()));+ Some((window, name, owner))+ })+ .collect()+ }++ fn report(name: &str, samples: &[f64]) {+ let mut sorted = samples.to_vec();+ sorted.sort_by(f64::total_cmp);+ let median = (sorted[(sorted.len() - 1) / 2] + sorted[sorted.len() / 2]) / 2.0;+ let mean = samples.iter().sum::<f64>() / samples.len() as f64;+ println!(+ "{name}: median_ms={median:.6} mean_ms={mean:.6} trials={}",+ samples.len()+ );+ println!("{name}_samples_ms={samples:?}");+ }++ pub fn run() {+ let trials = std::env::args()+ .nth(1)+ .map(|value| value.parse::<usize>().expect("trial count"))+ .unwrap_or(30);+ assert!(trials >= 20);+ if std::env::var_os("CAP_WINDOWS_PICKER_PNG_FILTERS").is_some() {+ png_filters(trials);+ return;+ }+ let mut listing = Vec::new();+ let mut picker = Vec::new();+ let mut icons = Vec::new();+ let mut repeated_icons = Vec::new();+ for trial in 0..trials + 3 {+ let start = Instant::now();+ let windows = black_box(Window::list());+ let list_ms = start.elapsed().as_secs_f64() * 1000.0;+ let start = Instant::now();+ let mut cache = WindowListCache::default();+ let targets = black_box(picker_windows(&mut cache));+ let picker_ms = start.elapsed().as_secs_f64() * 1000.0;+ let start = Instant::now();+ let pngs: Vec<_> = targets+ .iter()+ .map(|(window, _, _)| black_box(cache.app_icon(window)))+ .collect();+ let icons_ms = start.elapsed().as_secs_f64() * 1000.0;+ let start = Instant::now();+ let repeated: Vec<_> = targets+ .iter()+ .map(|(window, _, _)| black_box(cache.app_icon(window)))+ .collect();+ let repeated_ms = start.elapsed().as_secs_f64() * 1000.0;+ assert_eq!(pngs, repeated);+ if trial >= 3 {+ listing.push(list_ms);+ picker.push(picker_ms);+ icons.push(icons_ms);+ repeated_icons.push(repeated_ms);+ println!(+ "trial={} listed={} picker={} icons={}",+ trial - 2,+ windows.len(),+ targets.len(),+ pngs.iter().filter(|icon| icon.is_some()).count()+ );+ }+ }+ report("Window_list", &listing);+ report("picker_list", &picker);+ report("picker_icons", &icons);+ report("picker_icons_same_refresh_repeat", &repeated_icons);+ let mut cache = WindowListCache::default();+ for (window, name, owner) in picker_windows(&mut cache) {+ let icon = cache.app_icon(&window).map(|bytes| {+ let rgba = image::load_from_memory(&bytes)+ .expect("valid PNG")+ .into_rgba8();+ let hash = rgba+ .as_raw()+ .iter()+ .fold(0xcbf29ce484222325_u64, |hash, byte| {+ (hash ^ u64::from(*byte)).wrapping_mul(0x100000001b3)+ });+ (rgba.width(), rgba.height(), hash)+ });+ println!(+ "snapshot id={} owner={} name={} icon={icon:?}",+ window.id(),+ owner.escape_default(),+ name.escape_default()+ );+ }+ }++ fn png_filters(trials: usize) {+ use image::{+ ImageEncoder,+ codecs::png::{CompressionType, FilterType, PngEncoder},+ };+ let images: Vec<_> = picker_windows(&mut WindowListCache::default())+ .into_iter()+ .filter_map(|(window, _, _)| window.app_icon())+ .map(|bytes| {+ image::load_from_memory(&bytes)+ .expect("valid PNG")+ .into_rgba8()+ })+ .collect();+ for filter in [FilterType::Adaptive, FilterType::Sub, FilterType::NoFilter] {+ let mut samples = Vec::new();+ let mut byte_count = 0;+ for trial in 0..trials + 3 {+ let start = Instant::now();+ let encoded: Vec<_> = images+ .iter()+ .map(|image| {+ let mut png = Vec::new();+ PngEncoder::new_with_quality(&mut png, CompressionType::Fast, filter)+ .write_image(+ image.as_raw(),+ image.width(),+ image.height(),+ image::ColorType::Rgba8,+ )+ .expect("encode PNG");+ png+ })+ .collect();+ let elapsed = start.elapsed().as_secs_f64() * 1000.0;+ if trial >= 3 {+ samples.push(elapsed);+ }+ byte_count = encoded.iter().map(Vec::len).sum::<usize>();+ for (original, png) in images.iter().zip(encoded) {+ assert_eq!(+ original,+ &image::load_from_memory(&png)+ .expect("valid PNG")+ .into_rgba8()+ );+ }+ }+ report(&format!("PNG_{filter:?}"), &samples);+ println!(+ "PNG_{filter:?}: icons={} bytes={byte_count} pixels_equal=true",+ images.len()+ );+ }+ }+}++fn main() {+ #[cfg(windows)]+ windows_bench::run();+ #[cfg(not(windows))]+ eprintln!("windows_picker_bench requires Windows");+}diff --git a/crates/scap-targets/src/platform/win.rs b/crates/scap-targets/src/platform/win.rsindex 0a824ae68..03d42f5f0 100644--- a/crates/scap-targets/src/platform/win.rs+++ b/crates/scap-targets/src/platform/win.rs@@ -1,4 +1,10 @@+use image::{+ ImageEncoder,+ codecs::png::{CompressionType, FilterType, PngEncoder},+};use std::{+ cell::OnceCell,+ collections::HashMap,ffi::OsString,mem,os::windows::ffi::OsStringExt,@@ -308,20 +314,88 @@ fn get_cursor_position() -> Option<PhysicalPosition> {}}+#[derive(Default)]+pub struct WindowListCache {+ processes: HashMap<u32, ProcessMetadata>,+ executable_icons: HashMap<PathBuf, Option<Vec<u8>>>,+}++struct ProcessMetadata {+ path: Option<PathBuf>,+ owner_name: OnceCell<Option<String>>,+}++impl WindowListCache {+ pub fn list(&mut self) -> Vec<crate::Window> {+ self.processes.clear();+ self.executable_icons.clear();+ WindowImpl::list_with_cache(self)+ .into_iter()+ .map(crate::Window)+ .collect()+ }++ pub fn is_valid(&mut self, window: &crate::Window) -> bool {+ window.raw_handle().is_valid_with_cache(self)+ }++ pub fn is_on_screen(&mut self, window: &crate::Window) -> bool {+ window.raw_handle().is_on_screen_with_cache(self)+ }++ pub fn owner_name(&mut self, window: &crate::Window) -> Option<String> {+ self.window_owner_name(window.raw_handle())+ }++ pub fn app_icon(&mut self, window: &crate::Window) -> Option<Vec<u8>> {+ window.raw_handle().app_icon_with_cache(self)+ }++ fn process(&mut self, pid: u32) -> &ProcessMetadata {+ self.processes+ .entry(pid)+ .or_insert_with(|| ProcessMetadata {+ path: unsafe { pid_to_exe_path(pid) }.ok(),+ owner_name: OnceCell::new(),+ })+ }++ fn window_owner_name(&mut self, window: &WindowImpl) -> Option<String> {+ let process = self.process(window.process_id());+ let path = process.path.as_ref()?;+ process+ .owner_name+ .get_or_init(|| {+ let path = path.to_string_lossy();+ WindowImpl::get_file_description(&path).or_else(|| {+ Path::new(path.as_ref())+ .file_stem()+ .map(|stem| stem.to_string_lossy().into_owned())+ })+ })+ .clone()+ }+}+#[derive(Clone, Copy)]pub struct WindowImpl(HWND);impl WindowImpl {pub fn list() -> Vec<Self> {- struct EnumContext {+ Self::list_with_cache(&mut WindowListCache::default())+ }++ fn list_with_cache(cache: &mut WindowListCache) -> Vec<Self> {+ struct EnumContext<'a> {list: Vec<WindowImpl>,current_process_id: u32,+ cache: &'a mut WindowListCache,}unsafe extern "system" fn enum_windows_proc(hwnd: HWND, lparam: LPARAM) -> BOOL {let context = unsafe { &mut *(lparam.0 as *mut EnumContext) };- if is_window_valid_for_enumeration(hwnd, context.current_process_id) {+ if is_window_valid_for_enumeration(hwnd, context.current_process_id, context.cache) {context.list.push(WindowImpl(hwnd));}@@ -331,6 +405,7 @@ impl WindowImpl {let mut context = EnumContext {list: vec![],current_process_id: unsafe { GetCurrentProcessId() },+ cache,};unsafe {@@ -474,48 +549,16 @@ impl WindowImpl {}pub fn owner_name(&self) -> Option<String> {- unsafe {- let mut process_id = 0u32;- GetWindowThreadProcessId(self.0, Some(&mut process_id));-- if process_id == 0 {- return None;- }-- let process_handle =- OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, false, process_id).ok()?;-- let mut buffer = [0u16; 1024];- let mut buffer_size = buffer.len() as u32;-- let result = QueryFullProcessImageNameW(- process_handle,- PROCESS_NAME_FORMAT::default(),- PWSTR(buffer.as_mut_ptr()),- &mut buffer_size,- );-- let _ = CloseHandle(process_handle);-- if result.is_ok() && buffer_size > 0 {- let path_str = String::from_utf16_lossy(&buffer[..buffer_size as usize]);-- // Try to get the friendly name from version info first- if let Some(friendly_name) = self.get_file_description(&path_str) {- return Some(friendly_name);- }+ WindowListCache::default().window_owner_name(self)+ }- // Fallback to file stem- std::path::Path::new(&path_str)- .file_stem()- .map(|stem| stem.to_string_lossy().into_owned())- } else {- None- }- }+ fn process_id(&self) -> u32 {+ let mut pid = 0;+ unsafe { GetWindowThreadProcessId(self.0, Some(&mut pid)) };+ pid}- fn get_file_description(&self, file_path: &str) -> Option<String> {+ fn get_file_description(file_path: &str) -> Option<String> {unsafe {let wide_path: Vec<u16> = file_path.encode_utf16().chain(std::iter::once(0)).collect();@@ -562,21 +605,27 @@ impl WindowImpl {}pub fn app_icon(&self) -> Option<Vec<u8>> {- unsafe {- // Target size for acceptable icon quality - early termination threshold- const GOOD_SIZE_THRESHOLD: i32 = 256;+ self.app_icon_with_cache(&mut WindowListCache::default())+ }- if let Some(exe_path) = self.get_executable_path()- && let Some(icon_data) = self.extract_shell_icon_high_res(&exe_path, 512)- {- return Some(icon_data);+ fn app_icon_with_cache(&self, cache: &mut WindowListCache) -> Option<Vec<u8>> {+ let exe_path = cache.process(self.process_id()).path.clone();+ if let Some(path) = &exe_path {+ let icon = cache+ .executable_icons+ .entry(path.clone())+ .or_insert_with(|| {+ let path = path.to_string_lossy();+ self.extract_shell_icon_high_res(&path, 512)+ .or_else(|| self.extract_executable_icons_high_res(&path))+ });+ if let Some(icon) = icon {+ return Some(icon.clone());}+ }- if let Some(exe_path) = self.get_executable_path()- && let Some(icon_data) = self.extract_executable_icons_high_res(&exe_path)- {- return Some(icon_data);- }+ unsafe {+ const GOOD_SIZE_THRESHOLD: i32 = 256;// Method 3: Try to get the window's large iconlet large_icon = SendMessageW(@@ -594,9 +643,12 @@ impl WindowImpl {}// Method 4: Try executable file extraction (fallback to original method)- if let Some(exe_path) = self.get_executable_path() {- let wide_path: Vec<u16> =- exe_path.encode_utf16().chain(std::iter::once(0)).collect();+ if let Some(exe_path) = &exe_path {+ let wide_path: Vec<u16> = exe_path+ .to_string_lossy()+ .encode_utf16()+ .chain(std::iter::once(0))+ .collect();let mut large_icon: HICON = HICON::default();let mut small_icon: HICON = HICON::default();@@ -762,38 +814,6 @@ impl WindowImpl {}}- fn get_executable_path(&self) -> Option<String> {- unsafe {- let mut process_id = 0u32;- GetWindowThreadProcessId(self.0, Some(&mut process_id));-- if process_id == 0 {- return None;- }-- let process_handle =- OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, false, process_id).ok()?;-- let mut buffer = [0u16; 1024];- let mut buffer_size = buffer.len() as u32;-- let result = QueryFullProcessImageNameW(- process_handle,- PROCESS_NAME_FORMAT::default(),- PWSTR(buffer.as_mut_ptr()),- &mut buffer_size,- );-- let _ = CloseHandle(process_handle);-- if result.is_ok() && buffer_size > 0 {- Some(String::from_utf16_lossy(&buffer[..buffer_size as usize]))- } else {- None- }- }- }-fn get_icon_size(&self, icon: HICON) -> Option<(i32, i32)> {unsafe {let mut icon_info = ICONINFO::default();@@ -962,19 +982,21 @@ impl WindowImpl {chunk.swap(0, 2);}- if let Some(img) =- image::RgbaImage::from_raw(width as u32, height as u32, buffer)+ let mut png_data = Vec::new();+ if PngEncoder::new_with_quality(+ &mut png_data,+ CompressionType::Fast,+ FilterType::Sub,+ )+ .write_image(+ &buffer,+ width as u32,+ height as u32,+ image::ColorType::Rgba8,+ )+ .is_ok(){- let mut png_data = Vec::new();- if img- .write_to(- &mut std::io::Cursor::new(&mut png_data),- image::ImageFormat::Png,- )- .is_ok()- {- result = Some((png_data, width));- }+ result = Some((png_data, width));}}}@@ -1125,6 +1147,10 @@ impl WindowImpl {}pub fn is_on_screen(&self) -> bool {+ self.is_on_screen_with_cache(&mut WindowListCache::default())+ }++ fn is_on_screen_with_cache(&self, cache: &mut WindowListCache) -> bool {if !unsafe { IsWindowVisible(self.0) }.as_bool() {return false;}@@ -1144,12 +1170,8 @@ impl WindowImpl {return false;}- let mut process_id = 0;- unsafe { GetWindowThreadProcessId(self.0, Some(&mut process_id)) };-- let owner_process_path = match unsafe { pid_to_exe_path(process_id) } {- Ok(path) => path,- Err(_) => return false,+ let Some(owner_process_path) = &cache.process(self.process_id()).path else {+ return false;};if owner_process_path.starts_with("C:\\Windows\\SystemApps") {@@ -1160,18 +1182,21 @@ impl WindowImpl {}pub fn is_valid(&self) -> bool {+ self.is_valid_with_cache(&mut WindowListCache::default())+ }++ fn is_valid_with_cache(&self, cache: &mut WindowListCache) -> bool {if !unsafe { IsWindowVisible(self.0).as_bool() } {return false;}- let mut id = 0;- unsafe { GetWindowThreadProcessId(self.0, Some(&mut id)) };+ let id = self.process_id();if id == unsafe { GetCurrentProcessId() } {return false;}- if let Ok(exe_path) = unsafe { pid_to_exe_path(id) }- && is_ignored_executable(&exe_path)+ if let Some(exe_path) = &cache.process(id).path+ && is_ignored_executable(exe_path){return false;}@@ -1211,7 +1236,11 @@ fn is_ignored_executable(path: &Path) -> bool {})}-fn is_window_valid_for_enumeration(hwnd: HWND, current_process_id: u32) -> bool {+fn is_window_valid_for_enumeration(+ hwnd: HWND,+ current_process_id: u32,+ cache: &mut WindowListCache,+) -> bool {unsafe {if !IsWindowVisible(hwnd).as_bool() || IsIconic(hwnd).as_bool() {return false;@@ -1223,8 +1252,8 @@ fn is_window_valid_for_enumeration(hwnd: HWND, current_process_id: u32) -> boolreturn false;}- if let Ok(exe_path) = pid_to_exe_path(process_id)- && is_ignored_executable(&exe_path)+ if let Some(exe_path) = &cache.process(process_id).path+ && is_ignored_executable(exe_path){return false;}@@ -1367,7 +1396,7 @@ unsafe fn pid_to_exe_path(pid: u32) -> Result<PathBuf, windows::core::Error> {QueryFullProcessImageNameW(handle,PROCESS_NAME_FORMAT::default(),- windows::core::PWSTR(lpexename.as_mut_ptr()),+ PWSTR(lpexename.as_mut_ptr()),&mut lpdwsize,)};diff --git a/crates/scap-targets/tests/windows_targets.rs b/crates/scap-targets/tests/windows_targets.rsindex 79f260cba..1362d91be 100644--- a/crates/scap-targets/tests/windows_targets.rs+++ b/crates/scap-targets/tests/windows_targets.rs@@ -1,6 +1,6 @@#![cfg(target_os = "windows")]-use scap_targets::{Window, WindowId};+use scap_targets::{Window, WindowId, platform::WindowListCache};use std::{io::{BufRead, BufReader, Write},process::{Child, Command, Stdio},@@ -9,12 +9,13 @@ use std::{};use windows::{Win32::{- Foundation::HWND,+ Foundation::{HWND, LPARAM, WPARAM},UI::{HiDpi::{PROCESS_PER_MONITOR_DPI_AWARE, SetProcessDpiAwareness},WindowsAndMessaging::{- CreateWindowExW, DestroyWindow, DispatchMessageW, MSG, PM_REMOVE, PeekMessageW,- SW_MINIMIZE, ShowWindow, TranslateMessage, WINDOW_EX_STYLE, WINDOW_STYLE, WS_CHILD,+ CreateWindowExW, DestroyWindow, DispatchMessageW, IDI_APPLICATION, IDI_WARNING,+ LoadIconW, MSG, PM_REMOVE, PeekMessageW, SW_MINIMIZE, SendMessageW, ShowWindow,+ TranslateMessage, WINDOW_EX_STYLE, WINDOW_STYLE, WM_SETICON, WS_CHILD,WS_EX_TOOLWINDOW, WS_OVERLAPPEDWINDOW, WS_POPUP, WS_VISIBLE,},},@@ -76,6 +77,17 @@ fn window_fixture_process() {let normal = TestWindow::new(WS_OVERLAPPEDWINDOW | WS_VISIBLE, WINDOW_EX_STYLE(0), None);let popup = TestWindow::new(WS_POPUP | WS_VISIBLE, WINDOW_EX_STYLE(0), Some(normal.0));+ for (window, resource) in [(&normal, IDI_APPLICATION), (&popup, IDI_WARNING)] {+ let icon = unsafe { LoadIconW(None, resource) }.expect("load fixture icon");+ unsafe {+ SendMessageW(+ window.0,+ WM_SETICON,+ Some(WPARAM(0)),+ Some(LPARAM(icon.0 as isize)),+ )+ };+ }let hidden = TestWindow::new(WS_OVERLAPPEDWINDOW, WINDOW_EX_STYLE(0), None);let child = TestWindow::new(WS_CHILD | WS_VISIBLE, WINDOW_EX_STYLE(0), Some(normal.0));let tool = TestWindow::new(WS_OVERLAPPEDWINDOW | WS_VISIBLE, WS_EX_TOOLWINDOW, None);@@ -141,6 +153,8 @@ fn discovers_foreign_top_level_windows_and_preserves_target_filters() {assert_eq!(ids.len(), 6);let own = TestWindow::new(WS_OVERLAPPEDWINDOW | WS_VISIBLE, WINDOW_EX_STYLE(0), None);let windows = Window::list();+ let mut cache = WindowListCache::default();+ let cached_windows = cache.list();assert!(!windows.iter().any(|window| window.id() == own.id()));for id in &ids[..2] {@@ -152,6 +166,14 @@ fn discovers_foreign_top_level_windows_and_preserves_target_filters() {assert!(window.raw_handle().is_on_screen());assert!(window.name().is_some_and(|name| !name.is_empty()));assert!(window.owner_name().is_some());+ assert!(cached_windows.iter().any(|cached| cached.id() == *id));+ assert_eq!(cache.is_valid(window), window.raw_handle().is_valid());+ assert_eq!(+ cache.is_on_screen(window),+ window.raw_handle().is_on_screen()+ );+ assert_eq!(cache.owner_name(window), window.owner_name());+ assert_eq!(cache.app_icon(window), window.app_icon());assert!(window.display().is_some());assert!(window.display_relative_logical_bounds().is_some());assert_eq!(@@ -178,6 +200,22 @@ fn discovers_foreign_top_level_windows_and_preserves_target_filters() {"ineligible window {id} must stay excluded");}+ let cached_eligible: Vec<_> = cached_windows+ .iter()+ .filter(|window| cache.is_valid(window) && cache.is_on_screen(window))+ .map(Window::id)+ .collect();+ for id in &ids {+ assert_eq!(cached_eligible.contains(id), eligible.contains(id));+ }+ let icons: Vec<_> = ids[..2]+ .iter()+ .map(|id| {+ let window = windows.iter().find(|window| window.id() == *id).unwrap();+ cache.app_icon(window).expect("fixture window icon")+ })+ .collect();+ assert_ne!(icons[0], icons[1]);fixture.0.stdin