mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-04-07 13:11:27 +03:00
init wayland to update var 'cursor embeded'
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
@@ -4,12 +4,26 @@ use std::{io, sync::RwLock, time::Duration};
|
||||
|
||||
pub struct Capturer(Display, Box<dyn Recorder>, bool, Vec<u8>);
|
||||
|
||||
pub const IS_CURSOR_EMBEDDED: bool = true;
|
||||
pub static mut IS_CURSOR_EMBEDDED: bool = true;
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
static ref MAP_ERR: RwLock<Option<fn(err: String)-> io::Error>> = Default::default();
|
||||
}
|
||||
|
||||
pub fn detect_cursor_embeded() {
|
||||
if unsafe { IS_CURSOR_EMBEDDED } {
|
||||
use crate::common::wayland::pipewire::get_available_cursor_modes;
|
||||
match get_available_cursor_modes() {
|
||||
Ok(modes) => unsafe {
|
||||
IS_CURSOR_EMBEDDED = (modes & 0x02) > 0;
|
||||
},
|
||||
Err(..) => unsafe {
|
||||
IS_CURSOR_EMBEDDED = false;
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_map_err(f: fn(err: String) -> io::Error) {
|
||||
*MAP_ERR.write().unwrap() = Some(f);
|
||||
}
|
||||
@@ -74,7 +88,7 @@ impl Display {
|
||||
}
|
||||
|
||||
pub fn all() -> io::Result<Vec<Display>> {
|
||||
Ok(pipewire::get_capturables(true)
|
||||
Ok(pipewire::get_capturables(unsafe { IS_CURSOR_EMBEDDED })
|
||||
.map_err(map_err)?
|
||||
.drain(..)
|
||||
.map(|x| Display(x))
|
||||
|
||||
Reference in New Issue
Block a user