2021-03-29 15:59:14 +08:00
|
|
|
#[cfg(target_os = "linux")]
|
|
|
|
pub use linux::*;
|
|
|
|
#[cfg(target_os = "macos")]
|
|
|
|
pub use macos::*;
|
|
|
|
#[cfg(windows)]
|
|
|
|
pub use windows::*;
|
|
|
|
|
|
|
|
#[cfg(windows)]
|
|
|
|
pub mod windows;
|
|
|
|
|
|
|
|
#[cfg(target_os = "macos")]
|
|
|
|
pub mod macos;
|
|
|
|
|
|
|
|
#[cfg(target_os = "linux")]
|
|
|
|
pub mod linux;
|
|
|
|
|
|
|
|
use hbb_common::{message_proto::CursorData, ResultType};
|
|
|
|
const SERVICE_INTERVAL: u64 = 300;
|
|
|
|
|
2021-05-02 21:19:48 +08:00
|
|
|
pub fn is_xfce() -> bool {
|
|
|
|
#[cfg(target_os = "linux")]
|
|
|
|
{
|
|
|
|
return std::env::var_os("XDG_CURRENT_DESKTOP") == Some(std::ffi::OsString::from("XFCE"));
|
|
|
|
}
|
|
|
|
#[cfg(not(target_os = "linux"))]
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-29 15:59:14 +08:00
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::*;
|
|
|
|
#[test]
|
|
|
|
fn test_cursor_data() {
|
|
|
|
for _ in 0..30 {
|
|
|
|
if let Some(hc) = get_cursor().unwrap() {
|
|
|
|
let cd = get_cursor_data(hc).unwrap();
|
|
|
|
repng::encode(
|
|
|
|
std::fs::File::create("cursor.png").unwrap(),
|
|
|
|
cd.width as _,
|
|
|
|
cd.height as _,
|
|
|
|
&cd.colors[..],
|
|
|
|
)
|
|
|
|
.unwrap();
|
|
|
|
}
|
|
|
|
#[cfg(target_os = "macos")]
|
|
|
|
macos::is_process_trusted(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#[test]
|
|
|
|
fn test_get_cursor_pos() {
|
|
|
|
for _ in 0..30 {
|
|
|
|
assert!(!get_cursor_pos().is_none());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|