raw-window-handle-ffi 0.1.1

FFI types meant to make raw-window-handle types FFI-compatible.
Documentation
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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
/* Auto-generated header by cbindgen. Do not edit directly. */

#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>

enum rwhf_Error {
  RWHF_ERROR_UNKNOWN_UNEXAUSTIVE_VARIANT,
};
typedef uint8_t rwhf_Error;

enum rwhf_RawWindowHandleKind {
  /**
   * A raw window handle for UIKit (Apple's non-macOS windowing library).
   *
   * ## Availability Hints
   * This variant is likely to be used on iOS, tvOS, (in theory) watchOS, and
   * Mac Catalyst (`$arch-apple-ios-macabi` targets, which can notably use
   * UIKit *or* AppKit), as these are the targets that (currently) support
   * UIKit.
   */
  RWHF_RAW_WINDOW_HANDLE_KIND_UI_KIT_WINDOW_HANDLE,
  /**
   * A raw window handle for AppKit.
   *
   * ## Availability Hints
   * This variant is likely to be used on macOS, although Mac Catalyst
   * (`$arch-apple-ios-macabi` targets, which can notably use UIKit *or*
   * AppKit) can also use it despite being `target_os = "ios"`.
   */
  RWHF_RAW_WINDOW_HANDLE_KIND_APP_KIT_WINDOW_HANDLE,
  /**
   * A raw window handle for the Redox operating system.
   *
   * ## Availability Hints
   * This variant is used by the Orbital Windowing System in the Redox
   * operating system.
   */
  RWHF_RAW_WINDOW_HANDLE_KIND_ORBITAL_WINDOW_HANDLE,
  /**
   * A raw window handle for the OpenHarmony OS NDK
   *
   * ## Availability Hints
   * This variant is used on OpenHarmony OS (`target_env = "ohos"`).
   */
  RWHF_RAW_WINDOW_HANDLE_KIND_OHOS_NDK_WINDOW_HANDLE,
  /**
   * A raw window handle for Xlib.
   *
   * ## Availability Hints
   * This variant is likely to show up anywhere someone manages to get X11
   * working that Xlib can be built for, which is to say, most (but not all)
   * Unix systems.
   */
  RWHF_RAW_WINDOW_HANDLE_KIND_XLIB_WINDOW_HANDLE,
  /**
   * A raw window handle for Xcb.
   *
   * ## Availability Hints
   * This variant is likely to show up anywhere someone manages to get X11
   * working that XCB can be built for, which is to say, most (but not all)
   * Unix systems.
   */
  RWHF_RAW_WINDOW_HANDLE_KIND_XCB_WINDOW_HANDLE,
  /**
   * A raw window handle for Wayland.
   *
   * ## Availability Hints
   * This variant should be expected anywhere Wayland works, which is
   * currently some subset of unix systems.
   */
  RWHF_RAW_WINDOW_HANDLE_KIND_WAYLAND_WINDOW_HANDLE,
  /**
   * A raw window handle for the Linux Kernel Mode Set/Direct Rendering Manager
   *
   * ## Availability Hints
   * This variant is used on Linux when neither X nor Wayland are available
   */
  RWHF_RAW_WINDOW_HANDLE_KIND_DRM_WINDOW_HANDLE,
  /**
   * A raw window handle for the Linux Generic Buffer Manager.
   *
   * ## Availability Hints
   * This variant is present regardless of windowing backend and likely to be used with
   * EGL_MESA_platform_gbm or EGL_KHR_platform_gbm.
   */
  RWHF_RAW_WINDOW_HANDLE_KIND_GBM_WINDOW_HANDLE,
  /**
   * A raw window handle for Win32.
   *
   * ## Availability Hints
   * This variant is used on Windows systems.
   */
  RWHF_RAW_WINDOW_HANDLE_KIND_WIN32_WINDOW_HANDLE,
  /**
   * A raw window handle for WinRT.
   *
   * ## Availability Hints
   * This variant is used on Windows systems.
   */
  RWHF_RAW_WINDOW_HANDLE_KIND_WIN_RT_WINDOW_HANDLE,
  /**
   * A raw window handle for the Web.
   *
   * ## Availability Hints
   * This variant is used on Wasm or asm.js targets when targeting the Web/HTML5.
   */
  RWHF_RAW_WINDOW_HANDLE_KIND_WEB_WINDOW_HANDLE,
  /**
   * A raw window handle for a Web canvas registered via [`wasm-bindgen`].
   *
   * ## Availability Hints
   * This variant is used on Wasm or asm.js targets when targeting the Web/HTML5.
   *
   * [`wasm-bindgen`]: https://crates.io/crates/wasm-bindgen
   */
  RWHF_RAW_WINDOW_HANDLE_KIND_WEB_CANVAS_WINDOW_HANDLE,
  /**
   * A raw window handle for a Web offscreen canvas registered via [`wasm-bindgen`].
   *
   * ## Availability Hints
   * This variant is used on Wasm or asm.js targets when targeting the Web/HTML5.
   *
   * [`wasm-bindgen`]: https://crates.io/crates/wasm-bindgen
   */
  RWHF_RAW_WINDOW_HANDLE_KIND_WEB_OFFSCREEN_CANVAS_WINDOW_HANDLE,
  /**
   * A raw window handle for Android NDK.
   *
   * ## Availability Hints
   * This variant is used on Android targets.
   */
  RWHF_RAW_WINDOW_HANDLE_KIND_ANDROID_NDK_WINDOW_HANDLE,
  /**
   * A raw window handle for Haiku.
   *
   * ## Availability Hints
   * This variant is used on HaikuOS.
   */
  RWHF_RAW_WINDOW_HANDLE_KIND_HAIKU_WINDOW_HANDLE,
};
typedef uint8_t rwhf_RawWindowHandleKind;

