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();
|
||||
#[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);
|
||||
}
|
||||
#[cfg(any(target_os = "macos", target_os = "linux"))]
|
||||
|
@ -1320,7 +1320,7 @@ impl Connection {
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
@ -1636,6 +1636,18 @@ async fn send_sas() -> ResultType<()> {
|
||||
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! {
|
||||
static ref MODIFIER_MAP: HashMap<i32, Key> = [
|
||||
(ControlKey::Alt, Key::Alt),
|
||||
|
@ -135,6 +135,7 @@ pub(super) async fn check_init() -> ResultType<()> {
|
||||
let mut maxx = 0;
|
||||
let mut miny = 0;
|
||||
let mut maxy = 0;
|
||||
let use_uinput = crate::input_service::wayland_use_uinput();
|
||||
|
||||
if *CAP_DISPLAY_INFO.read().unwrap() == 0 {
|
||||
let mut lock = CAP_DISPLAY_INFO.write().unwrap();
|
||||
@ -167,28 +168,29 @@ pub(super) async fn check_init() -> ResultType<()> {
|
||||
num_cpus::get(),
|
||||
);
|
||||
|
||||
let (max_width, max_height) = match get_max_desktop_resolution() {
|
||||
Some(result) if !result.is_empty() => {
|
||||
let resolution: Vec<&str> = result.split(" ").collect();
|
||||
let w: i32 = resolution[0].parse().unwrap_or(origin.0 + width as i32);
|
||||
let h: i32 = resolution[2]
|
||||
.trim_end_matches(",")
|
||||
.parse()
|
||||
.unwrap_or(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)
|
||||
if use_uinput {
|
||||
let (max_width, max_height) = match get_max_desktop_resolution() {
|
||||
Some(result) if !result.is_empty() => {
|
||||
let resolution: Vec<&str> = result.split(" ").collect();
|
||||
let w: i32 = resolution[0].parse().unwrap_or(origin.0 + width as i32);
|
||||
let h: i32 = resolution[2]
|
||||
.trim_end_matches(",")
|
||||
.parse()
|
||||
.unwrap_or(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{
|
||||
(w, h)
|
||||
}
|
||||
}
|
||||
_ => (origin.0 + width as i32, origin.1 + height as i32),
|
||||
};
|
||||
_ => (origin.0 + width as i32, origin.1 + height as i32),
|
||||
};
|
||||
|
||||
minx = 0;
|
||||
maxx = max_width;
|
||||
miny = 0;
|
||||
maxy = max_height;
|
||||
minx = 0;
|
||||
maxx = max_width;
|
||||
miny = 0;
|
||||
maxy = max_height;
|
||||
}
|
||||
|
||||
let capturer = Box::into_raw(Box::new(
|
||||
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 {
|
||||
log::info!(
|
||||
"update mouse resolution: ({}, {}), ({}, {})",
|
||||
minx,
|
||||
maxx,
|
||||
miny,
|
||||
maxy
|
||||
);
|
||||
allow_err!(input_service::update_mouse_resolution(minx, maxx, miny, maxy).await);
|
||||
if use_uinput {
|
||||
if minx != maxx && miny != maxy {
|
||||
log::info!(
|
||||
"update mouse resolution: ({}, {}), ({}, {})",
|
||||
minx,
|
||||
maxx,
|
||||
miny,
|
||||
maxy
|
||||
);
|
||||
allow_err!(input_service::update_mouse_resolution(minx, maxx, miny, maxy).await);
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
Loading…
x
Reference in New Issue
Block a user