privacy_mode_win_magnifier: fix crash when resolution changed
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
5182b96bda
commit
18ba55056f
@ -364,6 +364,17 @@ impl CapturerMag {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let x = GetSystemMetrics(SM_XVIRTUALSCREEN);
|
||||||
|
let y = GetSystemMetrics(SM_YVIRTUALSCREEN);
|
||||||
|
let w = GetSystemMetrics(SM_CXVIRTUALSCREEN);
|
||||||
|
let h = GetSystemMetrics(SM_CYVIRTUALSCREEN);
|
||||||
|
s.rect = RECT {
|
||||||
|
left: x as _,
|
||||||
|
top: y as _,
|
||||||
|
right: (x + w) as _,
|
||||||
|
bottom: (y + h) as _,
|
||||||
|
};
|
||||||
|
|
||||||
// Create the magnifier control.
|
// Create the magnifier control.
|
||||||
s.magnifier_window = CreateWindowExA(
|
s.magnifier_window = CreateWindowExA(
|
||||||
0,
|
0,
|
||||||
@ -487,13 +498,26 @@ impl CapturerMag {
|
|||||||
let y = GetSystemMetrics(SM_YVIRTUALSCREEN);
|
let y = GetSystemMetrics(SM_YVIRTUALSCREEN);
|
||||||
let w = GetSystemMetrics(SM_CXVIRTUALSCREEN);
|
let w = GetSystemMetrics(SM_CXVIRTUALSCREEN);
|
||||||
let h = GetSystemMetrics(SM_CYVIRTUALSCREEN);
|
let h = GetSystemMetrics(SM_CYVIRTUALSCREEN);
|
||||||
|
if !(self.rect.left == x as _
|
||||||
self.rect = RECT {
|
&& self.rect.top == y as _
|
||||||
left: x as _,
|
&& self.rect.right == (x + w) as _
|
||||||
top: y as _,
|
&& self.rect.bottom == (y + h) as _)
|
||||||
right: (x + w) as _,
|
{
|
||||||
bottom: (y + h) as _,
|
return Err(Error::new(
|
||||||
};
|
ErrorKind::Other,
|
||||||
|
format!(
|
||||||
|
"Failed Check screen rect ({}, {}, {} , {}) to ({}, {}, {}, {})",
|
||||||
|
self.rect.left,
|
||||||
|
self.rect.top,
|
||||||
|
self.rect.right,
|
||||||
|
self.rect.bottom,
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
x + w,
|
||||||
|
y + h
|
||||||
|
),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
if FALSE
|
if FALSE
|
||||||
== SetWindowPos(
|
== SetWindowPos(
|
||||||
@ -623,4 +647,4 @@ mod tests {
|
|||||||
capture_mag.frame(&mut data).unwrap();
|
capture_mag.frame(&mut data).unwrap();
|
||||||
println!("capture data len: {}", data.len());
|
println!("capture data len: {}", data.len());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// Specify the Windows subsystem to eliminate console window.
|
// Specify the Windows subsystem to eliminate console window.
|
||||||
// Requires Rust 1.18.
|
// Requires Rust 1.18.
|
||||||
#![windows_subsystem = "windows"]
|
//#![windows_subsystem = "windows"]
|
||||||
|
|
||||||
use hbb_common::log;
|
use hbb_common::log;
|
||||||
use librustdesk::*;
|
use librustdesk::*;
|
||||||
|
@ -269,6 +269,7 @@ fn create_capturer(privacy_mode_id: i32, display: Display) -> ResultType<Box<dyn
|
|||||||
PRIVACY_WINDOW_NAME
|
PRIVACY_WINDOW_NAME
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
log::info!("Create maginifier capture for {}", privacy_mode_id);
|
||||||
c = Some(Box::new(c1));
|
c = Some(Box::new(c1));
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user