refactor: set default keyboard mode
This commit is contained in:
parent
4837d84209
commit
c267fc9d9b
@ -23,7 +23,7 @@ use hbb_common::{
|
||||
Config, PeerConfig, PeerInfoSerde, CONNECT_TIMEOUT, READ_TIMEOUT, RELAY_PORT,
|
||||
RENDEZVOUS_TIMEOUT,
|
||||
},
|
||||
log,
|
||||
get_version_number, log,
|
||||
message_proto::{option_message::BoolOption, *},
|
||||
protobuf::Message as _,
|
||||
rand,
|
||||
@ -47,7 +47,10 @@ pub use super::lang::*;
|
||||
pub mod file_trait;
|
||||
pub mod helper;
|
||||
pub mod io_loop;
|
||||
use crate::server::video_service::{SCRAP_X11_REF_URL, SCRAP_X11_REQUIRED};
|
||||
use crate::{
|
||||
common::is_keyboard_mode_supported,
|
||||
server::video_service::{SCRAP_X11_REF_URL, SCRAP_X11_REQUIRED},
|
||||
};
|
||||
pub static SERVER_KEYBOARD_ENABLED: AtomicBool = AtomicBool::new(true);
|
||||
pub static SERVER_FILE_TRANSFER_ENABLED: AtomicBool = AtomicBool::new(true);
|
||||
pub static SERVER_CLIPBOARD_ENABLED: AtomicBool = AtomicBool::new(true);
|
||||
@ -1410,12 +1413,11 @@ impl LoginConfigHandler {
|
||||
log::debug!("remove password of {}", self.id);
|
||||
}
|
||||
}
|
||||
if config.keyboard_mode == "" {
|
||||
if hbb_common::get_version_number(&pi.version) < hbb_common::get_version_number("1.2.0")
|
||||
{
|
||||
config.keyboard_mode = "legacy".to_string();
|
||||
if config.keyboard_mode.is_empty() {
|
||||
if is_keyboard_mode_supported(&KeyboardMode::Map, get_version_number(&pi.version)) {
|
||||
config.keyboard_mode = KeyboardMode::Map.to_string();
|
||||
} else {
|
||||
config.keyboard_mode = "map".to_string();
|
||||
config.keyboard_mode = KeyboardMode::Legacy.to_string();
|
||||
}
|
||||
}
|
||||
self.conn_id = pi.conn_id;
|
||||
|
@ -689,6 +689,15 @@ pub fn make_privacy_mode_msg(state: back_notification::PrivacyModeState) -> Mess
|
||||
msg_out
|
||||
}
|
||||
|
||||
pub fn is_keyboard_mode_supported(keyboard_mode: &KeyboardMode, version_number: i64) -> bool {
|
||||
match keyboard_mode {
|
||||
KeyboardMode::Legacy => true,
|
||||
KeyboardMode::Map => version_number >= hbb_common::get_version_number("1.2.0"),
|
||||
KeyboardMode::Translate => true,
|
||||
KeyboardMode::Auto => true,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
lazy_static::lazy_static! {
|
||||
pub static ref IS_X11: Mutex<bool> = Mutex::new(false);
|
||||
|
Loading…
x
Reference in New Issue
Block a user