Merge pull request #3274 from fufesou/refact/register_breakdown_handler
refact/register breakdown handler
This commit is contained in:
commit
30c795dc4f
18
Cargo.lock
generated
18
Cargo.lock
generated
@ -1566,7 +1566,6 @@ version = "0.0.14"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"core-graphics 0.22.3",
|
"core-graphics 0.22.3",
|
||||||
"hbb_common",
|
"hbb_common",
|
||||||
"libc",
|
|
||||||
"log",
|
"log",
|
||||||
"objc",
|
"objc",
|
||||||
"pkg-config",
|
"pkg-config",
|
||||||
@ -2598,6 +2597,7 @@ name = "hbb_common"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
"backtrace",
|
||||||
"bytes",
|
"bytes",
|
||||||
"chrono",
|
"chrono",
|
||||||
"confy",
|
"confy",
|
||||||
@ -2608,9 +2608,11 @@ dependencies = [
|
|||||||
"futures",
|
"futures",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
|
"libc",
|
||||||
"log",
|
"log",
|
||||||
"mac_address",
|
"mac_address",
|
||||||
"machine-uid",
|
"machine-uid",
|
||||||
|
"osascript",
|
||||||
"protobuf",
|
"protobuf",
|
||||||
"protobuf-codegen",
|
"protobuf-codegen",
|
||||||
"quinn",
|
"quinn",
|
||||||
@ -3925,6 +3927,17 @@ version = "6.4.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee"
|
checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "osascript"
|
||||||
|
version = "0.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "38731fa859ef679f1aec66ca9562165926b442f298467f76f5990f431efe87dc"
|
||||||
|
dependencies = [
|
||||||
|
"serde 1.0.149",
|
||||||
|
"serde_derive",
|
||||||
|
"serde_json 1.0.89",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pango"
|
name = "pango"
|
||||||
version = "0.16.5"
|
version = "0.16.5"
|
||||||
@ -4813,7 +4826,6 @@ dependencies = [
|
|||||||
"arboard",
|
"arboard",
|
||||||
"async-process",
|
"async-process",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"backtrace",
|
|
||||||
"base64",
|
"base64",
|
||||||
"bytes",
|
"bytes",
|
||||||
"cc",
|
"cc",
|
||||||
@ -4847,7 +4859,6 @@ dependencies = [
|
|||||||
"include_dir",
|
"include_dir",
|
||||||
"jni 0.19.0",
|
"jni 0.19.0",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"libc",
|
|
||||||
"libpulse-binding",
|
"libpulse-binding",
|
||||||
"libpulse-simple-binding",
|
"libpulse-simple-binding",
|
||||||
"mac_address",
|
"mac_address",
|
||||||
@ -5046,7 +5057,6 @@ dependencies = [
|
|||||||
"hwcodec",
|
"hwcodec",
|
||||||
"jni 0.19.0",
|
"jni 0.19.0",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"libc",
|
|
||||||
"log",
|
"log",
|
||||||
"ndk 0.7.0",
|
"ndk 0.7.0",
|
||||||
"num_cpus",
|
"num_cpus",
|
||||||
|
@ -43,7 +43,6 @@ cfg-if = "1.0"
|
|||||||
lazy_static = "1.4"
|
lazy_static = "1.4"
|
||||||
sha2 = "0.10"
|
sha2 = "0.10"
|
||||||
repng = "0.2"
|
repng = "0.2"
|
||||||
libc = "0.2"
|
|
||||||
parity-tokio-ipc = { git = "https://github.com/open-trade/parity-tokio-ipc" }
|
parity-tokio-ipc = { git = "https://github.com/open-trade/parity-tokio-ipc" }
|
||||||
flexi_logger = { version = "0.22", features = ["async", "use_chrono_for_offset"] }
|
flexi_logger = { version = "0.22", features = ["async", "use_chrono_for_offset"] }
|
||||||
runas = "0.2"
|
runas = "0.2"
|
||||||
@ -121,7 +120,6 @@ mouce = { git="https://github.com/fufesou/mouce.git" }
|
|||||||
evdev = { git="https://github.com/fufesou/evdev" }
|
evdev = { git="https://github.com/fufesou/evdev" }
|
||||||
dbus = "0.9"
|
dbus = "0.9"
|
||||||
dbus-crossroads = "0.5"
|
dbus-crossroads = "0.5"
|
||||||
backtrace = "0.3"
|
|
||||||
|
|
||||||
[target.'cfg(target_os = "android")'.dependencies]
|
[target.'cfg(target_os = "android")'.dependencies]
|
||||||
android_logger = "0.11"
|
android_logger = "0.11"
|
||||||
|
@ -37,8 +37,5 @@ core-graphics = "0.22"
|
|||||||
objc = "0.2"
|
objc = "0.2"
|
||||||
unicode-segmentation = "1.6"
|
unicode-segmentation = "1.6"
|
||||||
|
|
||||||
[target.'cfg(target_os = "linux")'.dependencies]
|
|
||||||
libc = "0.2"
|
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
pkg-config = "0.3"
|
pkg-config = "0.3"
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
use libc;
|
|
||||||
|
|
||||||
use crate::{Key, KeyboardControllable, MouseButton, MouseControllable};
|
use crate::{Key, KeyboardControllable, MouseButton, MouseControllable};
|
||||||
|
|
||||||
use self::libc::{c_char, c_int, c_void, useconds_t};
|
use hbb_common::libc::{c_char, c_int, c_void, useconds_t};
|
||||||
use std::{borrow::Cow, ffi::CString, ptr};
|
use std::{borrow::Cow, ffi::CString, ptr};
|
||||||
|
|
||||||
const CURRENT_WINDOW: c_int = 0;
|
const CURRENT_WINDOW: c_int = 0;
|
||||||
|
@ -31,6 +31,8 @@ sodiumoxide = "0.2"
|
|||||||
regex = "1.4"
|
regex = "1.4"
|
||||||
tokio-socks = { git = "https://github.com/open-trade/tokio-socks" }
|
tokio-socks = { git = "https://github.com/open-trade/tokio-socks" }
|
||||||
chrono = "0.4"
|
chrono = "0.4"
|
||||||
|
backtrace = "0.3"
|
||||||
|
libc = "0.2"
|
||||||
|
|
||||||
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
|
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
|
||||||
mac_address = "1.1"
|
mac_address = "1.1"
|
||||||
@ -46,6 +48,9 @@ protobuf-codegen = { version = "3.1" }
|
|||||||
[target.'cfg(target_os = "windows")'.dependencies]
|
[target.'cfg(target_os = "windows")'.dependencies]
|
||||||
winapi = { version = "0.3", features = ["winuser"] }
|
winapi = { version = "0.3", features = ["winuser"] }
|
||||||
|
|
||||||
|
[target.'cfg(target_os = "macos")'.dependencies]
|
||||||
|
osascript = "0.3.0"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
toml = "0.5"
|
toml = "0.5"
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
|
19
libs/hbb_common/examples/system_message.rs
Normal file
19
libs/hbb_common/examples/system_message.rs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
extern crate hbb_common;
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
use hbb_common::platform::linux;
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
use hbb_common::platform::macos;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
linux::system_message("test title", "test message", true).ok();
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
macos::alert(
|
||||||
|
"RustDesk".to_owned(),
|
||||||
|
"warning".to_owned(),
|
||||||
|
"test title".to_owned(),
|
||||||
|
"test message".to_owned(),
|
||||||
|
["Ok".to_owned()].to_vec(),
|
||||||
|
)
|
||||||
|
.ok();
|
||||||
|
}
|
@ -39,6 +39,7 @@ pub use tokio_socks::IntoTargetAddr;
|
|||||||
pub use tokio_socks::TargetAddr;
|
pub use tokio_socks::TargetAddr;
|
||||||
pub mod password_security;
|
pub mod password_security;
|
||||||
pub use chrono;
|
pub use chrono;
|
||||||
|
pub use libc;
|
||||||
pub use directories_next;
|
pub use directories_next;
|
||||||
pub mod keyboard;
|
pub mod keyboard;
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use crate::ResultType;
|
use crate::ResultType;
|
||||||
|
use std::{collections::HashMap, process::Command};
|
||||||
|
|
||||||
lazy_static::lazy_static! {
|
lazy_static::lazy_static! {
|
||||||
pub static ref DISTRO: Distro = Distro::new();
|
pub static ref DISTRO: Distro = Distro::new();
|
||||||
@ -155,3 +156,42 @@ fn run_loginctl(args: Option<Vec<&str>>) -> std::io::Result<std::process::Output
|
|||||||
.args(vec![String::from("--host"), l_args])
|
.args(vec![String::from("--host"), l_args])
|
||||||
.output()
|
.output()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// forever: may not work
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
pub fn system_message(title: &str, msg: &str, forever: bool) -> ResultType<()> {
|
||||||
|
let cmds: HashMap<&str, Vec<&str>> = HashMap::from([
|
||||||
|
("notify-send", [title, msg].to_vec()),
|
||||||
|
(
|
||||||
|
"zenity",
|
||||||
|
[
|
||||||
|
"--info",
|
||||||
|
"--timeout",
|
||||||
|
if forever { "0" } else { "3" },
|
||||||
|
"--title",
|
||||||
|
title,
|
||||||
|
"--text",
|
||||||
|
msg,
|
||||||
|
]
|
||||||
|
.to_vec(),
|
||||||
|
),
|
||||||
|
("kdialog", ["--title", title, "--msgbox", msg].to_vec()),
|
||||||
|
(
|
||||||
|
"xmessage",
|
||||||
|
[
|
||||||
|
"-center",
|
||||||
|
"-timeout",
|
||||||
|
if forever { "0" } else { "3" },
|
||||||
|
title,
|
||||||
|
msg,
|
||||||
|
]
|
||||||
|
.to_vec(),
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
for (k, v) in cmds {
|
||||||
|
if Command::new(k).args(v).spawn().is_ok() {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
crate::bail!("failed to post system message");
|
||||||
|
}
|
||||||
|
55
libs/hbb_common/src/platform/macos.rs
Normal file
55
libs/hbb_common/src/platform/macos.rs
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
use crate::ResultType;
|
||||||
|
use osascript;
|
||||||
|
use serde_derive::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Serialize)]
|
||||||
|
struct AlertParams {
|
||||||
|
title: String,
|
||||||
|
message: String,
|
||||||
|
alert_type: String,
|
||||||
|
buttons: Vec<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct AlertResult {
|
||||||
|
#[serde(rename = "buttonReturned")]
|
||||||
|
button: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Alert dialog, return the clicked button value.
|
||||||
|
///
|
||||||
|
/// # Arguments
|
||||||
|
///
|
||||||
|
/// * `app` - The app to execute the script.
|
||||||
|
/// * `alert_type` - Alert type. . informational, warning, critical
|
||||||
|
/// * `title` - The alert title.
|
||||||
|
/// * `message` - The alert message.
|
||||||
|
/// * `buttons` - The buttons to show.
|
||||||
|
pub fn alert(
|
||||||
|
app: String,
|
||||||
|
alert_type: String,
|
||||||
|
title: String,
|
||||||
|
message: String,
|
||||||
|
buttons: Vec<String>,
|
||||||
|
) -> ResultType<String> {
|
||||||
|
let script = osascript::JavaScript::new(&format!(
|
||||||
|
"
|
||||||
|
var App = Application('{}');
|
||||||
|
App.includeStandardAdditions = true;
|
||||||
|
return App.displayAlert($params.title, {{
|
||||||
|
message: $params.message,
|
||||||
|
'as': $params.alert_type,
|
||||||
|
buttons: $params.buttons,
|
||||||
|
}});
|
||||||
|
",
|
||||||
|
app
|
||||||
|
));
|
||||||
|
|
||||||
|
let result: AlertResult = script.execute_with_params(AlertParams {
|
||||||
|
title,
|
||||||
|
message,
|
||||||
|
alert_type,
|
||||||
|
buttons,
|
||||||
|
})?;
|
||||||
|
Ok(result.button)
|
||||||
|
}
|
@ -1,2 +1,60 @@
|
|||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
pub mod linux;
|
pub mod linux;
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
pub mod macos;
|
||||||
|
|
||||||
|
use crate::{config::Config, log};
|
||||||
|
use std::process::exit;
|
||||||
|
|
||||||
|
extern "C" fn breakdown_signal_handler(sig: i32) {
|
||||||
|
let mut stack = vec![];
|
||||||
|
backtrace::trace(|frame| {
|
||||||
|
backtrace::resolve_frame(frame, |symbol| {
|
||||||
|
if let Some(name) = symbol.name() {
|
||||||
|
stack.push(name.to_string());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
true // keep going to the next frame
|
||||||
|
});
|
||||||
|
let mut info = String::default();
|
||||||
|
if stack.iter().any(|s| {
|
||||||
|
s.contains(&"nouveau_pushbuf_kick")
|
||||||
|
|| s.to_lowercase().contains("nvidia")
|
||||||
|
|| s.contains("gdk_window_end_draw_frame")
|
||||||
|
}) {
|
||||||
|
Config::set_option("allow-always-software-render".to_string(), "Y".to_string());
|
||||||
|
info = "Always use software rendering will be set.".to_string();
|
||||||
|
log::info!("{}", info);
|
||||||
|
}
|
||||||
|
log::error!(
|
||||||
|
"Got signal {} and exit. stack:\n{}",
|
||||||
|
sig,
|
||||||
|
stack.join("\n").to_string()
|
||||||
|
);
|
||||||
|
if !info.is_empty() {
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
linux::system_message(
|
||||||
|
"RustDesk",
|
||||||
|
&format!("Got signal {} and exit.{}", sig, info),
|
||||||
|
true,
|
||||||
|
)
|
||||||
|
.ok();
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
macos::alert(
|
||||||
|
"RustDesk".to_owned(),
|
||||||
|
"critical".to_owned(),
|
||||||
|
"Crashed".to_owned(),
|
||||||
|
format!("Got signal {} and exit.{}", sig, info),
|
||||||
|
["Ok".to_owned()].to_vec(),
|
||||||
|
)
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn register_breakdown_handler() {
|
||||||
|
unsafe {
|
||||||
|
libc::signal(libc::SIGSEGV, breakdown_signal_handler as _);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -16,7 +16,6 @@ mediacodec = ["ndk"]
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
block = "0.1"
|
block = "0.1"
|
||||||
cfg-if = "1.0"
|
cfg-if = "1.0"
|
||||||
libc = "0.2"
|
|
||||||
num_cpus = "1.13"
|
num_cpus = "1.13"
|
||||||
lazy_static = "1.4"
|
lazy_static = "1.4"
|
||||||
hbb_common = { path = "../hbb_common" }
|
hbb_common = { path = "../hbb_common" }
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
extern crate block;
|
extern crate block;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate cfg_if;
|
extern crate cfg_if;
|
||||||
pub extern crate libc;
|
pub use hbb_common::libc;
|
||||||
#[cfg(dxgi)]
|
#[cfg(dxgi)]
|
||||||
extern crate winapi;
|
extern crate winapi;
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
use block::{Block, ConcreteBlock};
|
use block::{Block, ConcreteBlock};
|
||||||
use libc::c_void;
|
use hbb_common::libc::c_void;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
use super::config::Config;
|
use super::config::Config;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
use libc::c_void;
|
use hbb_common::libc::c_void;
|
||||||
|
|
||||||
use super::ffi::*;
|
use super::ffi::*;
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
use block::RcBlock;
|
use block::RcBlock;
|
||||||
use libc::c_void;
|
use hbb_common::libc::c_void;
|
||||||
|
|
||||||
pub type CGDisplayStreamRef = *mut c_void;
|
pub type CGDisplayStreamRef = *mut c_void;
|
||||||
pub type CFDictionaryRef = *mut c_void;
|
pub type CFDictionaryRef = *mut c_void;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use std::{io, ptr, slice};
|
use std::{io, ptr, slice};
|
||||||
|
|
||||||
use libc;
|
use hbb_common::libc;
|
||||||
|
|
||||||
use super::ffi::*;
|
use super::ffi::*;
|
||||||
use super::Display;
|
use super::Display;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#![allow(non_camel_case_types)]
|
#![allow(non_camel_case_types)]
|
||||||
|
|
||||||
use libc::c_void;
|
use hbb_common::libc::c_void;
|
||||||
|
|
||||||
#[link(name = "xcb")]
|
#[link(name = "xcb")]
|
||||||
#[link(name = "xcb-shm")]
|
#[link(name = "xcb-shm")]
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
use libc;
|
use hbb_common::libc;
|
||||||
|
|
||||||
use super::ffi::*;
|
use super::ffi::*;
|
||||||
use super::{Display, Rect, Server};
|
use super::{Display, Rect, Server};
|
||||||
|
@ -101,7 +101,7 @@ pub fn get_key_state(key: enigo::Key) -> bool {
|
|||||||
cfg_if::cfg_if! {
|
cfg_if::cfg_if! {
|
||||||
if #[cfg(target_os = "android")] {
|
if #[cfg(target_os = "android")] {
|
||||||
|
|
||||||
use libc::{c_float, c_int, c_void};
|
use hbb_common::libc::{c_float, c_int, c_void};
|
||||||
type Oboe = *mut c_void;
|
type Oboe = *mut c_void;
|
||||||
extern "C" {
|
extern "C" {
|
||||||
fn create_oboe_player(channels: c_int, sample_rate: c_int) -> Oboe;
|
fn create_oboe_player(channels: c_int, sample_rate: c_int) -> Oboe;
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
use hbb_common::log;
|
use hbb_common::log;
|
||||||
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
|
use hbb_common::platform::register_breakdown_handler;
|
||||||
|
|
||||||
/// shared by flutter and sciter main function
|
/// shared by flutter and sciter main function
|
||||||
///
|
///
|
||||||
@ -38,10 +40,11 @@ pub fn core_main() -> Option<Vec<String>> {
|
|||||||
}
|
}
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
|
register_breakdown_handler();
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
#[cfg(feature = "flutter")]
|
#[cfg(feature = "flutter")]
|
||||||
{
|
{
|
||||||
crate::platform::linux::register_breakdown_handler();
|
|
||||||
let (k, v) = ("LIBGL_ALWAYS_SOFTWARE", "true");
|
let (k, v) = ("LIBGL_ALWAYS_SOFTWARE", "true");
|
||||||
if !hbb_common::config::Config::get_option("allow-always-software-render").is_empty() {
|
if !hbb_common::config::Config::get_option("allow-always-software-render").is_empty() {
|
||||||
std::env::set_var(k, v);
|
std::env::set_var(k, v);
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
use super::{CursorData, ResultType};
|
use super::{CursorData, ResultType};
|
||||||
|
use hbb_common::libc::{c_char, c_int, c_long, c_void};
|
||||||
pub use hbb_common::platform::linux::*;
|
pub use hbb_common::platform::linux::*;
|
||||||
use hbb_common::{allow_err, bail, log};
|
use hbb_common::{allow_err, bail, log};
|
||||||
use libc::{c_char, c_int, c_void};
|
|
||||||
use std::{
|
use std::{
|
||||||
cell::RefCell,
|
cell::RefCell,
|
||||||
collections::HashMap,
|
|
||||||
path::PathBuf,
|
path::PathBuf,
|
||||||
sync::{
|
sync::{
|
||||||
atomic::{AtomicBool, Ordering},
|
atomic::{AtomicBool, Ordering},
|
||||||
@ -54,8 +53,8 @@ pub struct xcb_xfixes_get_cursor_image {
|
|||||||
pub height: u16,
|
pub height: u16,
|
||||||
pub xhot: u16,
|
pub xhot: u16,
|
||||||
pub yhot: u16,
|
pub yhot: u16,
|
||||||
pub cursor_serial: libc::c_long,
|
pub cursor_serial: c_long,
|
||||||
pub pixels: *const libc::c_long,
|
pub pixels: *const c_long,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_cursor_pos() -> Option<(i32, i32)> {
|
pub fn get_cursor_pos() -> Option<(i32, i32)> {
|
||||||
@ -637,91 +636,8 @@ pub fn get_double_click_time() -> u32 {
|
|||||||
settings,
|
settings,
|
||||||
property.as_ptr(),
|
property.as_ptr(),
|
||||||
&mut double_click_time as *mut u32,
|
&mut double_click_time as *mut u32,
|
||||||
0 as *const libc::c_void,
|
0 as *const c_void,
|
||||||
);
|
);
|
||||||
double_click_time
|
double_click_time
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// forever: may not work
|
|
||||||
pub fn system_message(title: &str, msg: &str, forever: bool) -> ResultType<()> {
|
|
||||||
let cmds: HashMap<&str, Vec<&str>> = HashMap::from([
|
|
||||||
("notify-send", [title, msg].to_vec()),
|
|
||||||
(
|
|
||||||
"zenity",
|
|
||||||
[
|
|
||||||
"--info",
|
|
||||||
"--timeout",
|
|
||||||
if forever { "0" } else { "3" },
|
|
||||||
"--title",
|
|
||||||
title,
|
|
||||||
"--text",
|
|
||||||
msg,
|
|
||||||
]
|
|
||||||
.to_vec(),
|
|
||||||
),
|
|
||||||
("kdialog", ["--title", title, "--msgbox", msg].to_vec()),
|
|
||||||
(
|
|
||||||
"xmessage",
|
|
||||||
[
|
|
||||||
"-center",
|
|
||||||
"-timeout",
|
|
||||||
if forever { "0" } else { "3" },
|
|
||||||
title,
|
|
||||||
msg,
|
|
||||||
]
|
|
||||||
.to_vec(),
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
for (k, v) in cmds {
|
|
||||||
if std::process::Command::new(k).args(v).spawn().is_ok() {
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bail!("failed to post system message");
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" fn breakdown_signal_handler(sig: i32) {
|
|
||||||
let mut stack = vec![];
|
|
||||||
backtrace::trace(|frame| {
|
|
||||||
backtrace::resolve_frame(frame, |symbol| {
|
|
||||||
if let Some(name) = symbol.name() {
|
|
||||||
stack.push(name.to_string());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
true // keep going to the next frame
|
|
||||||
});
|
|
||||||
let mut info = String::default();
|
|
||||||
if stack.iter().any(|s| {
|
|
||||||
s.contains(&"nouveau_pushbuf_kick")
|
|
||||||
|| s.to_lowercase().contains("nvidia")
|
|
||||||
|| s.contains("gdk_window_end_draw_frame")
|
|
||||||
}) {
|
|
||||||
hbb_common::config::Config::set_option(
|
|
||||||
"allow-always-software-render".to_string(),
|
|
||||||
"Y".to_string(),
|
|
||||||
);
|
|
||||||
info = "Always use software rendering will be set.".to_string();
|
|
||||||
log::info!("{}", info);
|
|
||||||
}
|
|
||||||
log::error!(
|
|
||||||
"Got signal {} and exit. stack:\n{}",
|
|
||||||
sig,
|
|
||||||
stack.join("\n").to_string()
|
|
||||||
);
|
|
||||||
if !info.is_empty() {
|
|
||||||
system_message(
|
|
||||||
"RustDesk",
|
|
||||||
&format!("Got signal {} and exit.{}", sig, info),
|
|
||||||
true,
|
|
||||||
)
|
|
||||||
.ok();
|
|
||||||
}
|
|
||||||
std::process::exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn register_breakdown_handler() {
|
|
||||||
unsafe {
|
|
||||||
libc::signal(libc::SIGSEGV, breakdown_signal_handler as _);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -2,7 +2,7 @@ use core::slice;
|
|||||||
use hbb_common::{
|
use hbb_common::{
|
||||||
allow_err,
|
allow_err,
|
||||||
anyhow::anyhow,
|
anyhow::anyhow,
|
||||||
bail, log,
|
bail, libc, log,
|
||||||
message_proto::{KeyEvent, MouseEvent},
|
message_proto::{KeyEvent, MouseEvent},
|
||||||
protobuf::Message,
|
protobuf::Message,
|
||||||
tokio::{self, sync::mpsc},
|
tokio::{self, sync::mpsc},
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#[cfg(any(target_os = "windows"))]
|
#[cfg(target_os = "windows")]
|
||||||
use super::ui_interface::get_option_opt;
|
use super::ui_interface::get_option_opt;
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
@ -80,7 +80,7 @@ pub fn start_tray() {
|
|||||||
/// Check if service is stoped.
|
/// Check if service is stoped.
|
||||||
/// Return [`true`] if service is stoped, [`false`] otherwise.
|
/// Return [`true`] if service is stoped, [`false`] otherwise.
|
||||||
#[inline]
|
#[inline]
|
||||||
#[cfg(any(target_os = "windows"))]
|
#[cfg(target_os = "windows")]
|
||||||
fn is_service_stopped() -> bool {
|
fn is_service_stopped() -> bool {
|
||||||
if let Some(v) = get_option_opt("stop-service") {
|
if let Some(v) = get_option_opt("stop-service") {
|
||||||
v == "Y"
|
v == "Y"
|
||||||
|
@ -128,7 +128,7 @@ pub fn get_license() -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[cfg(any(target_os = "linux", target_os = "windows"))]
|
#[cfg(target_os = "windows")]
|
||||||
pub fn get_option_opt(key: &str) -> Option<String> {
|
pub fn get_option_opt(key: &str) -> Option<String> {
|
||||||
OPTIONS.lock().unwrap().get(key).map(|x| x.clone())
|
OPTIONS.lock().unwrap().get(key).map(|x| x.clone())
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user