fix rdp session ctrl+alt+delete (#7258)

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages
2024-02-26 13:22:21 +08:00
committed by GitHub
parent ddbd4e79a2
commit 1bc11a207a
3 changed files with 23 additions and 5 deletions

View File

@@ -1,3 +1,5 @@
#[cfg(target_os = "linux")]
use super::rdp_input::client::{RdpInputKeyboard, RdpInputMouse};
use super::*;
#[cfg(target_os = "macos")]
use crate::common::is_server;
@@ -5,8 +7,6 @@ use crate::input::*;
#[cfg(target_os = "macos")]
use dispatch::Queue;
use enigo::{Enigo, Key, KeyboardControllable, MouseButton, MouseControllable};
#[cfg(target_os = "linux")]
use super::rdp_input::client::{RdpInputKeyboard, RdpInputMouse};
use hbb_common::{
get_time,
message_proto::{pointer_device_event::Union::TouchEvent, touch_event::Union::ScaleUpdate},
@@ -1316,6 +1316,7 @@ fn is_function_key(ck: &EnumOrUnknown<ControlKey>) -> bool {
let mut res = false;
if ck.value() == ControlKey::CtrlAltDel.value() {
// have to spawn new thread because send_sas is tokio_main, the caller can not be tokio_main.
#[cfg(windows)]
std::thread::spawn(|| {
allow_err!(send_sas());
});
@@ -1564,10 +1565,15 @@ async fn lock_screen_2() {
lock_screen().await;
}
#[cfg(windows)]
#[tokio::main(flavor = "current_thread")]
async fn send_sas() -> ResultType<()> {
let mut stream = crate::ipc::connect(1000, crate::POSTFIX_SERVICE).await?;
timeout(1000, stream.send(&crate::ipc::Data::SAS)).await??;
if crate::platform::is_physical_console_session().unwrap_or(true) {
let mut stream = crate::ipc::connect(1000, crate::POSTFIX_SERVICE).await?;
timeout(1000, stream.send(&crate::ipc::Data::SAS)).await??;
} else {
crate::platform::send_sas();
};
Ok(())
}