@@ -235,37 +235,29 @@ pub fn list_windows(
235235 owner_hwnds. push ( get_owner_window ( hwnd) )
236236 }
237237 for ( hwnd, title) in valid_hwnds. into_iter ( ) {
238- let mut rs_module_path = "" . to_string ( ) ;
239- if let Some ( module_path ) = get_module_path ( get_window_pid ( hwnd) ) {
240- rs_module_path = module_path ;
238+ let mut module_path = "" . to_string ( ) ;
239+ if let Some ( v ) = get_module_path ( get_window_pid ( hwnd) ) {
240+ module_path = v ;
241241 }
242- if !rs_module_path. is_empty ( )
243- && rs_module_path != "C:\\ Windows\\ System32\\ ApplicationFrameHost.exe"
244- {
245- result
246- . entry ( rs_module_path)
247- . or_default ( )
248- . push ( ( hwnd, title) ) ;
249- continue ;
250- }
251- if let Some ( ( i, _) ) = owner_hwnds. iter ( ) . enumerate ( ) . find ( |( _, v) | * * v == hwnd) {
252- if let Some ( module_path) = get_module_path ( get_window_pid ( hwnds[ i] ) ) {
253- rs_module_path = module_path;
242+ if !is_valid_module_path ( & module_path) {
243+ if let Some ( ( i, _) ) = owner_hwnds. iter ( ) . enumerate ( ) . find ( |( _, v) | * * v == hwnd) {
244+ if let Some ( v) = get_module_path ( get_window_pid ( hwnds[ i] ) ) {
245+ module_path = v;
246+ }
254247 }
255248 }
256- if !rs_module_path. is_empty ( )
257- && rs_module_path != "C:\\ Windows\\ System32\\ ApplicationFrameHost.exe"
258- {
259- result
260- . entry ( rs_module_path)
261- . or_default ( )
262- . push ( ( hwnd, title) ) ;
249+ if is_valid_module_path ( & module_path) {
250+ result. entry ( module_path) . or_default ( ) . push ( ( hwnd, title) ) ;
263251 }
264252 }
265253 debug ! ( "list windows {:?}" , result) ;
266254 Ok ( result)
267255}
268256
257+ fn is_valid_module_path ( module_path : & str ) -> bool {
258+ !module_path. is_empty ( ) && module_path != "C:\\ Windows\\ System32\\ ApplicationFrameHost.exe"
259+ }
260+
269261extern "system" fn enum_window ( hwnd : HWND , lparam : LPARAM ) -> BOOL {
270262 let windows: & mut Vec < HWND > = unsafe { & mut * ( lparam. 0 as * mut Vec < HWND > ) } ;
271263 windows. push ( hwnd) ;
0 commit comments