macos, periodically check if current display is changed

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2023-02-25 22:39:12 +08:00
parent f71d4e9e81
commit b8b3e99602
4 changed files with 14 additions and 7 deletions

View File

@@ -577,6 +577,14 @@ fn run(sp: GenericService) -> ResultType<()> {
if last_check_displays.elapsed().as_millis() > 1000 {
last_check_displays = now;
// Capturer on macos does not return Err event the solution is changed.
#[cfg(target_os = "macos")]
if check_display_changed(c.ndisplay, c.current, c.width, c.height) {
log::info!("Displays changed");
*SWITCH.lock().unwrap() = true;
bail!("SWITCH");
}
if let Some(msg_out) = check_displays_changed() {
sp.send(msg_out);
}