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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
|
use core::ffi::c_void;
use core::ptr;
use cty::{c_int, c_ulong};
/// Raw display handle for Xlib.
///
/// ## Construction
/// ```
/// # use raw_window_handle::XlibDisplayHandle;
/// let display_handle = XlibDisplayHandle::empty();
/// /* set fields */
/// ```
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct XlibDisplayHandle {
/// A pointer to an Xlib `Display`.
pub display: *mut c_void,
/// An X11 screen to use with this display handle.
///
/// Note, that X11 could have multiple screens, however
/// graphics APIs could work only with one screen at the time,
/// given that multiple screens usually reside on different GPUs.
pub screen: c_int,
}
/// Raw window handle for Xlib.
///
/// ## Construction
/// ```
/// # use raw_window_handle::XlibWindowHandle;
/// let window_handle = XlibWindowHandle::empty();
/// /* set fields */
/// ```
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct XlibWindowHandle {
/// An Xlib `Window`.
pub window: c_ulong,
/// An Xlib visual ID, or 0 if unknown.
pub visual_id: c_ulong,
}
/// Raw display handle for Xcb.
///
/// ## Construction
/// ```
/// # use raw_window_handle::XcbDisplayHandle;
/// let display_handle = XcbDisplayHandle::empty();
/// /* set fields */
/// ```
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct XcbDisplayHandle {
/// A pointer to an X server `xcb_connection_t`.
pub connection: *mut c_void,
/// An X11 screen to use with this display handle.
///
/// Note, that X11 could have multiple screens, however
/// graphics APIs could work only with one screen at the time,
/// given that multiple screens usually reside on different GPUs.
pub screen: c_int,
}
/// Raw window handle for Xcb.
///
/// ## Construction
/// ```
/// # use raw_window_handle::XcbWindowHandle;
/// let window_handle = XcbWindowHandle::empty();
/// /* set fields */
/// ```
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct XcbWindowHandle {
/// An X11 `xcb_window_t`.
pub window: u32, // Based on xproto.h
/// An X11 `xcb_visualid_t`, or 0 if unknown.
pub visual_id: u32,
}
/// Raw display handle for Wayland.
///
/// ## Construction
/// ```
/// # use raw_window_handle::WaylandDisplayHandle;
/// let display_handle = WaylandDisplayHandle::empty();
/// /* set fields */
/// ```
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct WaylandDisplayHandle {
/// A pointer to a `wl_display`.
pub display: *mut c_void,
}
/// Raw window handle for Wayland.
///
/// ## Construction
/// ```
/// # use raw_window_handle::WaylandWindowHandle;
/// let window_handle = WaylandWindowHandle::empty();
/// /* set fields */
/// ```
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct WaylandWindowHandle {
/// A pointer to a `wl_surface`.
pub surface: *mut c_void,
}
/// Raw display handle for the Linux Kernel Mode Set/Direct Rendering Manager.
///
/// ## Construction
/// ```
/// # use raw_window_handle::DrmDisplayHandle;
/// let display_handle = DrmDisplayHandle::empty();
/// /* set fields */
/// ```
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct DrmDisplayHandle {
/// The drm file descriptor.
pub fd: i32,
}
/// Raw window handle for the Linux Kernel Mode Set/Direct Rendering Manager.
///
/// ## Construction
/// ```
/// # use raw_window_handle::DrmWindowHandle;
/// let handle = DrmWindowHandle::empty();
/// /* set fields */
/// ```
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct DrmWindowHandle {
/// The primary drm plane handle.
pub plane: u32,
}
/// Raw display handle for the Linux Generic Buffer Manager.
///
/// ## Construction
/// ```
/// # use raw_window_handle::GbmDisplayHandle;
/// let display_handle = GbmDisplayHandle::empty();
/// /* set fields */
/// ```
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct GbmDisplayHandle {
/// The gbm device.
pub gbm_device: *mut c_void,
}
/// Raw window handle for the Linux Generic Buffer Manager.
///
/// ## Construction
/// ```
/// # use raw_window_handle::GbmWindowHandle;
/// let handle = GbmWindowHandle::empty();
/// /* set fields */
/// ```
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct GbmWindowHandle {
/// The gbm surface.
pub gbm_surface: *mut c_void,
}
impl XlibDisplayHandle {
pub fn empty() -> Self {
Self {
display: ptr::null_mut(),
screen: 0,
}
}
}
impl XlibWindowHandle {
pub fn empty() -> Self {
Self {
window: 0,
visual_id: 0,
}
}
}
impl XcbDisplayHandle {
pub fn empty() -> Self {
Self {
connection: ptr::null_mut(),
screen: 0,
}
}
}
impl XcbWindowHandle {
pub fn empty() -> Self {
Self {
window: 0,
visual_id: 0,
}
}
}
impl WaylandDisplayHandle {
pub fn empty() -> Self {
Self {
display: ptr::null_mut(),
}
}
}
impl WaylandWindowHandle {
pub fn empty() -> Self {
Self {
surface: ptr::null_mut(),
}
}
}
impl DrmDisplayHandle {
pub fn empty() -> Self {
Self { fd: 0 }
}
}
impl DrmWindowHandle {
pub fn empty() -> Self {
Self { plane: 0 }
}
}
impl GbmDisplayHandle {
pub fn empty() -> Self {
Self {
gbm_device: ptr::null_mut(),
}
}
}
impl GbmWindowHandle {
pub fn empty() -> Self {
Self {
gbm_surface: ptr::null_mut(),
}
}
}
|