fix: Function "LockScreen" on macOS since "ignore_flags" in enigo is introduced. (#9757)
1. LockScreen after connection is established. 2. LockScreen after "Map mode" or "Translate mode" keys are sent. Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
parent
40e8f0d307
commit
c565849062
@ -456,13 +456,22 @@ static RECORD_CURSOR_POS_RUNNING: AtomicBool = AtomicBool::new(false);
|
||||
// https://github.com/rustdesk/rustdesk/issues/9729
|
||||
// We need to do some special handling for macOS when using the legacy mode.
|
||||
#[cfg(target_os = "macos")]
|
||||
static LAST_KEY_LEGACY_MODE: AtomicBool = AtomicBool::new(false);
|
||||
// We use enigo to simulate mouse events. Only the legacy mode uses the key flags.
|
||||
static LAST_KEY_LEGACY_MODE: AtomicBool = AtomicBool::new(true);
|
||||
// We use enigo to
|
||||
// 1. Simulate mouse events
|
||||
// 2. Simulate the legacy mode key events
|
||||
// 3. Simulate the functioin key events, like LockScreen
|
||||
#[inline]
|
||||
#[cfg(target_os = "macos")]
|
||||
fn enigo_ignore_flags() -> bool {
|
||||
!LAST_KEY_LEGACY_MODE.load(Ordering::SeqCst)
|
||||
}
|
||||
#[inline]
|
||||
#[cfg(target_os = "macos")]
|
||||
fn set_last_legacy_mode(v: bool) {
|
||||
LAST_KEY_LEGACY_MODE.store(v, Ordering::SeqCst);
|
||||
ENIGO.lock().unwrap().set_ignore_flags(!v);
|
||||
}
|
||||
|
||||
pub fn try_start_record_cursor_pos() -> Option<thread::JoinHandle<()>> {
|
||||
if RECORD_CURSOR_POS_RUNNING.load(Ordering::SeqCst) {
|
||||
@ -1698,17 +1707,19 @@ pub fn handle_key_(evt: &KeyEvent) {
|
||||
match evt.mode.enum_value() {
|
||||
Ok(KeyboardMode::Map) => {
|
||||
#[cfg(target_os = "macos")]
|
||||
LAST_KEY_LEGACY_MODE.store(false, Ordering::SeqCst);
|
||||
set_last_legacy_mode(false);
|
||||
map_keyboard_mode(evt);
|
||||
}
|
||||
Ok(KeyboardMode::Translate) => {
|
||||
#[cfg(target_os = "macos")]
|
||||
LAST_KEY_LEGACY_MODE.store(false, Ordering::SeqCst);
|
||||
set_last_legacy_mode(false);
|
||||
translate_keyboard_mode(evt);
|
||||
}
|
||||
_ => {
|
||||
// All key down events are started from here,
|
||||
// so we can reset the flag of last legacy mode here.
|
||||
#[cfg(target_os = "macos")]
|
||||
LAST_KEY_LEGACY_MODE.store(true, Ordering::SeqCst);
|
||||
set_last_legacy_mode(true);
|
||||
legacy_keyboard_mode(evt);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user