/**
 * raw_window_handle_ffi:
 *         This type is ABI-stable and FFI-compatible analogue for [`raw_window_handle::UiKitWindowHandle`].
 *         Can be converted to and from the referenced type.
 */
typedef struct rwhf_UiKitWindowHandle {
  /**
   * A pointer to an `UIView` object.
   */
  void *ui_view;
  /**
   * A pointer to an `UIViewController` object, if the view has one.
   */
  void *ui_view_controller;
} rwhf_UiKitWindowHandle;

/**
 * raw_window_handle_ffi:
 *         This type is ABI-stable and FFI-compatible analogue for [`raw_window_handle::WinRtWindowHandle`].
 *         Can be converted to and from the referenced type.
 */
typedef struct rwhf_WinRtWindowHandle {
  /**
   * A WinRT `CoreWindow` handle.
   */
  void *core_window;
} rwhf_WinRtWindowHandle;

/**
 * raw_window_handle_ffi:
 *         This type is ABI-stable and FFI-compatible analogue for [`raw_window_handle::HaikuWindowHandle`].
 *         Can be converted to and from the referenced type.
 */
typedef struct rwhf_HaikuWindowHandle {
  /**
   * A pointer to a BWindow object
   */
  void *b_window;
  /**
   * A pointer to a BDirectWindow object that might be null
   */
  void *b_direct_window;
} rwhf_HaikuWindowHandle;

/**
 * raw_window_handle_ffi:
 *         This type is ABI-stable and FFI-compatible analogue for [`raw_window_handle::AppKitWindowHandle`].
 *         Can be converted to and from the referenced type.
 */
typedef struct rwhf_AppKitWindowHandle {
  /**
   * A pointer to an `NSView` object.
   */
  void *ns_view;
} rwhf_AppKitWindowHandle;

/**
 * raw_window_handle_ffi:
 *         This type is ABI-stable and FFI-compatible analogue for [`raw_window_handle::OrbitalWindowHandle`].
 *         Can be converted to and from the referenced type.
 */
typedef struct rwhf_OrbitalWindowHandle {
  /**
   * A pointer to an orbclient window.
   */
  void *window;
} rwhf_OrbitalWindowHandle;

/**
 * raw_window_handle_ffi:
 *         This type is ABI-stable and FFI-compatible analogue for [`raw_window_handle::OhosNdkWindowHandle`].
 *         Can be converted to and from the referenced type.
 *
 * Raw window handle for Ohos NDK.
 */
typedef struct rwhf_OhosNdkWindowHandle {
  void *native_window;
} rwhf_OhosNdkWindowHandle;

/**
 * raw_window_handle_ffi:
 *         This type is ABI-stable and FFI-compatible analogue for [`raw_window_handle::XlibWindowHandle`].
 *         Can be converted to and from the referenced type.
 */
typedef struct rwhf_XlibWindowHandle {
  /**
   * An Xlib `Window`.
   */
  unsigned long window;
  /**
   * An Xlib visual ID, or 0 if unknown.
   */
  unsigned long visual_id;
} rwhf_XlibWindowHandle;

/**
 * raw_window_handle_ffi:
 *         This type is ABI-stable and FFI-compatible analogue for [`raw_window_handle::XcbWindowHandle`].
 *         Can be converted to and from the referenced type.
 */
typedef struct rwhf_XcbWindowHandle {
  /**
   * An X11 `xcb_window_t`.
   */
  uint32_t window;
  /**
   * An X11 `xcb_visualid_t`.
   */
  uint32_t visual_id;
} rwhf_XcbWindowHandle;

