summaryrefslogtreecommitdiffstats
path: root/third_party/rust/raw-window-handle
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /third_party/rust/raw-window-handle
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/raw-window-handle')
-rw-r--r--third_party/rust/raw-window-handle/.cargo-checksum.json1
-rw-r--r--third_party/rust/raw-window-handle/CHANGELOG.md81
-rw-r--r--third_party/rust/raw-window-handle/Cargo.toml41
-rw-r--r--third_party/rust/raw-window-handle/LICENSE-APACHE.md177
-rw-r--r--third_party/rust/raw-window-handle/LICENSE-MIT.md21
-rw-r--r--third_party/rust/raw-window-handle/LICENSE-ZLIB.md11
-rw-r--r--third_party/rust/raw-window-handle/README.md9
-rw-r--r--third_party/rust/raw-window-handle/appveyor.yml22
-rw-r--r--third_party/rust/raw-window-handle/rustfmt.toml1
-rw-r--r--third_party/rust/raw-window-handle/src/android.rs43
-rw-r--r--third_party/rust/raw-window-handle/src/appkit.rs47
-rw-r--r--third_party/rust/raw-window-handle/src/haiku.rs46
-rw-r--r--third_party/rust/raw-window-handle/src/lib.rs307
-rw-r--r--third_party/rust/raw-window-handle/src/redox.rs43
-rw-r--r--third_party/rust/raw-window-handle/src/uikit.rs49
-rw-r--r--third_party/rust/raw-window-handle/src/unix.rs252
-rw-r--r--third_party/rust/raw-window-handle/src/web.rs45
-rw-r--r--third_party/rust/raw-window-handle/src/windows.rs71
18 files changed, 1267 insertions, 0 deletions
diff --git a/third_party/rust/raw-window-handle/.cargo-checksum.json b/third_party/rust/raw-window-handle/.cargo-checksum.json
new file mode 100644
index 0000000000..8bb6dad8fe
--- /dev/null
+++ b/third_party/rust/raw-window-handle/.cargo-checksum.json
@@ -0,0 +1 @@
+{"files":{"CHANGELOG.md":"4486ee3b55928e04f7afd8b7d185bad27195d014f5f9012ff56ca85597151d32","Cargo.toml":"04e23c62331ec0f425a98e3fd8a7218e18a35a62c83dd22a805ba78dfb34c519","LICENSE-APACHE.md":"0d542e0c8804e39aa7f37eb00da5a762149dc682d7829451287e11b938e94594","LICENSE-MIT.md":"9c5a80639a57c1c945570e7ebbca0706305849ce3c098021325cca9db2f7acc4","LICENSE-ZLIB.md":"ae895c8576e682f310fb70d93d9f99b1dd82872094c54a8f6cdfe2ca5c2d6ecb","README.md":"70ed92ecf84818c86cbbc49edaad1d359ae66fdcacaba7ecfb909b64810f65da","appveyor.yml":"8d80a816ac9c301e7b91ff6797c1279462215b0b02169c0c0ceede261f788dca","rustfmt.toml":"a60f9a6656083027a16746999197d72aa6fd7f906969597cb99ce162177f1700","src/android.rs":"ab71aac13da241d1fce139128ae0d6fc387241fdf6342a96656324ddf607e95a","src/appkit.rs":"32e168a0f0dda5564f2ef5c06da900faafaa32bf72da3cdcf4798f7f2221749f","src/haiku.rs":"a5af3a00b1ecba13a774271790756398017e35375a65be1942d8d50cb8a22ce3","src/lib.rs":"df243a3b0a0b6efd9022d57f28dc09c3fc81a03766db96e72728a36202ad9c4b","src/redox.rs":"7b1ad8f7ac8c098360b7536b753834817c7b985aa06f6336c950a3e48c7ddc12","src/uikit.rs":"e4ab89caaae6ab778ec82f7b8b17411372444d4dceb246c4303f3ddfca79e44e","src/unix.rs":"dbb4fdf304d2f1abd14480fcd8fe14c5c821501ef6973940f3406ba47c7b60d2","src/web.rs":"601f1f390f4f7155d3dc2c505c7851a919d5152839c93a983649a30ea1e68607","src/windows.rs":"ce5f0438875fcc0f8c6db95ceaf4cbea4d95c268fe92e82d92e3b7c913fe83d0"},"package":"ed7e3d950b66e19e0c372f3fa3fbbcf85b1746b571f74e0c2af6042a5c93420a"} \ No newline at end of file
diff --git a/third_party/rust/raw-window-handle/CHANGELOG.md b/third_party/rust/raw-window-handle/CHANGELOG.md
new file mode 100644
index 0000000000..4427f18b7c
--- /dev/null
+++ b/third_party/rust/raw-window-handle/CHANGELOG.md
@@ -0,0 +1,81 @@
+# Changelog
+
+## 0.5.0 (2022-07-14)
+
+* **Breaking:** The `RawWindowHandle` variants were split into `RawDisplayHandle` and `RawWindowHandle`.
+* The X11 screen is now present in new `XlibDisplayHandle` and `XcbDisplayHandle`.
+- Add GBM support.
+
+## 0.4.3 (2022-03-29)
+
+* [Add visual IDs to X11 handles](https://github.com/rust-windowing/raw-window-handle/pull/83)
+* [Add a link to the MDN page for data attributes in the documentation for WebHandle](https://github.com/rust-windowing/raw-window-handle/pull/86)
+* [add haiku support](https://github.com/rust-windowing/raw-window-handle/pull/88)
+
+## 0.4.2 (2021-11-24)
+
+* Also implement `HasRawWindowHandle` for `Rc<T>`, and `Arc<T>` where `T: ?Sized`.
+
+## 0.4.1 (2021-11-19)
+
+* Added an impl of `HasRawWindowHandle` for `&T`, `Rc<T>`, and `Arc<T>`. The impls for `Rc<T>` and `Arc<T>` require the `alloc` feature.
+
+## 0.4.0 (2021-11-15)
+
+* **Breaking:** Remove `_do_not_use` tags to use `#[non_exhaustive]` macro
+* **Breaking:** `RawWindowHandle` variants are no longer cfg-guarded by platform.
+* **Breaking:** Rename `IOS` to `UiKit`.
+* **Breaking:** Rename `MacOS` to `AppKit`.
+* **Breaking:** Rename `Windows` to `Win32`.
+* **Breaking:** Rename `Redox` to `Orbital`.
+* **Breaking:** Rename `Android` to `AndroidNdk`.
+* **Breaking:** Inner window handle structs are now exported at crate root.
+* Added Windows `WinRt` handle.
+
+# 0.3.4 (2021-11-27)
+
+* Add `HasRawWindowHandle` implementation for `HasRawWindowHandle` in the
+ newer `v0.4`.
+ This allows "provider" crates that implement `HasRawWindowHandle` (like
+ `winit`, `sdl2`, `glfw`, `fltk`, ...) to upgrade to `v0.4` without a
+ breaking change.
+ Afterwards "consumer" crates (like `gfx`, `wgpu`, `rfd`, ...) can start
+ upgrading with minimal breakage for their users.
+
+## 0.3.3 (2019-12-1)
+
+* Add missing `Hash` implementation for `AndroidHandle`.
+
+## 0.3.2 (2019-11-29)
+
+* Add `Hash` implementation for `RawWindowHandle`.
+
+## 0.3.1 (2019-10-27)
+
+* Remove `RawWindowHandle`'s `HasRawWindowHandle` implementation, as it was unsound (see [#35](https://github.com/rust-windowing/raw-window-handle/issues/35))
+* Explicitly require that handles within `RawWindowHandle` be valid for the lifetime of the `HasRawWindowHandle` implementation that provided them.
+
+## 0.3.0 (2019-10-5)
+
+* **Breaking:** Rename `XLib.surface` to `XLib.window`, as that more accurately represents the underlying type.
+* Implement `HasRawWindowHandle` for `RawWindowHandle`
+* Add `HINSTANCE` field to `WindowsHandle`.
+
+## 0.2.0 (2019-09-26)
+
+* **Breaking:** Rename `X11` to `XLib`.
+* Add XCB support.
+* Add Web support.
+* Add Android support.
+
+## 0.1.2 (2019-08-13)
+
+* Fix use of private `_non_exhaustive` field in platform handle structs preventing structs from getting initialized.
+
+## 0.1.1 (2019-08-13)
+
+* Flesh out Cargo.toml, adding crates.io info rendering tags.
+
+## 0.1.0 (2019-08-13)
+
+* Initial release.
diff --git a/third_party/rust/raw-window-handle/Cargo.toml b/third_party/rust/raw-window-handle/Cargo.toml
new file mode 100644
index 0000000000..9f742197e3
--- /dev/null
+++ b/third_party/rust/raw-window-handle/Cargo.toml
@@ -0,0 +1,41 @@
+# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
+#
+# When uploading crates to the registry Cargo will automatically
+# "normalize" Cargo.toml files for maximal compatibility
+# with all versions of Cargo and also rewrite `path` dependencies
+# to registry (e.g., crates.io) dependencies.
+#
+# If you are reading this file be aware that the original Cargo.toml
+# will likely look very different (and much more reasonable).
+# See Cargo.toml.orig for the original contents.
+
+[package]
+edition = "2018"
+name = "raw-window-handle"
+version = "0.5.0"
+authors = ["Osspial <osspial@gmail.com>"]
+description = "Interoperability library for Rust Windowing applications."
+documentation = "https://docs.rs/raw-window-handle"
+readme = "README.md"
+keywords = ["windowing"]
+license = "MIT OR Apache-2.0 OR Zlib"
+repository = "https://github.com/rust-windowing/raw-window-handle"
+
+[package.metadata.docs.rs]
+all-features = true
+rustdoc-args = [
+ "--cfg",
+ "docsrs",
+]
+
+[dependencies.cty]
+version = "0.2"
+
+[features]
+alloc = []
+
+[badges.appveyor]
+repository = "rust-windowing/raw-window-handle"
+
+[badges.travis-ci]
+repository = "rust-windowing/raw-window-handle"
diff --git a/third_party/rust/raw-window-handle/LICENSE-APACHE.md b/third_party/rust/raw-window-handle/LICENSE-APACHE.md
new file mode 100644
index 0000000000..f433b1a53f
--- /dev/null
+++ b/third_party/rust/raw-window-handle/LICENSE-APACHE.md
@@ -0,0 +1,177 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
diff --git a/third_party/rust/raw-window-handle/LICENSE-MIT.md b/third_party/rust/raw-window-handle/LICENSE-MIT.md
new file mode 100644
index 0000000000..be95e0b866
--- /dev/null
+++ b/third_party/rust/raw-window-handle/LICENSE-MIT.md
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2019 Osspial
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/third_party/rust/raw-window-handle/LICENSE-ZLIB.md b/third_party/rust/raw-window-handle/LICENSE-ZLIB.md
new file mode 100644
index 0000000000..f389031172
--- /dev/null
+++ b/third_party/rust/raw-window-handle/LICENSE-ZLIB.md
@@ -0,0 +1,11 @@
+Copyright (c) 2020 Osspial
+
+This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+
+3. This notice may not be removed or altered from any source distribution.
diff --git a/third_party/rust/raw-window-handle/README.md b/third_party/rust/raw-window-handle/README.md
new file mode 100644
index 0000000000..d26c4db655
--- /dev/null
+++ b/third_party/rust/raw-window-handle/README.md
@@ -0,0 +1,9 @@
+# `raw-window-handle`: A common windowing interoperability library for Rust
+[![Crates.io](https://img.shields.io/crates/v/raw-window-handle.svg?maxAge=2592000)](https://crates.io/crates/raw-window-handle)
+[![Docs](https://docs.rs/raw-window-handle/badge.svg)](https://docs.rs/raw-window-handle)
+
+This library provides standard types for accessing a window's platform-specific
+raw window handle and display's platform-specific raw display handle. This does
+not provide any utilities for creating and managing windows; instead, it
+provides a common interface that window creation libraries (e.g. Winit, SDL)
+can use to easily talk with graphics libraries (e.g. gfx-hal).
diff --git a/third_party/rust/raw-window-handle/appveyor.yml b/third_party/rust/raw-window-handle/appveyor.yml
new file mode 100644
index 0000000000..050795b4c3
--- /dev/null
+++ b/third_party/rust/raw-window-handle/appveyor.yml
@@ -0,0 +1,22 @@
+environment:
+ matrix:
+ - TARGET: x86_64-pc-windows-msvc
+ CHANNEL: nightly
+ - TARGET: x86_64-pc-windows-msvc
+ CHANNEL: stable
+ - TARGET: i686-pc-windows-msvc
+ CHANNEL: nightly
+ - TARGET: i686-pc-windows-gnu
+ CHANNEL: nightly
+install:
+ - appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
+ - rustup-init -yv --default-toolchain %CHANNEL% --default-host %TARGET%
+ - SET PATH=%PATH%;%USERPROFILE%\.cargo\bin
+ - SET PATH=%PATH%;C:\MinGW\bin
+ - rustc -V
+ - cargo -V
+
+build: false
+
+test_script:
+ - cargo test --verbose
diff --git a/third_party/rust/raw-window-handle/rustfmt.toml b/third_party/rust/raw-window-handle/rustfmt.toml
new file mode 100644
index 0000000000..34503e88e1
--- /dev/null
+++ b/third_party/rust/raw-window-handle/rustfmt.toml
@@ -0,0 +1 @@
+use_field_init_shorthand=true
diff --git a/third_party/rust/raw-window-handle/src/android.rs b/third_party/rust/raw-window-handle/src/android.rs
new file mode 100644
index 0000000000..e4504cebf2
--- /dev/null
+++ b/third_party/rust/raw-window-handle/src/android.rs
@@ -0,0 +1,43 @@
+use core::ffi::c_void;
+use core::ptr;
+
+/// Raw display handle for Android.
+///
+/// ## Construction
+/// ```
+/// # use raw_window_handle::AndroidDisplayHandle;
+/// let mut display_handle = AndroidDisplayHandle::empty();
+/// /* set fields */
+/// ```
+#[non_exhaustive]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
+pub struct AndroidDisplayHandle;
+
+impl AndroidDisplayHandle {
+ pub fn empty() -> Self {
+ Self {}
+ }
+}
+
+/// Raw window handle for Android NDK.
+///
+/// ## Construction
+/// ```
+/// # use raw_window_handle::AndroidNdkWindowHandle;
+/// let mut window_handle = AndroidNdkWindowHandle::empty();
+/// /* set fields */
+/// ```
+#[non_exhaustive]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
+pub struct AndroidNdkWindowHandle {
+ /// A pointer to an `ANativeWindow`.
+ pub a_native_window: *mut c_void,
+}
+
+impl AndroidNdkWindowHandle {
+ pub fn empty() -> Self {
+ Self {
+ a_native_window: ptr::null_mut(),
+ }
+ }
+}
diff --git a/third_party/rust/raw-window-handle/src/appkit.rs b/third_party/rust/raw-window-handle/src/appkit.rs
new file mode 100644
index 0000000000..1023aa038b
--- /dev/null
+++ b/third_party/rust/raw-window-handle/src/appkit.rs
@@ -0,0 +1,47 @@
+use core::ffi::c_void;
+use core::ptr;
+
+/// Raw display handle for AppKit.
+///
+/// ## Construction
+/// ```
+/// # use raw_window_handle::AppKitDisplayHandle;
+/// let mut display_handle = AppKitDisplayHandle::empty();
+/// /* set fields */
+/// ```
+#[non_exhaustive]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
+pub struct AppKitDisplayHandle;
+
+impl AppKitDisplayHandle {
+ pub fn empty() -> Self {
+ Self {}
+ }
+}
+
+/// Raw window handle for AppKit.
+///
+/// ## Construction
+/// ```
+/// # use raw_window_handle::AppKitWindowHandle;
+/// let mut window_handle = AppKitWindowHandle::empty();
+/// /* set fields */
+/// ```
+#[non_exhaustive]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
+pub struct AppKitWindowHandle {
+ /// A pointer to an `NSWindow` object.
+ pub ns_window: *mut c_void,
+ /// A pointer to an `NSView` object.
+ pub ns_view: *mut c_void,
+ // TODO: WHAT ABOUT ns_window_controller and ns_view_controller?
+}
+
+impl AppKitWindowHandle {
+ pub fn empty() -> Self {
+ Self {
+ ns_window: ptr::null_mut(),
+ ns_view: ptr::null_mut(),
+ }
+ }
+}
diff --git a/third_party/rust/raw-window-handle/src/haiku.rs b/third_party/rust/raw-window-handle/src/haiku.rs
new file mode 100644
index 0000000000..d44e8c2017
--- /dev/null
+++ b/third_party/rust/raw-window-handle/src/haiku.rs
@@ -0,0 +1,46 @@
+use core::ffi::c_void;
+use core::ptr;
+
+/// Raw display handle for Haiku.
+///
+/// ## Construction
+/// ```
+/// # use raw_window_handle::HaikuDisplayHandle;
+/// let mut display_handle = HaikuDisplayHandle::empty();
+/// /* set fields */
+/// ```
+#[non_exhaustive]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
+pub struct HaikuDisplayHandle;
+
+impl HaikuDisplayHandle {
+ pub fn empty() -> Self {
+ Self {}
+ }
+}
+
+/// Raw window handle for Haiku.
+///
+/// ## Construction
+/// ```
+/// # use raw_window_handle::HaikuWindowHandle;
+/// let mut window_handle = HaikuWindowHandle::empty();
+/// /* set fields */
+/// ```
+#[non_exhaustive]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
+pub struct HaikuWindowHandle {
+ /// A pointer to a BWindow object
+ pub b_window: *mut c_void,
+ /// A pointer to a BDirectWindow object that might be null
+ pub b_direct_window: *mut c_void,
+}
+
+impl HaikuWindowHandle {
+ pub fn empty() -> Self {
+ Self {
+ b_window: ptr::null_mut(),
+ b_direct_window: ptr::null_mut(),
+ }
+ }
+}
diff --git a/third_party/rust/raw-window-handle/src/lib.rs b/third_party/rust/raw-window-handle/src/lib.rs
new file mode 100644
index 0000000000..01c70a5775
--- /dev/null
+++ b/third_party/rust/raw-window-handle/src/lib.rs
@@ -0,0 +1,307 @@
+#![no_std]
+#![cfg_attr(docsrs, feature(doc_cfg))]
+
+//! Interoperability library for Rust Windowing applications.
+//!
+//! This library provides standard types for accessing a window's platform-specific raw window
+//! handle and platforms display handle. This does not provide any utilities for creating and
+//! managing windows; instead, it provides a common interface that window creation libraries (e.g.
+//! Winit, SDL) can use to easily talk with graphics libraries (e.g. gfx-hal).
+//!
+//! ## Safety guarantees
+//!
+//! Please see the docs of [`HasRawWindowHandle`] and [`HasRawDisplayHandle`].
+//!
+//! ## Platform handle initialization
+//!
+//! Each platform handle struct is purposefully non-exhaustive, so that additional fields may be
+//! added without breaking backwards compatibility. Each struct provides an `empty` method that may
+//! be used along with the struct update syntax to construct it. See each specific struct for
+//! examples.
+
+#[cfg(feature = "alloc")]
+extern crate alloc;
+
+mod android;
+mod appkit;
+mod haiku;
+mod redox;
+mod uikit;
+mod unix;
+mod web;
+mod windows;
+
+pub use android::{AndroidDisplayHandle, AndroidNdkWindowHandle};
+pub use appkit::{AppKitDisplayHandle, AppKitWindowHandle};
+pub use haiku::{HaikuDisplayHandle, HaikuWindowHandle};
+pub use redox::{OrbitalDisplayHandle, OrbitalWindowHandle};
+pub use uikit::{UiKitDisplayHandle, UiKitWindowHandle};
+pub use unix::{
+ DrmDisplayHandle, DrmWindowHandle, GbmDisplayHandle, GbmWindowHandle, WaylandDisplayHandle,
+ WaylandWindowHandle, XcbDisplayHandle, XcbWindowHandle, XlibDisplayHandle, XlibWindowHandle,
+};
+pub use web::{WebDisplayHandle, WebWindowHandle};
+pub use windows::{Win32WindowHandle, WinRtWindowHandle, WindowsDisplayHandle};
+
+/// Window that wraps around a raw window handle.
+///
+/// # Safety
+///
+/// Users can safely assume that non-`null`/`0` fields are valid handles, and it is up to the
+/// implementer of this trait to ensure that condition is upheld.
+///
+/// Despite that qualification, implementers should still make a best-effort attempt to fill in all
+/// available fields. If an implementation doesn't, and a downstream user needs the field, it should
+/// try to derive the field from other fields the implementer *does* provide via whatever methods the
+/// platform provides.
+///
+/// The exact handles returned by `raw_window_handle` must remain consistent between multiple calls
+/// to `raw_window_handle` as long as not indicated otherwise by platform specific events.
+pub unsafe trait HasRawWindowHandle {
+ fn raw_window_handle(&self) -> RawWindowHandle;
+}
+
+unsafe impl<'a, T: HasRawWindowHandle + ?Sized> HasRawWindowHandle for &'a T {
+ fn raw_window_handle(&self) -> RawWindowHandle {
+ (*self).raw_window_handle()
+ }
+}
+#[cfg(feature = "alloc")]
+#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
+unsafe impl<T: HasRawWindowHandle + ?Sized> HasRawWindowHandle for alloc::rc::Rc<T> {
+ fn raw_window_handle(&self) -> RawWindowHandle {
+ (**self).raw_window_handle()
+ }
+}
+#[cfg(feature = "alloc")]
+#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
+unsafe impl<T: HasRawWindowHandle + ?Sized> HasRawWindowHandle for alloc::sync::Arc<T> {
+ fn raw_window_handle(&self) -> RawWindowHandle {
+ (**self).raw_window_handle()
+ }
+}
+
+/// An enum to simply combine the different possible raw window handle variants.
+///
+/// # Variant Availability
+///
+/// Note that all variants are present on all targets (none are disabled behind
+/// `#[cfg]`s), but see the "Availability Hints" section on each variant for
+/// some hints on where this variant might be expected.
+///
+/// Note that these "Availability Hints" are not normative. That is to say, a
+/// [`HasRawWindowHandle`] implementor is completely allowed to return something
+/// unexpected. (For example, it's legal for someone to return a
+/// [`RawWindowHandle::Xlib`] on macOS, it would just be weird, and probably
+/// requires something like XQuartz be used).
+#[non_exhaustive]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
+pub enum RawWindowHandle {
+ /// 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.
+ UiKit(UiKitWindowHandle),
+ /// 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"`.
+ AppKit(AppKitWindowHandle),
+ /// 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.
+ Orbital(OrbitalWindowHandle),
+ /// 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.
+ Xlib(XlibWindowHandle),
+ /// 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.
+ Xcb(XcbWindowHandle),
+ /// A raw window handle for Wayland.
+ ///
+ /// ## Availability Hints
+ /// This variant should be expected anywhere Wayland works, which is
+ /// currently some subset of unix systems.
+ Wayland(WaylandWindowHandle),
+ /// 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
+ Drm(DrmWindowHandle),
+ /// 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_platfrom_gbm or EGL_KHR_platfrom_gbm.
+ Gbm(GbmWindowHandle),
+ /// A raw window handle for Win32.
+ ///
+ /// ## Availability Hints
+ /// This variant is used on Windows systems.
+ Win32(Win32WindowHandle),
+ /// A raw window handle for WinRT.
+ ///
+ /// ## Availability Hints
+ /// This variant is used on Windows systems.
+ WinRt(WinRtWindowHandle),
+ /// A raw window handle for the Web.
+ ///
+ /// ## Availability Hints
+ /// This variant is used on Wasm or asm.js targets when targeting the Web/HTML5.
+ Web(WebWindowHandle),
+ /// A raw window handle for Android NDK.
+ ///
+ /// ## Availability Hints
+ /// This variant is used on Android targets.
+ AndroidNdk(AndroidNdkWindowHandle),
+ /// A raw window handle for Haiku.
+ ///
+ /// ## Availability Hints
+ /// This variant is used on HaikuOS.
+ Haiku(HaikuWindowHandle),
+}
+
+/// Display that wraps around a raw display handle.
+///
+/// # Safety
+///
+/// Users can safely assume that non-`null`/`0` fields are valid handles, and it is up to the
+/// implementer of this trait to ensure that condition is upheld.
+///
+/// Despite that qualification, implementers should still make a best-effort attempt to fill in all
+/// available fields. If an implementation doesn't, and a downstream user needs the field, it should
+/// try to derive the field from other fields the implementer *does* provide via whatever methods the
+/// platform provides.
+///
+/// The exact handles returned by `raw_display_handle` must remain consistent between multiple calls
+/// to `raw_display_handle` as long as not indicated otherwise by platform specific events.
+pub unsafe trait HasRawDisplayHandle {
+ fn raw_display_handle(&self) -> RawDisplayHandle;
+}
+
+unsafe impl<'a, T: HasRawDisplayHandle + ?Sized> HasRawDisplayHandle for &'a T {
+ fn raw_display_handle(&self) -> RawDisplayHandle {
+ (*self).raw_display_handle()
+ }
+}
+
+#[cfg(feature = "alloc")]
+#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
+unsafe impl<T: HasRawDisplayHandle + ?Sized> HasRawDisplayHandle for alloc::rc::Rc<T> {
+ fn raw_display_handle(&self) -> RawDisplayHandle {
+ (**self).raw_display_handle()
+ }
+}
+
+#[cfg(feature = "alloc")]
+#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
+unsafe impl<T: HasRawDisplayHandle + ?Sized> HasRawDisplayHandle for alloc::sync::Arc<T> {
+ fn raw_display_handle(&self) -> RawDisplayHandle {
+ (**self).raw_display_handle()
+ }
+}
+
+/// An enum to simply combine the different possible raw display handle variants.
+///
+/// # Variant Availability
+///
+/// Note that all variants are present on all targets (none are disabled behind
+/// `#[cfg]`s), but see the "Availability Hints" section on each variant for
+/// some hints on where this variant might be expected.
+///
+/// Note that these "Availability Hints" are not normative. That is to say, a
+/// [`HasRawDisplayHandle`] implementor is completely allowed to return something
+/// unexpected. (For example, it's legal for someone to return a
+/// [`RawDisplayHandle::Xlib`] on macOS, it would just be weird, and probably
+/// requires something like XQuartz be used).
+#[non_exhaustive]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
+pub enum RawDisplayHandle {
+ /// A raw display 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.
+ UiKit(UiKitDisplayHandle),
+ /// A raw display 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"`.
+ AppKit(AppKitDisplayHandle),
+ /// A raw display handle for the Redox operating system.
+ ///
+ /// ## Availability Hints
+ /// This variant is used by the Orbital Windowing System in the Redox
+ /// operating system.
+ Orbital(OrbitalDisplayHandle),
+ /// A raw display 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.
+ Xlib(XlibDisplayHandle),
+ /// A raw display 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.
+ Xcb(XcbDisplayHandle),
+ /// A raw display handle for Wayland.
+ ///
+ /// ## Availability Hints
+ /// This variant should be expected anywhere Wayland works, which is
+ /// currently some subset of unix systems.
+ Wayland(WaylandDisplayHandle),
+ /// A raw display 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
+ Drm(DrmDisplayHandle),
+ /// A raw display 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_platfrom_gbm or EGL_KHR_platfrom_gbm.
+ Gbm(GbmDisplayHandle),
+ /// A raw display handle for Win32.
+ ///
+ /// ## Availability Hints
+ /// This variant is used on Windows systems.
+ Windows(WindowsDisplayHandle),
+ /// A raw display handle for the Web.
+ ///
+ /// ## Availability Hints
+ /// This variant is used on Wasm or asm.js targets when targeting the Web/HTML5.
+ Web(WebDisplayHandle),
+ /// A raw display handle for Android NDK.
+ ///
+ /// ## Availability Hints
+ /// This variant is used on Android targets.
+ Android(AndroidDisplayHandle),
+ /// A raw display handle for Haiku.
+ ///
+ /// ## Availability Hints
+ /// This variant is used on HaikuOS.
+ Haiku(HaikuDisplayHandle),
+}
diff --git a/third_party/rust/raw-window-handle/src/redox.rs b/third_party/rust/raw-window-handle/src/redox.rs
new file mode 100644
index 0000000000..5faa98501d
--- /dev/null
+++ b/third_party/rust/raw-window-handle/src/redox.rs
@@ -0,0 +1,43 @@
+use core::ffi::c_void;
+use core::ptr;
+
+/// Raw display handle for the Redox operating system.
+///
+/// ## Construction
+/// ```
+/// # use raw_window_handle::OrbitalDisplayHandle;
+/// let mut display_handle = OrbitalDisplayHandle::empty();
+/// /* set fields */
+/// ```
+#[non_exhaustive]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
+pub struct OrbitalDisplayHandle;
+
+impl OrbitalDisplayHandle {
+ pub fn empty() -> Self {
+ Self {}
+ }
+}
+
+/// Raw window handle for the Redox operating system.
+///
+/// ## Construction
+/// ```
+/// # use raw_window_handle::OrbitalWindowHandle;
+/// let mut window_handle = OrbitalWindowHandle::empty();
+/// /* set fields */
+/// ```
+#[non_exhaustive]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
+pub struct OrbitalWindowHandle {
+ /// A pointer to an orbclient window.
+ pub window: *mut c_void,
+}
+
+impl OrbitalWindowHandle {
+ pub fn empty() -> Self {
+ Self {
+ window: ptr::null_mut(),
+ }
+ }
+}
diff --git a/third_party/rust/raw-window-handle/src/uikit.rs b/third_party/rust/raw-window-handle/src/uikit.rs
new file mode 100644
index 0000000000..bee3a9a71b
--- /dev/null
+++ b/third_party/rust/raw-window-handle/src/uikit.rs
@@ -0,0 +1,49 @@
+use core::ffi::c_void;
+use core::ptr;
+
+/// Raw display handle for UIKit.
+///
+/// ## Construction
+/// ```
+/// # use raw_window_handle::UiKitDisplayHandle;
+/// let mut display_handle = UiKitDisplayHandle::empty();
+/// /* set fields */
+/// ```
+#[non_exhaustive]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
+pub struct UiKitDisplayHandle;
+
+impl UiKitDisplayHandle {
+ pub fn empty() -> Self {
+ Self {}
+ }
+}
+
+/// Raw window handle for UIKit.
+///
+/// ## Construction
+/// ```
+/// # use raw_window_handle::UiKitWindowHandle;
+/// let mut window_handle = UiKitWindowHandle::empty();
+/// /* set fields */
+/// ```
+#[non_exhaustive]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
+pub struct UiKitWindowHandle {
+ /// A pointer to an `UIWindow` object.
+ pub ui_window: *mut c_void,
+ /// A pointer to an `UIView` object.
+ pub ui_view: *mut c_void,
+ /// A pointer to an `UIViewController` object.
+ pub ui_view_controller: *mut c_void,
+}
+
+impl UiKitWindowHandle {
+ pub fn empty() -> Self {
+ Self {
+ ui_window: ptr::null_mut(),
+ ui_view: ptr::null_mut(),
+ ui_view_controller: ptr::null_mut(),
+ }
+ }
+}
diff --git a/third_party/rust/raw-window-handle/src/unix.rs b/third_party/rust/raw-window-handle/src/unix.rs
new file mode 100644
index 0000000000..9035fc2563
--- /dev/null
+++ b/third_party/rust/raw-window-handle/src/unix.rs
@@ -0,0 +1,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(),
+ }
+ }
+}
diff --git a/third_party/rust/raw-window-handle/src/web.rs b/third_party/rust/raw-window-handle/src/web.rs
new file mode 100644
index 0000000000..1e6908ffea
--- /dev/null
+++ b/third_party/rust/raw-window-handle/src/web.rs
@@ -0,0 +1,45 @@
+/// Raw display handle for the Web.
+///
+/// ## Construction
+/// ```
+/// # use raw_window_handle::WebDisplayHandle;
+/// let mut display_handle = WebDisplayHandle::empty();
+/// /* set fields */
+/// ```
+#[non_exhaustive]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
+pub struct WebDisplayHandle;
+
+impl WebDisplayHandle {
+ pub fn empty() -> Self {
+ Self {}
+ }
+}
+
+/// Raw window handle for the Web.
+///
+/// ## Construction
+/// ```
+/// # use raw_window_handle::WebWindowHandle;
+/// let mut window_handle = WebWindowHandle::empty();
+/// /* set fields */
+/// ```
+#[non_exhaustive]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
+pub struct 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.
+ /// 0 should be reserved for invalid / null IDs.
+ ///
+ /// [data attributes]: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/data-*
+ pub id: u32,
+}
+
+impl WebWindowHandle {
+ pub fn empty() -> Self {
+ Self { id: 0 }
+ }
+}
diff --git a/third_party/rust/raw-window-handle/src/windows.rs b/third_party/rust/raw-window-handle/src/windows.rs
new file mode 100644
index 0000000000..32b1a88af7
--- /dev/null
+++ b/third_party/rust/raw-window-handle/src/windows.rs
@@ -0,0 +1,71 @@
+use core::ffi::c_void;
+use core::ptr;
+
+/// Raw display handle for Windows.
+///
+/// It could be used regardless of Windows window backend.
+///
+/// ## Construction
+/// ```
+/// # use raw_window_handle::WindowsDisplayHandle;
+/// let mut display_handle = WindowsDisplayHandle::empty();
+/// /* set fields */
+/// ```
+#[non_exhaustive]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
+pub struct WindowsDisplayHandle;
+
+impl WindowsDisplayHandle {
+ pub fn empty() -> Self {
+ Self
+ }
+}
+
+/// Raw window handle for Win32.
+///
+/// ## Construction
+/// ```
+/// # use raw_window_handle::Win32WindowHandle;
+/// let mut window_handle = Win32WindowHandle::empty();
+/// /* set fields */
+/// ```
+#[non_exhaustive]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
+pub struct Win32WindowHandle {
+ /// A Win32 `HWND` handle.
+ pub hwnd: *mut c_void,
+ /// The `HINSTANCE` associated with this type's `HWND`.
+ pub hinstance: *mut c_void,
+}
+
+impl Win32WindowHandle {
+ pub fn empty() -> Self {
+ Self {
+ hwnd: ptr::null_mut(),
+ hinstance: ptr::null_mut(),
+ }
+ }
+}
+
+/// Raw window handle for WinRT.
+///
+/// ## Construction
+/// ```
+/// # use raw_window_handle::WinRtWindowHandle;
+/// let mut window_handle = WinRtWindowHandle::empty();
+/// /* set fields */
+/// ```
+#[non_exhaustive]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
+pub struct WinRtWindowHandle {
+ /// A WinRT `CoreWindow` handle.
+ pub core_window: *mut c_void,
+}
+
+impl WinRtWindowHandle {
+ pub fn empty() -> Self {
+ Self {
+ core_window: ptr::null_mut(),
+ }
+ }
+}