Skip to main content

gdk/
visual.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use crate::Visual;
4use std::ptr;
5use std::slice;
6
7impl Visual {
8    #[doc(alias = "gdk_query_depths")]
9    pub fn query_depths() -> Vec<i32> {
10        assert_initialized_main_thread!();
11        let mut ptr = ptr::null_mut();
12        let mut count = 0;
13
14        unsafe {
15            ffi::gdk_query_depths(&mut ptr, &mut count);
16            if ptr.is_null() || count == 0 {
17                vec![]
18            } else {
19                Vec::from(slice::from_raw_parts(ptr as *const i32, count as usize))
20            }
21        }
22    }
23}