refact: reduce try_get_displays() on login (#9333)
* refact: reduce try_get_displays() on login Signed-off-by: fufesou <linlong1266@gmail.com> * Function rename Signed-off-by: fufesou <linlong1266@gmail.com> --------- Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
		
							parent
							
								
									cacca7295c
								
							
						
					
					
						commit
						c358399eca
					
				| @ -1279,29 +1279,9 @@ impl Connection { | ||||
|                 self.send(msg_out).await; | ||||
|             } | ||||
| 
 | ||||
|             #[cfg(not(any(target_os = "android", target_os = "ios")))] | ||||
|             { | ||||
|                 #[cfg(not(windows))] | ||||
|                 let displays = display_service::try_get_displays(); | ||||
|                 #[cfg(windows)] | ||||
|                 let displays = display_service::try_get_displays_add_amyuni_headless(); | ||||
|                 pi.resolutions = Some(SupportedResolutions { | ||||
|                     resolutions: displays | ||||
|                         .map(|displays| { | ||||
|                             displays | ||||
|                                 .get(self.display_idx) | ||||
|                                 .map(|d| crate::platform::resolutions(&d.name())) | ||||
|                                 .unwrap_or(vec![]) | ||||
|                         }) | ||||
|                         .unwrap_or(vec![]), | ||||
|                     ..Default::default() | ||||
|                 }) | ||||
|                 .into(); | ||||
|             } | ||||
| 
 | ||||
|             try_activate_screen(); | ||||
| 
 | ||||
|             match super::display_service::update_get_sync_displays().await { | ||||
|             match super::display_service::update_get_sync_displays_on_login().await { | ||||
|                 Err(err) => { | ||||
|                     res.set_error(format!("{}", err)); | ||||
|                 } | ||||
| @ -1314,6 +1294,18 @@ impl Connection { | ||||
|                     } | ||||
|                     pi.displays = displays; | ||||
|                     pi.current_display = self.display_idx as _; | ||||
|                     #[cfg(not(any(target_os = "android", target_os = "ios")))] | ||||
|                     { | ||||
|                         pi.resolutions = Some(SupportedResolutions { | ||||
|                             resolutions: pi | ||||
|                                 .displays | ||||
|                                 .get(self.display_idx) | ||||
|                                 .map(|d| crate::platform::resolutions(&d.name)) | ||||
|                                 .unwrap_or(vec![]), | ||||
|                             ..Default::default() | ||||
|                         }) | ||||
|                         .into(); | ||||
|                     } | ||||
|                     res.set_peer_info(pi); | ||||
|                     sub_service = true; | ||||
| 
 | ||||
|  | ||||
| @ -344,14 +344,18 @@ pub fn is_inited_msg() -> Option<Message> { | ||||
|     None | ||||
| } | ||||
| 
 | ||||
| pub async fn update_get_sync_displays() -> ResultType<Vec<DisplayInfo>> { | ||||
| pub async fn update_get_sync_displays_on_login() -> ResultType<Vec<DisplayInfo>> { | ||||
|     #[cfg(target_os = "linux")] | ||||
|     { | ||||
|         if !is_x11() { | ||||
|             return super::wayland::get_displays().await; | ||||
|         } | ||||
|     } | ||||
|     check_update_displays(&try_get_displays()?); | ||||
|     #[cfg(not(windows))] | ||||
|     let displays = display_service::try_get_displays(); | ||||
|     #[cfg(windows)] | ||||
|     let displays = display_service::try_get_displays_add_amyuni_headless(); | ||||
|     check_update_displays(&displays?); | ||||
|     Ok(SYNC_DISPLAYS.lock().unwrap().displays.clone()) | ||||
| } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user