set map as default keyboard mode

This commit is contained in:
Asura 2022-10-09 19:27:19 -07:00
parent 01875a562c
commit f2a5b77d7a
3 changed files with 17 additions and 6 deletions

2
Cargo.lock generated
View File

@ -4126,7 +4126,7 @@ dependencies = [
[[package]]
name = "rdev"
version = "0.5.0-2"
source = "git+https://github.com/asur4s/rdev#71a2b9e014b5aaeb85d7bb4a5b7562e3a68cc509"
source = "git+https://github.com/asur4s/rdev#22c8a6474065f03ecbddef7f47de0539ff3f5c4f"
dependencies = [
"cocoa",
"core-foundation 0.9.3",

View File

@ -48,7 +48,7 @@ pub use super::lang::*;
pub mod file_trait;
pub mod helper;
pub mod io_loop;
use crate::ui_session_interface::global_save_keyboard_mode;
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);
@ -1294,6 +1294,9 @@ impl LoginConfigHandler {
if !pi.version.is_empty() {
self.version = hbb_common::get_version_number(&pi.version);
}
if hbb_common::get_version_number(&pi.version) < hbb_common::get_version_number("1.2.0") {
global_save_keyboard_mode("legacy".to_owned());
}
self.features = pi.features.clone().into_option();
let serde = PeerInfoSerde {
username: pi.username.clone(),

View File

@ -80,13 +80,11 @@ impl<T: InvokeUiSession> Session<T> {
}
pub fn get_keyboard_mode(&self) -> String {
return std::env::var("KEYBOARD_MODE")
.unwrap_or(String::from("legacy"))
.to_lowercase();
global_get_keyboard_mode()
}
pub fn save_keyboard_mode(&self, value: String) {
std::env::set_var("KEYBOARD_MODE", value);
global_save_keyboard_mode(value);
}
pub fn save_view_style(&mut self, value: String) {
@ -1550,3 +1548,13 @@ async fn send_note(url: String, id: String, conn_id: i32, note: String) {
fn get_hotkey_state(key: RdevKey) -> bool {
*MUTEX_SPECIAL_KEYS.lock().unwrap().get(&key).unwrap()
}
pub fn global_get_keyboard_mode() -> String {
return std::env::var("KEYBOARD_MODE")
.unwrap_or(String::from("map"))
.to_lowercase();
}
pub fn global_save_keyboard_mode(value: String) {
std::env::set_var("KEYBOARD_MODE", value);
}