@@ -316,10 +316,10 @@ impl LinuxAccessibility {
316316
317317 while let Some ( entry) = stack. pop ( ) {
318318 // Check element count limit
319- if let Some ( max) = filter. max_elements {
320- if element_count >= max {
321- continue ;
322- }
319+ if let Some ( max) = filter. max_elements
320+ && element_count >= max
321+ {
322+ continue ;
323323 }
324324
325325 // Allocate temporary ID (will be remapped later)
@@ -360,32 +360,29 @@ impl LinuxAccessibility {
360360 handles_to_insert. push ( ( temp_id, entry. handle . clone ( ) ) ) ;
361361
362362 // Get children if we should recurse
363- let should_recurse = filter. max_depth . map_or ( true , |max| entry. depth < max) ;
364- if should_recurse {
365- if let Ok ( children) = proxy. get_children ( ) . await {
366- // Push children to stack in reverse order so first child is processed first
367- for child_ref in children. into_iter ( ) . rev ( ) {
368- let child_handle = NativeHandle {
369- bus_name : child_ref. name_as_str ( ) . unwrap_or_default ( ) . to_string ( ) ,
370- object_path : child_ref. path_as_str ( ) . to_string ( ) ,
371- } ;
372-
373- if let Ok ( child_proxy) = Self :: create_accessible_proxy (
374- & conn,
375- & child_handle. bus_name ,
376- & child_handle. object_path ,
377- )
378- . await
379- {
380- if let Ok ( child_interfaces) = child_proxy. get_interfaces ( ) . await {
381- stack. push ( StackEntry {
382- handle : child_handle,
383- interfaces : child_interfaces,
384- parent_temp_id : Some ( temp_id) ,
385- depth : entry. depth + 1 ,
386- } ) ;
387- }
388- }
363+ let should_recurse = filter. max_depth . is_none_or ( |max| entry. depth < max) ;
364+ if should_recurse && let Ok ( children) = proxy. get_children ( ) . await {
365+ // Push children to stack in reverse order so first child is processed first
366+ for child_ref in children. into_iter ( ) . rev ( ) {
367+ let child_handle = NativeHandle {
368+ bus_name : child_ref. name_as_str ( ) . unwrap_or_default ( ) . to_string ( ) ,
369+ object_path : child_ref. path_as_str ( ) . to_string ( ) ,
370+ } ;
371+
372+ if let Ok ( child_proxy) = Self :: create_accessible_proxy (
373+ & conn,
374+ & child_handle. bus_name ,
375+ & child_handle. object_path ,
376+ )
377+ . await
378+ && let Ok ( child_interfaces) = child_proxy. get_interfaces ( ) . await
379+ {
380+ stack. push ( StackEntry {
381+ handle : child_handle,
382+ interfaces : child_interfaces,
383+ parent_temp_id : Some ( temp_id) ,
384+ depth : entry. depth + 1 ,
385+ } ) ;
389386 }
390387 }
391388 }
@@ -498,16 +495,16 @@ impl LinuxAccessibility {
498495 let bus_name = child_ref. name_as_str ( ) . unwrap_or_default ( ) . to_string ( ) ;
499496
500497 // Get PID from D-Bus
501- if let Some ( pid) = Self :: get_pid_for_bus_name ( conn, & bus_name) . await {
502- if pid == target_pid {
503- return Some ( (
504- NativeHandle {
505- bus_name ,
506- object_path : child_ref . path_as_str ( ) . to_string ( ) ,
507- } ,
508- pid ,
509- ) ) ;
510- }
498+ if let Some ( pid) = Self :: get_pid_for_bus_name ( conn, & bus_name) . await
499+ && pid == target_pid
500+ {
501+ return Some ( (
502+ NativeHandle {
503+ bus_name ,
504+ object_path : child_ref . path_as_str ( ) . to_string ( ) ,
505+ } ,
506+ pid ,
507+ ) ) ;
511508 }
512509 }
513510
@@ -1047,7 +1044,7 @@ impl AccessibilityReader for LinuxAccessibility {
10471044 help : element. help . clone ( ) ,
10481045 role_description : element. role_description . clone ( ) ,
10491046 identifier : element. identifier . clone ( ) ,
1050- bounds : element. bounds . clone ( ) ,
1047+ bounds : element. bounds ,
10511048 enabled : element. enabled ,
10521049 focused : element. focused ,
10531050 actions : element. actions . clone ( ) ,
@@ -1080,10 +1077,10 @@ impl AccessibilityReader for LinuxAccessibility {
10801077 // Platform adapter methods (merged from LinuxAdapter)
10811078
10821079 fn capture_screen ( & self , pid : Option < u32 > ) -> Result < Screenshot > {
1083- if let Some ( pid) = pid {
1084- if let Ok ( screenshot) = self . capture_window ( pid) {
1085- return Ok ( screenshot ) ;
1086- }
1080+ if let Some ( pid) = pid
1081+ && let Ok ( screenshot) = self . capture_window ( pid)
1082+ {
1083+ return Ok ( screenshot ) ;
10871084 }
10881085 LinuxAccessibility :: capture_screen ( self )
10891086 }
@@ -1278,60 +1275,55 @@ async fn run_linux_event_loop(
12781275 }
12791276
12801277 // Register for focus events if enabled
1281- if config. should_capture ( AccessibilityEventType :: FocusChanged ) {
1282- if let Err ( e) = atspi_conn
1278+ if config. should_capture ( AccessibilityEventType :: FocusChanged )
1279+ && let Err ( e) = atspi_conn
12831280 . register_event :: < atspi:: events:: focus:: FocusEvent > ( )
12841281 . await
1285- {
1286- eprintln ! ( "Warning: Failed to register for focus events: {}" , e) ;
1287- }
1282+ {
1283+ eprintln ! ( "Warning: Failed to register for focus events: {}" , e) ;
12881284 }
12891285
12901286 // Register for object events
1291- if config. should_capture ( AccessibilityEventType :: StructureChanged ) {
1292- if let Err ( e) = atspi_conn
1287+ if config. should_capture ( AccessibilityEventType :: StructureChanged )
1288+ && let Err ( e) = atspi_conn
12931289 . register_event :: < atspi:: events:: object:: ChildrenChangedEvent > ( )
12941290 . await
1295- {
1296- eprintln ! (
1297- "Warning: Failed to register for children changed events: {}" ,
1298- e
1299- ) ;
1300- }
1291+ {
1292+ eprintln ! (
1293+ "Warning: Failed to register for children changed events: {}" ,
1294+ e
1295+ ) ;
13011296 }
13021297
1303- if config. should_capture ( AccessibilityEventType :: ValueChanged ) {
1304- if let Err ( e) = atspi_conn
1298+ if config. should_capture ( AccessibilityEventType :: ValueChanged )
1299+ && let Err ( e) = atspi_conn
13051300 . register_event :: < atspi:: events:: object:: TextChangedEvent > ( )
13061301 . await
1307- {
1308- eprintln ! ( "Warning: Failed to register for text changed events: {}" , e) ;
1309- }
1302+ {
1303+ eprintln ! ( "Warning: Failed to register for text changed events: {}" , e) ;
13101304 }
13111305
13121306 // Register for window events
1313- if config. should_capture ( AccessibilityEventType :: WindowCreated ) {
1314- if let Err ( e) = atspi_conn
1307+ if config. should_capture ( AccessibilityEventType :: WindowCreated )
1308+ && let Err ( e) = atspi_conn
13151309 . register_event :: < atspi:: events:: window:: CreateEvent > ( )
13161310 . await
1317- {
1318- eprintln ! (
1319- "Warning: Failed to register for window create events: {}" ,
1320- e
1321- ) ;
1322- }
1311+ {
1312+ eprintln ! (
1313+ "Warning: Failed to register for window create events: {}" ,
1314+ e
1315+ ) ;
13231316 }
13241317
1325- if config. should_capture ( AccessibilityEventType :: WindowDestroyed ) {
1326- if let Err ( e) = atspi_conn
1318+ if config. should_capture ( AccessibilityEventType :: WindowDestroyed )
1319+ && let Err ( e) = atspi_conn
13271320 . register_event :: < atspi:: events:: window:: DestroyEvent > ( )
13281321 . await
1329- {
1330- eprintln ! (
1331- "Warning: Failed to register for window destroy events: {}" ,
1332- e
1333- ) ;
1334- }
1322+ {
1323+ eprintln ! (
1324+ "Warning: Failed to register for window destroy events: {}" ,
1325+ e
1326+ ) ;
13351327 }
13361328
13371329 // Get the event stream
0 commit comments