fix: macos, crash, key input. --server also has UI. (#7878)

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou 2024-04-30 22:53:42 +08:00 committed by GitHub
parent 28bf73cd5a
commit 003b9e48e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1086,20 +1086,24 @@ pub async fn lock_screen() {
}
}
#[inline]
#[cfg(target_os = "linux")]
pub fn handle_key(evt: &KeyEvent) {
#[cfg(target_os = "macos")]
if !is_server() {
// having GUI, run main GUI thread, otherwise crash
let evt = evt.clone();
QUEUE.exec_async(move || handle_key_(&evt));
key_sleep();
return;
}
#[cfg(windows)]
crate::portable_service::client::handle_key(evt);
#[cfg(not(windows))]
handle_key_(evt);
#[cfg(target_os = "macos")]
}
#[inline]
#[cfg(target_os = "windows")]
pub fn handle_key(evt: &KeyEvent) {
crate::portable_service::client::handle_key(evt);
}
#[inline]
#[cfg(target_os = "macos")]
pub fn handle_key(evt: &KeyEvent) {
// having GUI, run main GUI thread, otherwise crash
let evt = evt.clone();
QUEUE.exec_async(move || handle_key_(&evt));
key_sleep();
}