fix: privacy mode, windows vd, init resolution (#8992)

Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
fufesou
2024-08-08 15:31:11 +08:00
committed by GitHub
parent 6197832317
commit 049c334db3
3 changed files with 15 additions and 2 deletions

View File

@@ -213,6 +213,8 @@ impl PrivacyModeImpl {
dm.u1.s2_mut().dmPosition.x -= new_primary_dm.u1.s2().dmPosition.x;
dm.u1.s2_mut().dmPosition.y -= new_primary_dm.u1.s2().dmPosition.y;
dm.dmFields |= DM_POSITION;
dm.dmPelsWidth = 1920;
dm.dmPelsHeight = 1080;
let rc = ChangeDisplaySettingsExW(
dd.DeviceName.as_ptr(),
&mut dm,
@@ -220,7 +222,6 @@ impl PrivacyModeImpl {
flags,
NULL,
);
if rc != DISP_CHANGE_SUCCESSFUL {
log::error!(
"Failed ChangeDisplaySettingsEx, device name: {:?}, flags: {}, ret: {}",
@@ -230,6 +231,15 @@ impl PrivacyModeImpl {
);
bail!("Failed ChangeDisplaySettingsEx, ret: {}", rc);
}
// If we want to set dpi, the following references may be helpful.
// And setting dpi should be called after changing the display settings.
// https://stackoverflow.com/questions/35233182/how-can-i-change-windows-10-display-scaling-programmatically-using-c-sharp
// https://github.com/lihas/windows-DPI-scaling-sample/blob/master/DPIHelper/DpiHelper.cpp
//
// But the official API does not provide a way to get/set dpi.
// https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ne-wingdi-displayconfig_device_info_type
// https://github.com/lihas/windows-DPI-scaling-sample/blob/738ac18b7a7ce2d8fdc157eb825de9cb5eee0448/DPIHelper/DpiHelper.h#L37
}
}