mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
move virtual display to lib workspace
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
@@ -53,8 +53,6 @@ mod connection;
|
||||
pub mod portable_service;
|
||||
mod service;
|
||||
mod video_qos;
|
||||
#[cfg(windows)]
|
||||
mod virtual_display;
|
||||
pub mod video_service;
|
||||
|
||||
use hbb_common::tcp::new_listener;
|
||||
|
||||
@@ -42,7 +42,7 @@ use std::{
|
||||
time::{self, Duration, Instant},
|
||||
};
|
||||
#[cfg(windows)]
|
||||
use super::virtual_display;
|
||||
use virtual_display;
|
||||
|
||||
pub const SCRAP_UBUNTU_HIGHER_REQUIRED: &str = "Wayland requires Ubuntu 21.04 or higher version.";
|
||||
pub const SCRAP_OTHER_VERSION_OR_X11_REQUIRED: &str =
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
use hbb_common::{bail, ResultType};
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
const LIB_NAME_VIRTUAL_DISPLAY: &str = "virtual_display";
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
static ref LIB_VIRTUAL_DISPLAY: Arc<Mutex<Result<libloading::Library, libloading::Error>>> = {
|
||||
#[cfg(target_os = "windows")]
|
||||
let libname = format!("{}.dll", LIB_NAME_VIRTUAL_DISPLAY);
|
||||
#[cfg(target_os = "linux")]
|
||||
let libname = format!("lib{}.so", LIB_NAME_VIRTUAL_DISPLAY);
|
||||
#[cfg(target_os = "macos")]
|
||||
let libname = format!("lib{}.dylib", LIB_NAME_VIRTUAL_DISPLAY);
|
||||
Arc::new(Mutex::new(unsafe { libloading::Library::new(libname) }))
|
||||
};
|
||||
}
|
||||
|
||||
pub(super) fn is_device_created() -> bool {
|
||||
match &*LIB_VIRTUAL_DISPLAY.lock().unwrap() {
|
||||
Ok(lib) => unsafe {
|
||||
match lib.get::<libloading::Symbol<fn() -> bool>>(b"is_device_created") {
|
||||
Ok(func) => func(),
|
||||
Err(..) => false,
|
||||
}
|
||||
},
|
||||
Err(..) => false,
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! def_func_result {
|
||||
($func:ident, $name: tt) => {
|
||||
pub(super) fn $func() -> ResultType<()> {
|
||||
match &*LIB_VIRTUAL_DISPLAY.lock().unwrap() {
|
||||
Ok(lib) => unsafe {
|
||||
match lib.get::<libloading::Symbol<fn() -> ResultType<()>>>($name.as_bytes()) {
|
||||
Ok(func) => func(),
|
||||
Err(..) => bail!("Failed to load func {}", $name),
|
||||
}
|
||||
},
|
||||
Err(e) => bail!("Failed to load library {}, {}", LIB_NAME_VIRTUAL_DISPLAY, e),
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
def_func_result!(create_device, "create_device");
|
||||
|
||||
pub(super) fn close_device() {
|
||||
match &*LIB_VIRTUAL_DISPLAY.lock().unwrap() {
|
||||
Ok(lib) => unsafe {
|
||||
match lib.get::<libloading::Symbol<fn()>>(b"close_device") {
|
||||
Ok(func) => func(),
|
||||
Err(..) => {},
|
||||
}
|
||||
},
|
||||
Err(..) => {},
|
||||
}
|
||||
}
|
||||
|
||||
def_func_result!(plug_in_monitor, "plug_in_monitor");
|
||||
def_func_result!(plug_out_monitor, "plug_out_monitor");
|
||||
def_func_result!(update_monitor_modes, "update_monitor_modes");
|
||||
Reference in New Issue
Block a user