1 use core::ptr;
2 use libc::{c_ulong, c_void};
3 
4 /// Raw window handle for Xlib.
5 ///
6 /// ## Construction
7 /// ```
8 /// # use raw_window_handle::unix::XlibHandle;
9 /// let handle = XlibHandle {
10 ///     /* fields */
11 ///     ..XlibHandle::empty()
12 /// };
13 /// ```
14 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
15 pub struct XlibHandle {
16     /// An Xlib `Window`.
17     pub window: c_ulong,
18     /// A pointer to an Xlib `Display`.
19     pub display: *mut c_void,
20     #[doc(hidden)]
21     #[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."]
22     pub _non_exhaustive_do_not_use: crate::seal::Seal,
23 }
24 
25 /// Raw window handle for Xcb.
26 ///
27 /// ## Construction
28 /// ```
29 /// # use raw_window_handle::unix::XcbHandle;
30 /// let handle = XcbHandle {
31 ///     /* fields */
32 ///     ..XcbHandle::empty()
33 /// };
34 /// ```
35 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
36 pub struct XcbHandle {
37     /// An X11 `xcb_window_t`.
38     pub window: u32, // Based on xproto.h
39     /// A pointer to an X server `xcb_connection_t`.
40     pub connection: *mut c_void,
41     #[doc(hidden)]
42     #[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."]
43     pub _non_exhaustive_do_not_use: crate::seal::Seal,
44 }
45 
46 /// Raw window handle for Wayland.
47 ///
48 /// ## Construction
49 /// ```
50 /// # use raw_window_handle::unix::WaylandHandle;
51 /// let handle = WaylandHandle {
52 ///     /* fields */
53 ///     ..WaylandHandle::empty()
54 /// };
55 /// ```
56 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
57 pub struct WaylandHandle {
58     /// A pointer to a `wl_surface`.
59     pub surface: *mut c_void,
60     /// A pointer to a `wl_display`.
61     pub display: *mut c_void,
62     #[doc(hidden)]
63     #[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."]
64     pub _non_exhaustive_do_not_use: crate::seal::Seal,
65 }
66 
67 impl XlibHandle {
empty() -> XlibHandle68     pub fn empty() -> XlibHandle {
69         #[allow(deprecated)]
70         XlibHandle {
71             window: 0,
72             display: ptr::null_mut(),
73             _non_exhaustive_do_not_use: crate::seal::Seal,
74         }
75     }
76 }
77 
78 impl XcbHandle {
empty() -> XcbHandle79     pub fn empty() -> XcbHandle {
80         #[allow(deprecated)]
81         XcbHandle {
82             window: 0,
83             connection: ptr::null_mut(),
84             _non_exhaustive_do_not_use: crate::seal::Seal,
85         }
86     }
87 }
88 
89 impl WaylandHandle {
empty() -> WaylandHandle90     pub fn empty() -> WaylandHandle {
91         #[allow(deprecated)]
92         WaylandHandle {
93             surface: ptr::null_mut(),
94             display: ptr::null_mut(),
95             _non_exhaustive_do_not_use: crate::seal::Seal,
96         }
97     }
98 }
99