Skip to content

Commit

Permalink
Merge branch 'rustdesk:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangbo8418 authored Nov 19, 2024
2 parents 6634a9b + 4a49fbe commit 0d37f19
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ class MainService : Service() {
stopCapture()
FFI.refreshScreen()
startCapture()
} else {
FFI.refreshScreen()
}
}

Expand Down
11 changes: 6 additions & 5 deletions src/privacy_mode/win_virtual_display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,9 @@ impl PrivacyModeImpl {
}
}

fn set_primary_display(&mut self) -> ResultType<()> {
fn set_primary_display(&mut self) -> ResultType<String> {
let display = &self.virtual_displays[0];
let display_name = std::string::String::from_utf16(&display.name)?;

#[allow(invalid_value)]
let mut new_primary_dm: DEVMODEW = unsafe { std::mem::MaybeUninit::uninit().assume_init() };
Expand Down Expand Up @@ -230,8 +231,6 @@ 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,
Expand Down Expand Up @@ -261,7 +260,7 @@ impl PrivacyModeImpl {
}
}

Ok(())
Ok(display_name)
}

fn disable_physical_displays(&self) -> ResultType<()> {
Expand Down Expand Up @@ -431,9 +430,11 @@ impl PrivacyMode for PrivacyModeImpl {
}

let reg_connectivity_1 = reg_display_settings::read_reg_connectivity()?;
guard.set_primary_display()?;
let primary_display_name = guard.set_primary_display()?;
guard.disable_physical_displays()?;
Self::commit_change_display(CDS_RESET)?;
// Explicitly set the resolution(virtual display) to 1920x1080.
allow_err!(crate::platform::change_resolution(&primary_display_name, 1920, 1080));
let reg_connectivity_2 = reg_display_settings::read_reg_connectivity()?;

if let Some(reg_recovery) =
Expand Down

0 comments on commit 0d37f19

Please sign in to comment.