change resolution, macos needs more tests

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2023-05-24 22:50:53 +08:00
parent 0d11a88dce
commit b36a3f70fb
4 changed files with 22 additions and 15 deletions

View File

@@ -44,6 +44,24 @@ pub fn breakdown_callback() {
crate::input_service::release_device_modifiers();
}
#[cfg(not(any(target_os = "android", target_os = "ios")))]
pub fn change_resolution(name: &str, width: usize, height: usize) -> ResultType<()> {
hbb_common::log::warn!("Change resolution of '{}' to ({},{})", name, width, height);
let cur_resolution = current_resolution(name)?;
// For MacOS
// to-do: Make sure the following comparison works.
// For Linux
// Just run "xrandr", dpi may not be taken into consideration.
// For Windows
// dmPelsWidth and dmPelsHeight is the same to width and height
// Because this process is running in dpi awareness mode.
if cur_resolution.width as usize == width && cur_resolution.height as usize == height {
return Ok(());
}
change_resolution_directly(name, width, height)
}
// Android
#[cfg(target_os = "android")]
pub fn get_active_username() -> String {