fix: crash, drop tokio RunTime in async context (#9091)
* fix: crash, drop tokio RunTime in async context Signed-off-by: fufesou <linlong1266@gmail.com> * chore Signed-off-by: fufesou <linlong1266@gmail.com> --------- Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
parent
ed18e3c786
commit
f31e60af5b
@ -481,7 +481,7 @@ pub async fn start_server(is_server: bool) {
|
|||||||
});
|
});
|
||||||
input_service::fix_key_down_timeout_loop();
|
input_service::fix_key_down_timeout_loop();
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
if crate::platform::current_is_wayland() {
|
if input_service::wayland_use_uinput() {
|
||||||
allow_err!(input_service::setup_uinput(0, 1920, 0, 1080).await);
|
allow_err!(input_service::setup_uinput(0, 1920, 0, 1080).await);
|
||||||
}
|
}
|
||||||
#[cfg(any(target_os = "macos", target_os = "linux"))]
|
#[cfg(any(target_os = "macos", target_os = "linux"))]
|
||||||
|
@ -1320,7 +1320,7 @@ impl Connection {
|
|||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
{
|
{
|
||||||
// use rdp_input when uinput is not available in wayland. Ex: flatpak
|
// use rdp_input when uinput is not available in wayland. Ex: flatpak
|
||||||
if !is_x11() && !crate::is_server() {
|
if input_service::wayland_use_rdp_input() {
|
||||||
let _ = setup_rdp_input().await;
|
let _ = setup_rdp_input().await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1636,6 +1636,18 @@ async fn send_sas() -> ResultType<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
pub fn wayland_use_uinput() -> bool {
|
||||||
|
!crate::platform::is_x11() && crate::is_server()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
pub fn wayland_use_rdp_input() -> bool {
|
||||||
|
!crate::platform::is_x11() && !crate::is_server()
|
||||||
|
}
|
||||||
|
|
||||||
lazy_static::lazy_static! {
|
lazy_static::lazy_static! {
|
||||||
static ref MODIFIER_MAP: HashMap<i32, Key> = [
|
static ref MODIFIER_MAP: HashMap<i32, Key> = [
|
||||||
(ControlKey::Alt, Key::Alt),
|
(ControlKey::Alt, Key::Alt),
|
||||||
|
@ -135,6 +135,7 @@ pub(super) async fn check_init() -> ResultType<()> {
|
|||||||
let mut maxx = 0;
|
let mut maxx = 0;
|
||||||
let mut miny = 0;
|
let mut miny = 0;
|
||||||
let mut maxy = 0;
|
let mut maxy = 0;
|
||||||
|
let use_uinput = crate::input_service::wayland_use_uinput();
|
||||||
|
|
||||||
if *CAP_DISPLAY_INFO.read().unwrap() == 0 {
|
if *CAP_DISPLAY_INFO.read().unwrap() == 0 {
|
||||||
let mut lock = CAP_DISPLAY_INFO.write().unwrap();
|
let mut lock = CAP_DISPLAY_INFO.write().unwrap();
|
||||||
@ -167,28 +168,29 @@ pub(super) async fn check_init() -> ResultType<()> {
|
|||||||
num_cpus::get(),
|
num_cpus::get(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let (max_width, max_height) = match get_max_desktop_resolution() {
|
if use_uinput {
|
||||||
Some(result) if !result.is_empty() => {
|
let (max_width, max_height) = match get_max_desktop_resolution() {
|
||||||
let resolution: Vec<&str> = result.split(" ").collect();
|
Some(result) if !result.is_empty() => {
|
||||||
let w: i32 = resolution[0].parse().unwrap_or(origin.0 + width as i32);
|
let resolution: Vec<&str> = result.split(" ").collect();
|
||||||
let h: i32 = resolution[2]
|
let w: i32 = resolution[0].parse().unwrap_or(origin.0 + width as i32);
|
||||||
.trim_end_matches(",")
|
let h: i32 = resolution[2]
|
||||||
.parse()
|
.trim_end_matches(",")
|
||||||
.unwrap_or(origin.1 + height as i32);
|
.parse()
|
||||||
if w < origin.0 + width as i32 || h < origin.1 + height as i32 {
|
.unwrap_or(origin.1 + height as i32);
|
||||||
(origin.0 + width as i32, origin.1 + height as i32)
|
if w < origin.0 + width as i32 || h < origin.1 + height as i32 {
|
||||||
|
(origin.0 + width as i32, origin.1 + height as i32)
|
||||||
|
} else {
|
||||||
|
(w, h)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else{
|
_ => (origin.0 + width as i32, origin.1 + height as i32),
|
||||||
(w, h)
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => (origin.0 + width as i32, origin.1 + height as i32),
|
|
||||||
};
|
|
||||||
|
|
||||||
minx = 0;
|
minx = 0;
|
||||||
maxx = max_width;
|
maxx = max_width;
|
||||||
miny = 0;
|
miny = 0;
|
||||||
maxy = max_height;
|
maxy = max_height;
|
||||||
|
}
|
||||||
|
|
||||||
let capturer = Box::into_raw(Box::new(
|
let capturer = Box::into_raw(Box::new(
|
||||||
Capturer::new(display).with_context(|| "Failed to create capturer")?,
|
Capturer::new(display).with_context(|| "Failed to create capturer")?,
|
||||||
@ -206,15 +208,17 @@ pub(super) async fn check_init() -> ResultType<()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if minx != maxx && miny != maxy {
|
if use_uinput {
|
||||||
log::info!(
|
if minx != maxx && miny != maxy {
|
||||||
"update mouse resolution: ({}, {}), ({}, {})",
|
log::info!(
|
||||||
minx,
|
"update mouse resolution: ({}, {}), ({}, {})",
|
||||||
maxx,
|
minx,
|
||||||
miny,
|
maxx,
|
||||||
maxy
|
miny,
|
||||||
);
|
maxy
|
||||||
allow_err!(input_service::update_mouse_resolution(minx, maxx, miny, maxy).await);
|
);
|
||||||
|
allow_err!(input_service::update_mouse_resolution(minx, maxx, miny, maxy).await);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user