fix: linux, weak network, repeated keys (#10211)
Use `press` as the `click` flag on Linux to avoid repeated keys, like the Legacy mode. Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
@@ -793,12 +793,13 @@ impl Connection {
|
||||
handle_mouse(&msg, id);
|
||||
}
|
||||
MessageInput::Key((mut msg, press)) => {
|
||||
// todo: press and down have similar meanings.
|
||||
if press && msg.mode.enum_value() == Ok(KeyboardMode::Legacy) {
|
||||
// Set the press state to false, use `down` only in `handle_key()`.
|
||||
msg.press = false;
|
||||
if press {
|
||||
msg.down = true;
|
||||
}
|
||||
handle_key(&msg);
|
||||
if press && msg.mode.enum_value() == Ok(KeyboardMode::Legacy) {
|
||||
if press {
|
||||
msg.down = false;
|
||||
handle_key(&msg);
|
||||
}
|
||||
@@ -1965,8 +1966,6 @@ impl Connection {
|
||||
Some(message::Union::KeyEvent(..)) => {}
|
||||
#[cfg(any(target_os = "android"))]
|
||||
Some(message::Union::KeyEvent(mut me)) => {
|
||||
let is_press = (me.press || me.down) && !crate::is_modifier(&me);
|
||||
|
||||
let key = match me.mode.enum_value() {
|
||||
Ok(KeyboardMode::Map) => {
|
||||
Some(crate::keyboard::keycode_to_rdev_key(me.chr()))
|
||||
@@ -1982,6 +1981,9 @@ impl Connection {
|
||||
}
|
||||
.filter(crate::keyboard::is_modifier);
|
||||
|
||||
let is_press =
|
||||
(me.press || me.down) && !(crate::is_modifier(&me) || key.is_some());
|
||||
|
||||
if let Some(key) = key {
|
||||
if is_press {
|
||||
self.pressed_modifiers.insert(key);
|
||||
@@ -2022,14 +2024,6 @@ impl Connection {
|
||||
}
|
||||
// https://github.com/rustdesk/rustdesk/issues/8633
|
||||
MOUSE_MOVE_TIME.store(get_time(), Ordering::SeqCst);
|
||||
// handle all down as press
|
||||
// fix unexpected repeating key on remote linux, seems also fix abnormal alt/shift, which
|
||||
// make sure all key are released
|
||||
let is_press = if cfg!(target_os = "linux") {
|
||||
(me.press || me.down) && !crate::is_modifier(&me)
|
||||
} else {
|
||||
me.press
|
||||
};
|
||||
|
||||
let key = match me.mode.enum_value() {
|
||||
Ok(KeyboardMode::Map) => {
|
||||
@@ -2046,6 +2040,16 @@ impl Connection {
|
||||
}
|
||||
.filter(crate::keyboard::is_modifier);
|
||||
|
||||
// handle all down as press
|
||||
// fix unexpected repeating key on remote linux, seems also fix abnormal alt/shift, which
|
||||
// make sure all key are released
|
||||
// https://github.com/rustdesk/rustdesk/issues/6793
|
||||
let is_press = if cfg!(target_os = "linux") {
|
||||
(me.press || me.down) && !(crate::is_modifier(&me) || key.is_some())
|
||||
} else {
|
||||
me.press
|
||||
};
|
||||
|
||||
if let Some(key) = key {
|
||||
if is_press {
|
||||
self.pressed_modifiers.insert(key);
|
||||
|
||||
Reference in New Issue
Block a user