fn get_parent_window()

in src/platform_impl/linux/x11/util/geometry.rs [233:258]


    fn get_parent_window(&self, window: ffi::Window) -> Result<ffi::Window, XError> {
        let parent = unsafe {
            let mut root = 0;
            let mut parent = 0;
            let mut children: *mut ffi::Window = ptr::null_mut();
            let mut nchildren = 0;

            // What's filled into `parent` if `window` is the root window?
            let _status = (self.xlib.XQueryTree)(
                self.display,
                window,
                &mut root,
                &mut parent,
                &mut children,
                &mut nchildren,
            );

            // The list of children isn't used
            if children != ptr::null_mut() {
                (self.xlib.XFree)(children as *mut _);
            }

            parent
        };
        self.check_errors().map(|_| parent)
    }