fix lock screen for mac and linux
This commit is contained in:
parent
6bc0c3ce98
commit
f42a77ad22
@ -1071,8 +1071,7 @@ impl Connection {
|
|||||||
}
|
}
|
||||||
log::info!("#{} Connection closed: {}", self.inner.id(), reason);
|
log::info!("#{} Connection closed: {}", self.inner.id(), reason);
|
||||||
if lock && self.lock_after_session_end && self.keyboard {
|
if lock && self.lock_after_session_end && self.keyboard {
|
||||||
crate::platform::lock_screen();
|
lock_screen();
|
||||||
super::video_service::switch_to_primary();
|
|
||||||
}
|
}
|
||||||
self.tx_to_cm.send(ipc::Data::Close).ok();
|
self.tx_to_cm.send(ipc::Data::Close).ok();
|
||||||
self.port_forward_socket.take();
|
self.port_forward_socket.take();
|
||||||
|
@ -439,6 +439,39 @@ pub fn is_enter(evt: &KeyEvent) -> bool {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn lock_screen() {
|
||||||
|
cfg_if::cfg_if! {
|
||||||
|
if #[cfg(target_os = "linux")] {
|
||||||
|
// xdg_screensaver lock not work on Linux from our service somehow
|
||||||
|
// loginctl lock-session also not work, they both work run rustdesk from cmd
|
||||||
|
std::thread::spawn(|| {
|
||||||
|
let mut key_event = KeyEvent::new();
|
||||||
|
key_event.down = true;
|
||||||
|
key_event.set_chr('l' as _);
|
||||||
|
key_event.modifiers.push(ControlKey::Meta.into());
|
||||||
|
handle_key(&key_event);
|
||||||
|
key_event.down = false;
|
||||||
|
handle_key(&key_event);
|
||||||
|
});
|
||||||
|
} else if #[cfg(target_os = "macos")] {
|
||||||
|
// CGSession -suspend not real lock screen, it is user switch
|
||||||
|
std::thread::spawn(|| {
|
||||||
|
let mut key_event = KeyEvent::new();
|
||||||
|
key_event.down = true;
|
||||||
|
key_event.set_chr('q' as _);
|
||||||
|
key_event.modifiers.push(ControlKey::Meta.into());
|
||||||
|
key_event.modifiers.push(ControlKey::Control.into());
|
||||||
|
handle_key(&key_event);
|
||||||
|
key_event.down = false;
|
||||||
|
handle_key(&key_event);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
crate::platform::lock_screen();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super::video_service::switch_to_primary();
|
||||||
|
}
|
||||||
|
|
||||||
lazy_static::lazy_static! {
|
lazy_static::lazy_static! {
|
||||||
static ref KEY_MAP: HashMap<i32, Key> =
|
static ref KEY_MAP: HashMap<i32, Key> =
|
||||||
[
|
[
|
||||||
@ -646,8 +679,7 @@ fn handle_key_(evt: &KeyEvent) {
|
|||||||
allow_err!(send_sas());
|
allow_err!(send_sas());
|
||||||
});
|
});
|
||||||
} else if ck.value() == ControlKey::LockScreen.value() {
|
} else if ck.value() == ControlKey::LockScreen.value() {
|
||||||
crate::platform::lock_screen();
|
lock_screen();
|
||||||
super::video_service::switch_to_primary();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(key_event::Union::chr(chr)) => {
|
Some(key_event::Union::chr(chr)) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user