forked from rust-windowing/raw-window-handle
/
macos.rs
43 lines (40 loc) · 1.16 KB
/
macos.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use core::ptr;
use libc::c_void;
/// Raw window handle for macOS.
///
/// ## Construction
/// ```
/// # use raw_window_handle::macos::MacOSHandle;
/// let handle = MacOSHandle {
/// /* fields */
/// ..MacOSHandle::empty()
/// };
/// ```
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct MacOSHandle {
pub ns_window: *mut c_void,
pub ns_view: *mut c_void,
// TODO: WHAT ABOUT ns_window_controller and ns_view_controller?
#[doc(hidden)]
#[deprecated = "This field is used to ensure that this struct is non-exhaustive, so that it may be extended in the future. Do not refer to this field."]
pub _non_exhaustive_do_not_use: crate::seal::Seal,
}
impl MacOSHandle {
pub fn empty() -> MacOSHandle {
#[allow(deprecated)]
MacOSHandle {
ns_window: ptr::null_mut(),
ns_view: ptr::null_mut(),
_non_exhaustive_do_not_use: crate::seal::Seal,
}
}
}
impl From<new::AppKitHandle> for MacOSHandle {
fn from(handle: new::AppKitHandle) -> Self {
Self {
ns_window: handle.ns_window,
ns_view: handle.ns_view,
..Self::empty()
}
}
}