Refact/android input changed notify clients (#8494)
* refact: android, input control changed, notify clients Signed-off-by: fufesou <linlong1266@gmail.com> * fix: android init input perm Signed-off-by: fufesou <linlong1266@gmail.com> --------- Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
parent
9c7d4ef1f7
commit
b047730830
@ -177,6 +177,11 @@ class ServerModel with ChangeNotifier {
|
||||
await timerCallback();
|
||||
});
|
||||
}
|
||||
|
||||
// Initial keyboard status is off on mobile
|
||||
if (isMobile) {
|
||||
bind.mainSetOption(key: kOptionEnableKeyboard, value: 'N');
|
||||
}
|
||||
}
|
||||
|
||||
/// 1. check android permission
|
||||
|
@ -786,6 +786,13 @@ pub fn main_show_option(_key: String) -> SyncReturn<bool> {
|
||||
}
|
||||
|
||||
pub fn main_set_option(key: String, value: String) {
|
||||
#[cfg(target_os = "android")]
|
||||
if key.eq(config::keys::OPTION_ENABLE_KEYBOARD) {
|
||||
crate::ui_cm_interface::notify_input_control(config::option2bool(
|
||||
config::keys::OPTION_ENABLE_KEYBOARD,
|
||||
&value,
|
||||
));
|
||||
}
|
||||
if key.eq("custom-rendezvous-server") {
|
||||
set_option(key, value.clone());
|
||||
#[cfg(target_os = "android")]
|
||||
|
@ -189,6 +189,8 @@ pub enum Data {
|
||||
MouseMoveTime(i64),
|
||||
Authorize,
|
||||
Close,
|
||||
#[cfg(target_os = "android")]
|
||||
InputControl(bool),
|
||||
#[cfg(windows)]
|
||||
SAS,
|
||||
UserSid(Option<u32>),
|
||||
|
@ -400,6 +400,9 @@ impl Connection {
|
||||
}
|
||||
#[cfg(target_os = "android")]
|
||||
start_channel(rx_to_cm, tx_from_cm);
|
||||
#[cfg(target_os = "android")]
|
||||
conn.send_permission(Permission::Keyboard, conn.keyboard).await;
|
||||
#[cfg(not(target_os = "android"))]
|
||||
if !conn.keyboard {
|
||||
conn.send_permission(Permission::Keyboard, false).await;
|
||||
}
|
||||
@ -457,6 +460,11 @@ impl Connection {
|
||||
conn.on_close("connection manager", true).await;
|
||||
break;
|
||||
}
|
||||
#[cfg(target_os = "android")]
|
||||
ipc::Data::InputControl(v) => {
|
||||
conn.keyboard = v;
|
||||
conn.send_permission(Permission::Keyboard, v).await;
|
||||
}
|
||||
ipc::Data::CmErr(e) => {
|
||||
if e != "expected" {
|
||||
// cm closed before connection
|
||||
|
@ -279,6 +279,15 @@ pub fn close(id: i32) {
|
||||
};
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[cfg(target_os = "android")]
|
||||
pub fn notify_input_control(v: bool) {
|
||||
for (_, mut client) in CLIENTS.write().unwrap().iter_mut() {
|
||||
client.keyboard = v;
|
||||
allow_err!(client.tx.send(Data::InputControl(v)));
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn remove(id: i32) {
|
||||
CLIENTS.write().unwrap().remove(&id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user