Clean remapped keycodes when breakdown
This commit is contained in:
parent
b59f87f825
commit
6ffa2cacb1
@ -7,6 +7,8 @@ pub mod macos;
|
|||||||
use crate::{config::Config, log};
|
use crate::{config::Config, log};
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
|
|
||||||
|
static mut GLOBAL_CALLBACK: Option<Box<dyn Fn()>> = None;
|
||||||
|
|
||||||
extern "C" fn breakdown_signal_handler(sig: i32) {
|
extern "C" fn breakdown_signal_handler(sig: i32) {
|
||||||
let mut stack = vec![];
|
let mut stack = vec![];
|
||||||
backtrace::trace(|frame| {
|
backtrace::trace(|frame| {
|
||||||
@ -41,11 +43,20 @@ extern "C" fn breakdown_signal_handler(sig: i32) {
|
|||||||
)
|
)
|
||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
|
unsafe {
|
||||||
|
if let Some(callback) = &GLOBAL_CALLBACK {
|
||||||
|
callback()
|
||||||
|
}
|
||||||
|
}
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn register_breakdown_handler() {
|
pub fn register_breakdown_handler<T>(callback: T)
|
||||||
|
where
|
||||||
|
T: Fn() + 'static,
|
||||||
|
{
|
||||||
unsafe {
|
unsafe {
|
||||||
|
GLOBAL_CALLBACK = Some(Box::new(callback));
|
||||||
libc::signal(libc::SIGSEGV, breakdown_signal_handler as _);
|
libc::signal(libc::SIGSEGV, breakdown_signal_handler as _);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
use crate::platform::breakdown_callback;
|
||||||
use hbb_common::log;
|
use hbb_common::log;
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
use hbb_common::platform::register_breakdown_handler;
|
use hbb_common::platform::register_breakdown_handler;
|
||||||
@ -38,7 +39,7 @@ pub fn core_main() -> Option<Vec<String>> {
|
|||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
register_breakdown_handler();
|
register_breakdown_handler(breakdown_callback);
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
#[cfg(feature = "flutter")]
|
#[cfg(feature = "flutter")]
|
||||||
{
|
{
|
||||||
|
@ -17,6 +17,7 @@ pub mod delegate;
|
|||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
pub mod linux;
|
pub mod linux;
|
||||||
|
|
||||||
|
use crate::input_service::clear_remapped_keycode;
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
use hbb_common::{message_proto::CursorData, ResultType};
|
use hbb_common::{message_proto::CursorData, ResultType};
|
||||||
#[cfg(not(target_os = "macos"))]
|
#[cfg(not(target_os = "macos"))]
|
||||||
@ -41,6 +42,11 @@ pub fn is_xfce() -> bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn breakdown_callback() {
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
clear_remapped_keycode()
|
||||||
|
}
|
||||||
|
|
||||||
// Android
|
// Android
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
pub fn get_active_username() -> String {
|
pub fn get_active_username() -> String {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user