/**
 * raw_window_handle_ffi:
 *         This type is ABI-stable and FFI-compatible analogue for [`raw_window_handle::WaylandWindowHandle`].
 *         Can be converted to and from the referenced type.
 */
typedef struct rwhf_WaylandWindowHandle {
  /**
   * A pointer to a `wl_surface`.
   */
  void *surface;
} rwhf_WaylandWindowHandle;

/**
 * raw_window_handle_ffi:
 *         This type is ABI-stable and FFI-compatible analogue for [`raw_window_handle::DrmWindowHandle`].
 *         Can be converted to and from the referenced type.
 */
typedef struct rwhf_DrmWindowHandle {
  /**
   * The primary drm plane handle.
   */
  uint32_t plane;
} rwhf_DrmWindowHandle;

/**
 * raw_window_handle_ffi:
 *         This type is ABI-stable and FFI-compatible analogue for [`raw_window_handle::GbmWindowHandle`].
 *         Can be converted to and from the referenced type.
 */
typedef struct rwhf_GbmWindowHandle {
  /**
   * The gbm surface.
   */
  void *gbm_surface;
} rwhf_GbmWindowHandle;

/**
 * raw_window_handle_ffi:
 *         This type is ABI-stable and FFI-compatible analogue for [`raw_window_handle::Win32WindowHandle`].
 *         Can be converted to and from the referenced type.
 */
typedef struct rwhf_Win32WindowHandle {
  /**
   * A Win32 `HWND` handle.
   */
  intptr_t hwnd;
  /**
   * The `GWLP_HINSTANCE` associated with this type's `HWND`.
   */
  intptr_t hinstance;
} rwhf_Win32WindowHandle;

/**
 * raw_window_handle_ffi:
 *         This type is ABI-stable and FFI-compatible analogue for [`raw_window_handle::WebWindowHandle`].
 *         Can be converted to and from the referenced type.
 */
typedef struct rwhf_WebWindowHandle {
  /**
   * An ID value inserted into the [data attributes] of the canvas element as '`raw-handle`'.
   *
   * When accessing from JS, the attribute will automatically be called `rawHandle`.
   *
   * Each canvas created by the windowing system should be assigned their own unique ID.
   *
   * [data attributes]: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/data-*
   */
  uint32_t id;
} rwhf_WebWindowHandle;

/**
 * raw_window_handle_ffi:
 *         This type is ABI-stable and FFI-compatible analogue for [`raw_window_handle::WebCanvasWindowHandle`].
 *         Can be converted to and from the referenced type.
 */
typedef struct rwhf_WebCanvasWindowHandle {
  /**
   * A pointer to the [`JsValue`] of an [`HtmlCanvasElement`].
   *
   * Note: This uses [`c_void`] to avoid depending on `wasm-bindgen`
   * directly.
   *
   * [`JsValue`]: https://docs.rs/wasm-bindgen/latest/wasm_bindgen/struct.JsValue.html
   * [`HtmlCanvasElement`]: https://docs.rs/web-sys/latest/web_sys/struct.HtmlCanvasElement.html
   */
  void *obj;
} rwhf_WebCanvasWindowHandle;

/**
 * raw_window_handle_ffi:
 *         This type is ABI-stable and FFI-compatible analogue for [`raw_window_handle::WebOffscreenCanvasWindowHandle`].
 *         Can be converted to and from the referenced type.
 */
typedef struct rwhf_WebOffscreenCanvasWindowHandle {
  /**
   * A pointer to the [`JsValue`] of an [`OffscreenCanvas`].
   *
   * Note: This uses [`c_void`] to avoid depending on `wasm-bindgen`
   * directly.
   *
   * [`JsValue`]: https://docs.rs/wasm-bindgen/latest/wasm_bindgen/struct.JsValue.html
   * [`OffscreenCanvas`]: https://docs.rs/web-sys/latest/web_sys/struct.OffscreenCanvas.html
   */
  void *obj;
} rwhf_WebOffscreenCanvasWindowHandle;

/**
 * raw_window_handle_ffi:
 *         This type is ABI-stable and FFI-compatible analogue for [`raw_window_handle::AndroidNdkWindowHandle`].
 *         Can be converted to and from the referenced type.
 */
typedef struct rwhf_AndroidNdkWindowHandle {
  /**
   * A pointer to an `ANativeWindow`.
   */
  void *a_native_window;
} rwhf_AndroidNdkWindowHandle;

