fix default keyboard mode when changing version
This commit is contained in:
parent
a3769ca8e9
commit
3102a24166
@ -7,6 +7,7 @@ use cpal::{
|
|||||||
use magnum_opus::{Channels::*, Decoder as AudioDecoder};
|
use magnum_opus::{Channels::*, Decoder as AudioDecoder};
|
||||||
use sha2::{Digest, Sha256};
|
use sha2::{Digest, Sha256};
|
||||||
use std::{
|
use std::{
|
||||||
|
str::FromStr,
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
net::SocketAddr,
|
net::SocketAddr,
|
||||||
ops::{Deref, Not},
|
ops::{Deref, Not},
|
||||||
@ -48,7 +49,7 @@ pub mod file_trait;
|
|||||||
pub mod helper;
|
pub mod helper;
|
||||||
pub mod io_loop;
|
pub mod io_loop;
|
||||||
use crate::{
|
use crate::{
|
||||||
common::is_keyboard_mode_supported,
|
common::{self, is_keyboard_mode_supported},
|
||||||
server::video_service::{SCRAP_X11_REF_URL, SCRAP_X11_REQUIRED},
|
server::video_service::{SCRAP_X11_REF_URL, SCRAP_X11_REQUIRED},
|
||||||
};
|
};
|
||||||
pub static SERVER_KEYBOARD_ENABLED: AtomicBool = AtomicBool::new(true);
|
pub static SERVER_KEYBOARD_ENABLED: AtomicBool = AtomicBool::new(true);
|
||||||
@ -1419,6 +1420,13 @@ impl LoginConfigHandler {
|
|||||||
} else {
|
} else {
|
||||||
config.keyboard_mode = KeyboardMode::Legacy.to_string();
|
config.keyboard_mode = KeyboardMode::Legacy.to_string();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
let keyboard_modes =
|
||||||
|
common::get_supported_keyboard_modes(get_version_number(&pi.version));
|
||||||
|
let current_mode = &KeyboardMode::from_str(&config.keyboard_mode).unwrap_or_default();
|
||||||
|
if !keyboard_modes.contains(current_mode) {
|
||||||
|
config.keyboard_mode = KeyboardMode::Legacy.to_string();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
self.conn_id = pi.conn_id;
|
self.conn_id = pi.conn_id;
|
||||||
// no matter if change, for update file time
|
// no matter if change, for update file time
|
||||||
|
@ -698,6 +698,13 @@ pub fn is_keyboard_mode_supported(keyboard_mode: &KeyboardMode, version_number:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_supported_keyboard_modes(version: i64) -> Vec<KeyboardMode> {
|
||||||
|
KeyboardMode::iter()
|
||||||
|
.filter(|&mode| is_keyboard_mode_supported(mode, version))
|
||||||
|
.map(|&mode| mode)
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(not(target_os = "linux"))]
|
#[cfg(not(target_os = "linux"))]
|
||||||
lazy_static::lazy_static! {
|
lazy_static::lazy_static! {
|
||||||
pub static ref IS_X11: Mutex<bool> = Mutex::new(false);
|
pub static ref IS_X11: Mutex<bool> = Mutex::new(false);
|
||||||
|
@ -4,7 +4,7 @@ use crate::client::{
|
|||||||
load_config, send_mouse, start_video_audio_threads, FileManager, Key, LoginConfigHandler,
|
load_config, send_mouse, start_video_audio_threads, FileManager, Key, LoginConfigHandler,
|
||||||
QualityStatus, KEY_MAP,
|
QualityStatus, KEY_MAP,
|
||||||
};
|
};
|
||||||
use crate::common::{is_keyboard_mode_supported, GrabState};
|
use crate::common::{self, is_keyboard_mode_supported, GrabState};
|
||||||
use crate::keyboard;
|
use crate::keyboard;
|
||||||
use crate::{client::Data, client::Interface};
|
use crate::{client::Data, client::Interface};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
@ -204,10 +204,7 @@ impl<T: InvokeUiSession> Session<T> {
|
|||||||
|
|
||||||
pub fn get_supported_keyboard_modes(&self) -> Vec<KeyboardMode> {
|
pub fn get_supported_keyboard_modes(&self) -> Vec<KeyboardMode> {
|
||||||
let version = self.get_peer_version();
|
let version = self.get_peer_version();
|
||||||
KeyboardMode::iter()
|
common::get_supported_keyboard_modes(version)
|
||||||
.filter(|&mode| is_keyboard_mode_supported(mode, version))
|
|
||||||
.map(|&mode| mode)
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn remove_port_forward(&self, port: i32) {
|
pub fn remove_port_forward(&self, port: i32) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user