mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-12-12 19:17:58 +00:00
@@ -10,6 +10,7 @@ use std::time::{Duration, SystemTime};
|
||||
|
||||
use async_trait::async_trait;
|
||||
use bytes::Bytes;
|
||||
use hbb_common::message_proto::option_message::BoolOption;
|
||||
use rdev::{Event, EventType::*};
|
||||
use uuid::Uuid;
|
||||
|
||||
@@ -374,7 +375,6 @@ impl<T: InvokeUiSession> Session<T> {
|
||||
}
|
||||
|
||||
pub fn swab_modifier_key(&self, msg: &mut KeyEvent) {
|
||||
|
||||
let allow_swap_key = self.get_toggle_option("allow_swap_key".to_string());
|
||||
if allow_swap_key {
|
||||
if let Some(key_event::Union::ControlKey(ck)) = msg.union {
|
||||
@@ -388,19 +388,22 @@ impl<T: InvokeUiSession> Session<T> {
|
||||
};
|
||||
msg.set_control_key(ck);
|
||||
}
|
||||
msg.modifiers = msg.modifiers.iter().map(|ck| {
|
||||
let ck = ck.enum_value_or_default();
|
||||
let ck = match ck {
|
||||
ControlKey::Control => ControlKey::Meta,
|
||||
ControlKey::Meta => ControlKey::Control,
|
||||
ControlKey::RControl => ControlKey::Meta,
|
||||
ControlKey::RWin => ControlKey::Control,
|
||||
_ => ck,
|
||||
};
|
||||
hbb_common::protobuf::EnumOrUnknown::new(ck)
|
||||
}).collect();
|
||||
|
||||
|
||||
msg.modifiers = msg
|
||||
.modifiers
|
||||
.iter()
|
||||
.map(|ck| {
|
||||
let ck = ck.enum_value_or_default();
|
||||
let ck = match ck {
|
||||
ControlKey::Control => ControlKey::Meta,
|
||||
ControlKey::Meta => ControlKey::Control,
|
||||
ControlKey::RControl => ControlKey::Meta,
|
||||
ControlKey::RWin => ControlKey::Control,
|
||||
_ => ck,
|
||||
};
|
||||
hbb_common::protobuf::EnumOrUnknown::new(ck)
|
||||
})
|
||||
.collect();
|
||||
|
||||
let code = msg.chr();
|
||||
if code != 0 {
|
||||
let mut peer = self.peer_platform().to_lowercase();
|
||||
@@ -444,7 +447,6 @@ impl<T: InvokeUiSession> Session<T> {
|
||||
msg.set_chr(key);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pub fn send_key_event(&self, evt: &KeyEvent) {
|
||||
@@ -841,6 +843,37 @@ impl<T: InvokeUiSession> Session<T> {
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
pub fn set_view_only(&self, view_only: bool) {
|
||||
let mut option = OptionMessage::default();
|
||||
let f = |b: bool| {
|
||||
if b {
|
||||
BoolOption::Yes.into()
|
||||
} else {
|
||||
BoolOption::No.into()
|
||||
}
|
||||
};
|
||||
if view_only {
|
||||
option.disable_keyboard = f(true);
|
||||
option.disable_clipboard = f(true);
|
||||
option.show_remote_cursor = f(true);
|
||||
} else {
|
||||
option.disable_keyboard = f(false);
|
||||
option.disable_clipboard = f(self.get_toggle_option("disable-clipboard".to_string()));
|
||||
option.show_remote_cursor = f(self.get_toggle_option("show-remote-cursor".to_string()));
|
||||
}
|
||||
let mut misc = Misc::new();
|
||||
misc.set_option(option);
|
||||
let mut msg = Message::new();
|
||||
msg.set_misc(misc);
|
||||
self.send(Data::Message(msg));
|
||||
if self.get_toggle_option("view-only".to_string()) != view_only {
|
||||
self.lc
|
||||
.write()
|
||||
.unwrap()
|
||||
.toggle_option("view-only".to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait InvokeUiSession: Send + Sync + Clone + 'static + Sized + Default {
|
||||
@@ -1011,21 +1044,25 @@ impl<T: InvokeUiSession> Interface for Session<T> {
|
||||
handle_test_delay(t, peer).await;
|
||||
}
|
||||
}
|
||||
|
||||
fn swap_modifier_mouse(&self, msg : &mut hbb_common::protos::message::MouseEvent) {
|
||||
|
||||
fn swap_modifier_mouse(&self, msg: &mut hbb_common::protos::message::MouseEvent) {
|
||||
let allow_swap_key = self.get_toggle_option("allow_swap_key".to_string());
|
||||
if allow_swap_key {
|
||||
msg.modifiers = msg.modifiers.iter().map(|ck| {
|
||||
let ck = ck.enum_value_or_default();
|
||||
let ck = match ck {
|
||||
ControlKey::Control => ControlKey::Meta,
|
||||
ControlKey::Meta => ControlKey::Control,
|
||||
ControlKey::RControl => ControlKey::Meta,
|
||||
ControlKey::RWin => ControlKey::Control,
|
||||
_ => ck,
|
||||
};
|
||||
hbb_common::protobuf::EnumOrUnknown::new(ck)
|
||||
}).collect();
|
||||
if allow_swap_key {
|
||||
msg.modifiers = msg
|
||||
.modifiers
|
||||
.iter()
|
||||
.map(|ck| {
|
||||
let ck = ck.enum_value_or_default();
|
||||
let ck = match ck {
|
||||
ControlKey::Control => ControlKey::Meta,
|
||||
ControlKey::Meta => ControlKey::Control,
|
||||
ControlKey::RControl => ControlKey::Meta,
|
||||
ControlKey::RWin => ControlKey::Control,
|
||||
_ => ck,
|
||||
};
|
||||
hbb_common::protobuf::EnumOrUnknown::new(ck)
|
||||
})
|
||||
.collect();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user