typedef union rwhf_RawWindowHandleData {
  /**
   * A raw window handle for UIKit (Apple's non-macOS windowing library).
   *
   * ## Availability Hints
   * This variant is likely to be used on iOS, tvOS, (in theory) watchOS, and
   * Mac Catalyst (`$arch-apple-ios-macabi` targets, which can notably use
   * UIKit *or* AppKit), as these are the targets that (currently) support
   * UIKit.
   */
  struct rwhf_UiKitWindowHandle ui_kit;
  /**
   * A raw window handle for AppKit.
   *
   * ## Availability Hints
   * This variant is likely to be used on macOS, although Mac Catalyst
   * (`$arch-apple-ios-macabi` targets, which can notably use UIKit *or*
   * AppKit) can also use it despite being `target_os = "ios"`.
   */
  struct rwhf_AppKitWindowHandle app_kit;
  /**
   * A raw window handle for the Redox operating system.
   *
   * ## Availability Hints
   * This variant is used by the Orbital Windowing System in the Redox
   * operating system.
   */
  struct rwhf_OrbitalWindowHandle orbital;
  /**
   * A raw window handle for the OpenHarmony OS NDK
   *
   * ## Availability Hints
   * This variant is used on OpenHarmony OS (`target_env = "ohos"`).
   */
  struct rwhf_OhosNdkWindowHandle ohos_ndk;
  /**
   * A raw window handle for Xlib.
   *
   * ## Availability Hints
   * This variant is likely to show up anywhere someone manages to get X11
   * working that Xlib can be built for, which is to say, most (but not all)
   * Unix systems.
   */
  struct rwhf_XlibWindowHandle xlib;
  /**
   * A raw window handle for Xcb.
   *
   * ## Availability Hints
   * This variant is likely to show up anywhere someone manages to get X11
   * working that XCB can be built for, which is to say, most (but not all)
   * Unix systems.
   */
  struct rwhf_XcbWindowHandle xcb;
  /**
   * A raw window handle for Wayland.
   *
   * ## Availability Hints
   * This variant should be expected anywhere Wayland works, which is
   * currently some subset of unix systems.
   */
  struct rwhf_WaylandWindowHandle wayland;
  /**
   * A raw window handle for the Linux Kernel Mode Set/Direct Rendering Manager
   *
   * ## Availability Hints
   * This variant is used on Linux when neither X nor Wayland are available
   */
  struct rwhf_DrmWindowHandle drm;
  /**
   * A raw window handle for the Linux Generic Buffer Manager.
   *
   * ## Availability Hints
   * This variant is present regardless of windowing backend and likely to be used with
   * EGL_MESA_platform_gbm or EGL_KHR_platform_gbm.
   */
  struct rwhf_GbmWindowHandle gbm;
  /**
   * A raw window handle for Win32.
   *
   * ## Availability Hints
   * This variant is used on Windows systems.
   */
  struct rwhf_Win32WindowHandle win32;
  /**
   * A raw window handle for WinRT.
   *
   * ## Availability Hints
   * This variant is used on Windows systems.
   */
  struct rwhf_WinRtWindowHandle win_rt;
  /**
   * A raw window handle for the Web.
   *
   * ## Availability Hints
   * This variant is used on Wasm or asm.js targets when targeting the Web/HTML5.
   */
  struct rwhf_WebWindowHandle web;
  /**
   * A raw window handle for a Web canvas registered via [`wasm-bindgen`].
   *
   * ## Availability Hints
   * This variant is used on Wasm or asm.js targets when targeting the Web/HTML5.
   *
   * [`wasm-bindgen`]: https://crates.io/crates/wasm-bindgen
   */
  struct rwhf_WebCanvasWindowHandle web_canvas;
  /**
   * A raw window handle for a Web offscreen canvas registered via [`wasm-bindgen`].
   *
   * ## Availability Hints
   * This variant is used on Wasm or asm.js targets when targeting the Web/HTML5.
   *
   * [`wasm-bindgen`]: https://crates.io/crates/wasm-bindgen
   */
  struct rwhf_WebOffscreenCanvasWindowHandle web_offscreen_canvas;
  /**
   * A raw window handle for Android NDK.
   *
   * ## Availability Hints
   * This variant is used on Android targets.
   */
  struct rwhf_AndroidNdkWindowHandle android_ndk;
  /**
   * A raw window handle for Haiku.
   *
   * ## Availability Hints
   * This variant is used on HaikuOS.
   */
  struct rwhf_HaikuWindowHandle haiku;
} rwhf_RawWindowHandleData;

typedef struct rwhf_RawWindowHandle {
  rwhf_RawWindowHandleKind kind;
  union rwhf_RawWindowHandleData data;
} rwhf_RawWindowHandle;