mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
refactor: keyboard of client
This commit is contained in:
@@ -18,7 +18,7 @@ use hbb_common::{
|
||||
use crate::flutter::{self, SESSIONS};
|
||||
use crate::ui_interface::{self, *};
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
use crate::ui_session_interface::CUR_SESSION;
|
||||
use crate::keyboard::CUR_SESSION;
|
||||
use crate::{
|
||||
client::file_trait::FileManager,
|
||||
flutter::{make_fd_to_json, session_add, session_start_},
|
||||
@@ -225,6 +225,20 @@ pub fn session_set_image_quality(id: String, value: String) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_get_keyboard_mode(id: String) -> Option<String> {
|
||||
if let Some(session) = SESSIONS.read().unwrap().get(&id) {
|
||||
Some(session.get_keyboard_mode())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_set_keyboard_mode(id: String, value: String) {
|
||||
if let Some(session) = SESSIONS.write().unwrap().get_mut(&id) {
|
||||
session.save_keyboard_mode(value);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_get_custom_image_quality(id: String) -> Option<Vec<i32>> {
|
||||
if let Some(session) = SESSIONS.read().unwrap().get(&id) {
|
||||
Some(session.get_custom_image_quality())
|
||||
@@ -271,7 +285,7 @@ pub fn session_handle_flutter_key_event(
|
||||
down_or_up: bool,
|
||||
) {
|
||||
if let Some(session) = SESSIONS.read().unwrap().get(&id) {
|
||||
session.handle_flutter_key_event(&name, keycode, scancode, down_or_up);
|
||||
// session.handle_flutter_key_event(&name, keycode, scancode, down_or_up);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,7 +296,6 @@ pub fn session_enter_or_leave(id: String, enter: bool) {
|
||||
*CUR_SESSION.lock().unwrap() = Some(session.clone());
|
||||
session.enter();
|
||||
} else {
|
||||
*CUR_SESSION.lock().unwrap() = None;
|
||||
session.leave();
|
||||
}
|
||||
}
|
||||
@@ -299,12 +312,14 @@ pub fn session_input_key(
|
||||
command: bool,
|
||||
) {
|
||||
if let Some(session) = SESSIONS.read().unwrap().get(&id) {
|
||||
// #[cfg(any(target_os = "android", target_os = "ios"))]
|
||||
session.input_key(&name, down, press, alt, ctrl, shift, command);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_input_string(id: String, value: String) {
|
||||
if let Some(session) = SESSIONS.read().unwrap().get(&id) {
|
||||
// #[cfg(any(target_os = "android", target_os = "ios"))]
|
||||
session.input_string(&value);
|
||||
}
|
||||
}
|
||||
@@ -329,19 +344,6 @@ pub fn session_get_peer_option(id: String, name: String) -> String {
|
||||
"".to_string()
|
||||
}
|
||||
|
||||
pub fn session_get_keyboard_name(id: String) -> String {
|
||||
if let Some(session) = SESSIONS.read().unwrap().get(&id) {
|
||||
return session.get_keyboard_mode();
|
||||
}
|
||||
"legacy".to_string()
|
||||
}
|
||||
|
||||
pub fn session_set_keyboard_mode(id: String, keyboard_mode: String) {
|
||||
if let Some(session) = SESSIONS.read().unwrap().get(&id) {
|
||||
session.save_keyboard_mode(keyboard_mode);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_input_os_password(id: String, value: String) {
|
||||
if let Some(session) = SESSIONS.read().unwrap().get(&id) {
|
||||
session.input_os_password(value, true);
|
||||
@@ -1083,8 +1085,7 @@ pub fn main_is_installed() -> SyncReturn<bool> {
|
||||
}
|
||||
|
||||
pub fn main_start_grab_keyboard() {
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
crate::ui_session_interface::global_grab_keyboard();
|
||||
crate::keyboard::client::start_grab_loop();
|
||||
}
|
||||
|
||||
pub fn main_is_installed_lower_version() -> SyncReturn<bool> {
|
||||
|
||||
Reference in New Issue
Block a user