@@ -70,13 +70,19 @@ pub struct MonitorInfoProvider {
7070 cache : Arc < RwLock < MonitorCache > > ,
7171}
7272
73- impl MonitorInfoProvider {
74- /// Creates a new MonitorInfoProvider instance
75- pub fn new ( ) -> Self {
73+ impl Default for MonitorInfoProvider {
74+ fn default ( ) -> Self {
7675 Self {
7776 cache : Arc :: new ( RwLock :: new ( MonitorCache :: new ( ) ) ) ,
7877 }
7978 }
79+ }
80+
81+ impl MonitorInfoProvider {
82+ /// Creates a new MonitorInfoProvider instance
83+ pub fn new ( ) -> Self {
84+ Default :: default ( )
85+ }
8086
8187 /// Gets all available monitors with caching
8288 pub async fn get_monitors ( & self ) -> DwallResult < HashMap < String , Monitor > > {
@@ -121,7 +127,7 @@ impl MonitorInfoProvider {
121127 }
122128
123129 // Check if any monitor IDs changed
124- for ( id , _ ) in & current_monitors {
130+ for id in current_monitors. keys ( ) {
125131 if !cached_monitors. contains_key ( id) {
126132 return Ok ( true ) ;
127133 }
@@ -304,9 +310,11 @@ impl MonitorManager {
304310fn query_monitor_info ( ) -> DwallResult < HashMap < String , Monitor > > {
305311 debug ! ( "Querying monitor information from system" ) ;
306312 let mut monitors = HashMap :: new ( ) ;
307- let mut index = 0 ;
308313
309- for display_path in display_config:: query_display_paths ( ) ?. into_iter ( ) {
314+ for ( index, display_path) in display_config:: query_display_paths ( ) ?
315+ . into_iter ( )
316+ . enumerate ( )
317+ {
310318 let target_info =
311319 display_config:: query_target_name ( display_path. adapter_id , display_path. target_id ) ?;
312320 let device_path = target_info. monitorDevicePath . to_string ( ) ;
@@ -333,11 +341,9 @@ fn query_monitor_info() -> DwallResult<HashMap<String, Monitor>> {
333341 id : device_path. clone ( ) ,
334342 device_path,
335343 friendly_name,
336- index : Some ( index) ,
344+ index : Some ( index as u32 ) ,
337345 } ,
338346 ) ;
339-
340- index += 1 ;
341347 }
342348
343349 info ! ( "Found {} monitors in total" , monitors. len( ) ) ;
0 commit comments