diff --git a/libs/hbb_common/src/platform/linux.rs b/libs/hbb_common/src/platform/linux.rs index 1a41ebad6..d4d44270a 100644 --- a/libs/hbb_common/src/platform/linux.rs +++ b/libs/hbb_common/src/platform/linux.rs @@ -1,10 +1,6 @@ use crate::ResultType; use std::sync::Mutex; -lazy_static::lazy_static! { - pub static ref IS_X11: Mutex = Mutex::new("x11" == get_display_server()); -} - pub fn get_display_server() -> String { let session = get_value_of_seat0(0); get_display_server_of_session(&session) diff --git a/src/client.rs b/src/client.rs index 9f330ea1c..6cda7f9ad 100644 --- a/src/client.rs +++ b/src/client.rs @@ -156,7 +156,7 @@ impl Client { } Ok(x) => { #[cfg(target_os = "linux")] - if !*IS_X11.lock().unwrap() { + if !*crate::common::IS_X11.lock().unwrap() { let keyboard = super::uinput::client::UInputKeyboard::new().await?; log::info!("UInput keyboard created"); let mouse = super::uinput::client::UInputMouse::new().await?; diff --git a/src/common.rs b/src/common.rs index 2be4b5295..58b456db9 100644 --- a/src/common.rs +++ b/src/common.rs @@ -721,4 +721,13 @@ pub fn get_keyboard_mode() -> String { pub fn save_keyboard_mode(value: String) { std::env::set_var("KEYBOARD_MODE", value); +} + +lazy_static::lazy_static! { + pub static ref IS_X11: Mutex = { + #[cfg(not(target_os = "linux"))] + Mutex::new("x11" == hbb_common::platform::linux::get_display_server()) + #[cfg(not(target_os = "linux"))] + false + }; } \ No newline at end of file diff --git a/src/server/input_service.rs b/src/server/input_service.rs index 3765eb9e0..19be48b8e 100644 --- a/src/server/input_service.rs +++ b/src/server/input_service.rs @@ -2,7 +2,7 @@ use super::*; #[cfg(target_os = "macos")] use dispatch::Queue; use enigo::{Enigo, Key, KeyboardControllable, MouseButton, MouseControllable}; -use hbb_common::platform::linux::IS_X11; +use crate::common::IS_X11; use hbb_common::{config::COMPRESS_LEVEL, protobuf::EnumOrUnknown}; use rdev::{simulate, EventType, Key as RdevKey}; use std::{