trivial changes

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou 2023-05-19 21:08:51 +08:00
parent df2de0fd61
commit 88cf61953b

View File

@ -74,17 +74,23 @@ pub fn plug_out_headless() -> bool {
} }
fn get_new_device_name(device_names: &HashSet<String>) -> String { fn get_new_device_name(device_names: &HashSet<String>) -> String {
let device_names_af = windows::get_device_names(); for _ in 0..3 {
let diff_names: Vec<_> = device_names_af.difference(&device_names).collect(); let device_names_af = windows::get_device_names();
if diff_names.len() != 1 { let diff_names: Vec<_> = device_names_af.difference(&device_names).collect();
log::error!( if diff_names.len() == 1 {
"Failed to get diff device names after plugin virtual display : {:?}", return diff_names[0].clone();
&diff_names } else if diff_names.len() > 1 {
); log::error!(
"".to_string() "Failed to get diff device names after plugin virtual display, more than one diff names: {:?}",
} else { &diff_names
diff_names[0].clone() );
return "".to_string();
}
// Sleep is needed here to wait for the virtual display to be ready.
std::thread::sleep(std::time::Duration::from_millis(50));
} }
log::error!("Failed to get diff device names after plugin virtual display",);
"".to_string()
} }
pub fn plug_in_peer_request(modes: Vec<Vec<virtual_display::MonitorMode>>) -> ResultType<Vec<u32>> { pub fn plug_in_peer_request(modes: Vec<Vec<virtual_display::MonitorMode>>) -> ResultType<Vec<u32>> {
@ -214,7 +220,7 @@ mod windows {
{ {
continue; continue;
} }
let mut dm: DEVMODEW = unsafe { std::mem::zeroed() }; let mut dm: DEVMODEW = unsafe { std::mem::zeroed() };
dm.dmSize = std::mem::size_of::<DEVMODEW>() as _; dm.dmSize = std::mem::size_of::<DEVMODEW>() as _;
dm.dmDriverExtra = 0; dm.dmDriverExtra = 0;