Merge branch 'master' into keyboard

This commit is contained in:
rustdesk
2022-12-09 19:51:15 +08:00
16 changed files with 101 additions and 70 deletions

View File

@@ -936,7 +936,7 @@ impl<T: InvokeUiSession> Remote<T> {
self.handle_job_status(d.id, d.file_num, err);
}
Some(file_response::Union::Error(e)) => {
if let Some(job) = fs::get_job(e.id, &mut self.write_jobs) {
if let Some(_job) = fs::get_job(e.id, &mut self.write_jobs) {
fs::remove_job(e.id, &mut self.write_jobs);
}
self.handle_job_status(e.id, e.file_num, Some(e.error));

View File

@@ -78,7 +78,7 @@ pub enum FS {
WriteError {
id: i32,
file_num: i32,
err: String
err: String,
},
WriteOffset {
id: i32,
@@ -544,7 +544,7 @@ async fn check_pid(postfix: &str) {
}
}
}
hbb_common::allow_err!(std::fs::remove_file(&Config::ipc_path(postfix)));
std::fs::remove_file(&Config::ipc_path(postfix)).ok();
}
#[inline]

View File

@@ -246,16 +246,18 @@ pub async fn setup_uinput(minx: i32, maxx: i32, miny: i32, maxy: i32) -> ResultT
pub async fn update_mouse_resolution(minx: i32, maxx: i32, miny: i32, maxy: i32) -> ResultType<()> {
set_uinput_resolution(minx, maxx, miny, maxy).await?;
if let Some(mouse) = ENIGO.lock().unwrap().get_custom_mouse() {
if let Some(mouse) = mouse
.as_mut_any()
.downcast_mut::<super::uinput::client::UInputMouse>()
{
allow_err!(mouse.send_refresh());
} else {
log::error!("failed downcast uinput mouse");
std::thread::spawn(|| {
if let Some(mouse) = ENIGO.lock().unwrap().get_custom_mouse() {
if let Some(mouse) = mouse
.as_mut_any()
.downcast_mut::<super::uinput::client::UInputMouse>()
{
allow_err!(mouse.send_refresh());
} else {
log::error!("failed downcast uinput mouse");
}
}
}
});
Ok(())
}

View File

@@ -4,7 +4,7 @@ use evdev::{
uinput::{VirtualDevice, VirtualDeviceBuilder},
AttributeSet, EventType, InputEvent,
};
use hbb_common::{allow_err, bail, log, tokio, ResultType};
use hbb_common::{allow_err, bail, log, tokio::{self, runtime::Runtime}, ResultType};
static IPC_CONN_TIMEOUT: u64 = 1000;
static IPC_REQUEST_TIMEOUT: u64 = 1000;
@@ -17,24 +17,24 @@ pub mod client {
pub struct UInputKeyboard {
conn: Connection,
rt: Runtime,
}
impl UInputKeyboard {
pub async fn new() -> ResultType<Self> {
let conn = ipc::connect(IPC_CONN_TIMEOUT, IPC_POSTFIX_KEYBOARD).await?;
Ok(Self { conn })
let rt = Runtime::new()?;
Ok(Self { conn, rt })
}
#[tokio::main(flavor = "current_thread")]
async fn send(&mut self, data: Data) -> ResultType<()> {
self.conn.send(&data).await
fn send(&mut self, data: Data) -> ResultType<()> {
self.rt.block_on(self.conn.send(&data))
}
#[tokio::main(flavor = "current_thread")]
async fn send_get_key_state(&mut self, data: Data) -> ResultType<bool> {
self.conn.send(&data).await?;
fn send_get_key_state(&mut self, data: Data) -> ResultType<bool> {
self.rt.block_on(self.conn.send(&data))?;
match self.conn.next_timeout(IPC_REQUEST_TIMEOUT).await {
match self.rt.block_on(self.conn.next_timeout(IPC_REQUEST_TIMEOUT)) {
Ok(Some(Data::KeyboardResponse(ipc::DataKeyboardResponse::GetKeyState(state)))) => {
Ok(state)
}
@@ -101,17 +101,18 @@ pub mod client {
pub struct UInputMouse {
conn: Connection,
rt: Runtime,
}
impl UInputMouse {
pub async fn new() -> ResultType<Self> {
let conn = ipc::connect(IPC_CONN_TIMEOUT, IPC_POSTFIX_MOUSE).await?;
Ok(Self { conn })
let rt = Runtime::new()?;
Ok(Self { conn, rt })
}
#[tokio::main(flavor = "current_thread")]
async fn send(&mut self, data: Data) -> ResultType<()> {
self.conn.send(&data).await
fn send(&mut self, data: Data) -> ResultType<()> {
self.rt.block_on(self.conn.send(&data))
}
pub fn send_refresh(&mut self) -> ResultType<()> {
@@ -586,6 +587,16 @@ pub mod service {
match data {
Data::Mouse(data) => {
if let DataMouse::Refresh = data {
let resolution = RESOLUTION.lock().unwrap();
let rng_x = resolution.0.clone();
let rng_y = resolution.1.clone();
log::info!(
"Refresh uinput mouce with rng_x: ({}, {}), rng_y: ({}, {})",
rng_x.0,
rng_x.1,
rng_y.0,
rng_y.1
);
mouse = match mouce::Mouse::new_uinput(rng_x, rng_y) {
Ok(mouse) => mouse,
Err(e) => {

View File

@@ -21,8 +21,9 @@
use super::{video_qos::VideoQoS, *};
#[cfg(windows)]
use crate::portable_service::client::PORTABLE_SERVICE_RUNNING;
#[cfg(windows)]
use hbb_common::get_version_number;
use hbb_common::{
get_version_number,
tokio::sync::{
mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender},
Mutex as TokioMutex,