mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-04-09 11:51:28 +03:00
@@ -1,3 +1,4 @@
|
||||
use std::ffi::CString;
|
||||
use std::ptr;
|
||||
use std::rc::Rc;
|
||||
|
||||
@@ -64,6 +65,7 @@ impl Iterator for DisplayIter {
|
||||
if inner.rem != 0 {
|
||||
unsafe {
|
||||
let data = &*inner.data;
|
||||
let name = get_atom_name(self.server.raw(), data.name);
|
||||
|
||||
let display = Display::new(
|
||||
self.server.clone(),
|
||||
@@ -75,6 +77,7 @@ impl Iterator for DisplayIter {
|
||||
h: data.height,
|
||||
},
|
||||
root,
|
||||
name,
|
||||
);
|
||||
|
||||
xcb_randr_monitor_info_next(inner);
|
||||
@@ -91,3 +94,30 @@ impl Iterator for DisplayIter {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn get_atom_name(conn: *mut xcb_connection_t, atom: xcb_atom_t) -> String {
|
||||
let empty = "".to_owned();
|
||||
if atom == 0 {
|
||||
return empty;
|
||||
}
|
||||
unsafe {
|
||||
let mut e: xcb_generic_error_t = std::mem::zeroed();
|
||||
let reply = xcb_get_atom_name_reply(
|
||||
conn,
|
||||
xcb_get_atom_name(conn, atom),
|
||||
&mut ((&mut e) as *mut xcb_generic_error_t) as _,
|
||||
);
|
||||
if reply == std::ptr::null() {
|
||||
return empty;
|
||||
}
|
||||
let length = xcb_get_atom_name_name_length(reply);
|
||||
let name = xcb_get_atom_name_name(reply);
|
||||
let mut v = vec![0u8; length as _];
|
||||
std::ptr::copy_nonoverlapping(name as _, v.as_mut_ptr(), length as _);
|
||||
libc::free(reply as *mut _);
|
||||
if let Ok(s) = CString::new(v) {
|
||||
return s.to_string_lossy().to_string();
|
||||
}
|
||||
empty
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user