fix win, local detect some dead code

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou 2023-01-27 23:45:07 +08:00
parent a529b14f2d
commit bf04a03cd1
3 changed files with 19 additions and 2 deletions

2
Cargo.lock generated
View File

@ -4371,7 +4371,7 @@ dependencies = [
[[package]]
name = "rdev"
version = "0.5.0-2"
source = "git+https://github.com/fufesou/rdev#1be26c7e8ed0d43cebdd8331d467bb61130a2e6e"
source = "git+https://github.com/fufesou/rdev#238c9778da40056e2efda1e4264355bc89fb6358"
dependencies = [
"cocoa",
"core-foundation 0.9.3",

View File

@ -245,8 +245,13 @@ pub fn session_get_keyboard_mode(id: String) -> Option<String> {
}
pub fn session_set_keyboard_mode(id: String, value: String) {
let mut mode_updated = false;
if let Some(session) = SESSIONS.write().unwrap().get_mut(&id) {
session.save_keyboard_mode(value);
mode_updated = true;
}
if mode_updated {
crate::keyboard::update_grab_get_key_name();
}
}
@ -1182,7 +1187,8 @@ pub fn main_update_me() -> SyncReturn<bool> {
}
pub fn set_cur_session_id(id: String) {
super::flutter::set_cur_session_id(id)
super::flutter::set_cur_session_id(id);
crate::keyboard::update_grab_get_key_name();
}
pub fn install_show_run_without_install() -> SyncReturn<bool> {

View File

@ -64,6 +64,8 @@ pub mod client {
match state {
GrabState::Ready => {}
GrabState::Run => {
#[cfg(windows)]
update_grab_get_key_name();
#[cfg(any(target_os = "windows", target_os = "macos"))]
KEYBOARD_HOOKED.swap(true, Ordering::SeqCst);
@ -184,6 +186,15 @@ pub mod client {
}
}
#[cfg(windows)]
pub fn update_grab_get_key_name() {
match get_keyboard_mode_enum() {
KeyboardMode::Map => rdev::set_get_key_name(false),
KeyboardMode::Translate => rdev::set_get_key_name(true),
_ => {}
};
}
pub fn start_grab_loop() {
#[cfg(any(target_os = "windows", target_os = "macos"))]
std::thread::spawn(move || {