fix press/release single meta key
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
a1cbd9238c
commit
2c25be346c
@ -2,6 +2,7 @@
|
||||
/// cbindgen:ignore
|
||||
pub mod platform;
|
||||
mod keyboard;
|
||||
pub use keyboard::keycode_to_rdev_key;
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
pub use platform::{get_cursor, get_cursor_data, get_cursor_pos, start_os_service};
|
||||
#[cfg(not(any(target_os = "ios")))]
|
||||
|
@ -1371,6 +1371,35 @@ fn simulate_win2win_hotkey(code: u32, down: bool) {
|
||||
allow_err!(rdev::simulate_code(Some(keycode), None, down));
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||
fn is_meta_key(_evt: &KeyEvent) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
fn is_meta_key(evt: &KeyEvent) -> bool {
|
||||
match evt.mode.unwrap() {
|
||||
KeyboardMode::Map | KeyboardMode::Translate => match &evt.union {
|
||||
Some(key_event::Union::ControlKey(ck)) => {
|
||||
return *ck == ControlKey::Meta.into();
|
||||
}
|
||||
Some(key_event::Union::Chr(code)) => {
|
||||
let key = crate::keycode_to_rdev_key(*code);
|
||||
return key == RdevKey::MetaLeft || key == RdevKey::MetaRight;
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
KeyboardMode::Legacy => match &evt.union {
|
||||
Some(key_event::Union::ControlKey(ck)) => {
|
||||
return *ck == ControlKey::Meta.into();
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
pub fn handle_key_(evt: &KeyEvent) {
|
||||
if EXITING.load(Ordering::SeqCst) {
|
||||
return;
|
||||
@ -1381,8 +1410,8 @@ pub fn handle_key_(evt: &KeyEvent) {
|
||||
Some(LockModesHandler::new(&evt))
|
||||
}
|
||||
_ => {
|
||||
if evt.down {
|
||||
Some(LockModesHandler::new(&evt))
|
||||
if evt.down && !is_meta_key(evt) {
|
||||
Some(LockModesHandler::new(evt))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user