From 653bc5981393b5c06ae732f8838774fb00a68335 Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Thu, 21 Jul 2022 22:22:36 +0300 Subject: [PATCH] Update raw-window-handle to v0.5.0 This updates raw-window-handle to v0.5.0. --- CHANGELOG.md | 1 + Cargo.toml | 6 +++--- src/event_loop.rs | 8 +++++++ src/lib.rs | 7 ++++--- src/platform_impl/android/mod.rs | 12 ++++++++++- src/platform_impl/ios/event_loop.rs | 6 ++++++ src/platform_impl/ios/window.rs | 16 ++++++++------ src/platform_impl/linux/mod.rs | 19 ++++++++++------- .../linux/wayland/event_loop/mod.rs | 10 +++++++++ src/platform_impl/linux/wayland/window/mod.rs | 20 ++++++++++++------ src/platform_impl/linux/x11/mod.rs | 9 ++++++++ src/platform_impl/linux/x11/window.rs | 21 ++++++++++++------- src/platform_impl/macos/event_loop.rs | 6 ++++++ src/platform_impl/macos/window.rs | 18 +++++++++++----- .../web/event_loop/window_target.rs | 15 +++++++++---- src/platform_impl/web/window.rs | 13 ++++++++---- src/platform_impl/windows/event_loop.rs | 10 +++++++-- src/platform_impl/windows/window.rs | 17 ++++++++++----- src/window.rs | 19 ++++++++++++++--- 19 files changed, 177 insertions(+), 56 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e412377..0a024d78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -72,6 +72,7 @@ And please only add new entries to the top of this list, right below the `# Unre - **Breaking**, Replaced `VideoMode::refresh_rate` with `VideoMode::refresh_rate_millihertz` providing better precision. - On Web, add `with_prevent_default` and `with_focusable` to `WindowBuilderExtWebSys` to control whether events should be propagated. - On Windows, fix focus events being sent to inactive windows. +- **Breaking**, update `raw-window-handle` to `v0.5` and implement `HasRawDisplayHandle` for `Window` and `EventLoopWindowTarget`. # 0.26.1 (2022-01-05) diff --git a/Cargo.toml b/Cargo.toml index 71719924..0458e180 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,7 +45,7 @@ instant = { version = "0.1", features = ["wasm-bindgen"] } once_cell = "1.12" log = "0.4" serde = { version = "1", optional = true, features = ["serde_derive"] } -raw-window-handle = "0.4.2" +raw-window-handle = "0.5.0" bitflags = "1" mint = { version = "0.5.6", optional = true } @@ -55,8 +55,8 @@ simple_logger = "2.1.0" [target.'cfg(target_os = "android")'.dependencies] # Coordinate the next winit release with android-ndk-rs: https://github.com/rust-windowing/winit/issues/1995 -ndk = { git = "https://github.com/rust-windowing/android-ndk-rs", rev = "a0c5e99" } -ndk-glue = { git = "https://github.com/rust-windowing/android-ndk-rs", rev = "a0c5e99" } +ndk = { git = "https://github.com/rust-windowing/android-ndk-rs", rev = "814be08" } +ndk-glue = { git = "https://github.com/rust-windowing/android-ndk-rs", rev = "814be08" } [target.'cfg(any(target_os = "ios", target_os = "macos"))'.dependencies] objc = "0.2.7" diff --git a/src/event_loop.rs b/src/event_loop.rs index 6b5e054e..b96c80c9 100644 --- a/src/event_loop.rs +++ b/src/event_loop.rs @@ -13,6 +13,7 @@ use std::{error, fmt}; use instant::Instant; use once_cell::sync::OnceCell; +use raw_window_handle::{HasRawDisplayHandle, RawDisplayHandle}; use crate::{event::Event, monitor::MonitorHandle, platform_impl}; @@ -337,6 +338,13 @@ impl EventLoopWindowTarget { } } +unsafe impl HasRawDisplayHandle for EventLoopWindowTarget { + /// Returns a [`raw_window_handle::RawDisplayHandle`] for the event loop. + fn raw_display_handle(&self) -> RawDisplayHandle { + self.p.raw_display_handle() + } +} + /// Used to send custom events to [`EventLoop`]. pub struct EventLoopProxy { event_loop_proxy: platform_impl::EventLoopProxy, diff --git a/src/lib.rs b/src/lib.rs index 3b519f00..4871bb3c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -98,9 +98,9 @@ //! # Drawing on the window //! //! Winit doesn't directly provide any methods for drawing on a [`Window`]. However it allows you to -//! retrieve the raw handle of the window (see the [`platform`] module and/or the -//! [`raw_window_handle`] method), which in turn allows you to create an -//! OpenGL/Vulkan/DirectX/Metal/etc. context that can be used to render graphics. +//! retrieve the raw handle of the window and display (see the [`platform`] module and/or the +//! [`raw_window_handle`] and [`raw_display_handle`] methods), which in turn allows +//! you to create an OpenGL/Vulkan/DirectX/Metal/etc. context that can be used to render graphics. //! //! Note that many platforms will display garbage data in the window's client area if the //! application doesn't render anything to the window by the time the desktop compositor is ready to @@ -129,6 +129,7 @@ //! [`LoopDestroyed`]: event::Event::LoopDestroyed //! [`platform`]: platform //! [`raw_window_handle`]: ./window/struct.Window.html#method.raw_window_handle +//! [`raw_display_handle`]: ./window/struct.Window.html#method.raw_display_handle #![deny(rust_2018_idioms)] #![deny(rustdoc::broken_intra_doc_links)] diff --git a/src/platform_impl/android/mod.rs b/src/platform_impl/android/mod.rs index 65e1a8cf..9c275e6e 100644 --- a/src/platform_impl/android/mod.rs +++ b/src/platform_impl/android/mod.rs @@ -14,7 +14,9 @@ use ndk::{ }; use ndk_glue::{Event, LockReadGuard, Rect}; use once_cell::sync::Lazy; -use raw_window_handle::{HasRawWindowHandle, RawWindowHandle}; +use raw_window_handle::{ + AndroidDisplayHandle, HasRawWindowHandle, RawDisplayHandle, RawWindowHandle, +}; use crate::{ dpi::{PhysicalPosition, PhysicalSize, Position, Size}, @@ -645,6 +647,10 @@ impl EventLoopWindowTarget { v.push_back(MonitorHandle); v } + + pub fn raw_display_handle(&self) -> RawDisplayHandle { + RawDisplayHandle::Android(AndroidDisplayHandle::empty()) + } } #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] @@ -835,6 +841,10 @@ impl Window { } } + pub fn raw_display_handle(&self) -> RawDisplayHandle { + RawDisplayHandle::Android(AndroidDisplayHandle::empty()) + } + pub fn config(&self) -> Configuration { CONFIG.read().unwrap().clone() } diff --git a/src/platform_impl/ios/event_loop.rs b/src/platform_impl/ios/event_loop.rs index 1a32fe56..eeaf2e68 100644 --- a/src/platform_impl/ios/event_loop.rs +++ b/src/platform_impl/ios/event_loop.rs @@ -7,6 +7,8 @@ use std::{ sync::mpsc::{self, Receiver, Sender}, }; +use raw_window_handle::{RawDisplayHandle, UiKitDisplayHandle}; + use crate::{ dpi::LogicalSize, event::Event, @@ -63,6 +65,10 @@ impl EventLoopWindowTarget { Some(RootMonitorHandle { inner: monitor }) } + + pub fn raw_display_handle(&self) -> RawDisplayHandle { + RawDisplayHandle::UiKit(UiKitDisplayHandle::empty()) + } } pub struct EventLoop { diff --git a/src/platform_impl/ios/window.rs b/src/platform_impl/ios/window.rs index 2fc9f3ed..0a4b81c2 100644 --- a/src/platform_impl/ios/window.rs +++ b/src/platform_impl/ios/window.rs @@ -1,10 +1,10 @@ -use raw_window_handle::{RawWindowHandle, UiKitHandle}; use std::{ collections::VecDeque, ops::{Deref, DerefMut}, }; use objc::runtime::{Class, Object, BOOL, NO, YES}; +use raw_window_handle::{RawDisplayHandle, RawWindowHandle, UiKitDisplayHandle, UiKitWindowHandle}; use crate::{ dpi::{self, LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize, Position, Size}, @@ -332,11 +332,15 @@ impl Inner { } pub fn raw_window_handle(&self) -> RawWindowHandle { - let mut handle = UiKitHandle::empty(); - handle.ui_window = self.window as _; - handle.ui_view = self.view as _; - handle.ui_view_controller = self.view_controller as _; - RawWindowHandle::UiKit(handle) + let mut window_handle = UiKitWindowHandle::empty(); + window_handle.ui_window = self.window as _; + window_handle.ui_view = self.view as _; + window_handle.ui_view_controller = self.view_controller as _; + RawWindowHandle::UiKit(window_handle) + } + + pub fn raw_display_handle(&self) -> RawDisplayHandle { + RawDisplayHandle::UiKit(UiKitDisplayHandle::empty()) } } diff --git a/src/platform_impl/linux/mod.rs b/src/platform_impl/linux/mod.rs index 6876c48b..989bfec5 100644 --- a/src/platform_impl/linux/mod.rs +++ b/src/platform_impl/linux/mod.rs @@ -20,7 +20,7 @@ use std::{ffi::CStr, mem::MaybeUninit, os::raw::*, sync::Arc}; use once_cell::sync::Lazy; #[cfg(feature = "x11")] use parking_lot::Mutex; -use raw_window_handle::RawWindowHandle; +use raw_window_handle::{RawDisplayHandle, RawWindowHandle}; #[cfg(feature = "x11")] pub use self::x11::XNotSupported; @@ -572,13 +572,14 @@ impl Window { } } + #[inline] pub fn raw_window_handle(&self) -> RawWindowHandle { - match self { - #[cfg(feature = "x11")] - Window::X(ref window) => RawWindowHandle::Xlib(window.raw_window_handle()), - #[cfg(feature = "wayland")] - Window::Wayland(ref window) => RawWindowHandle::Wayland(window.raw_window_handle()), - } + x11_or_wayland!(match self; Window(window) => window.raw_window_handle()) + } + + #[inline] + pub fn raw_display_handle(&self) -> RawDisplayHandle { + x11_or_wayland!(match self; Window(window) => window.raw_display_handle()) } } @@ -810,6 +811,10 @@ impl EventLoopWindowTarget { EventLoopWindowTarget::X(ref evlp) => evlp.set_device_event_filter(_filter), } } + + pub fn raw_display_handle(&self) -> raw_window_handle::RawDisplayHandle { + x11_or_wayland!(match self; Self(evlp) => evlp.raw_display_handle()) + } } fn sticky_exit_callback( diff --git a/src/platform_impl/linux/wayland/event_loop/mod.rs b/src/platform_impl/linux/wayland/event_loop/mod.rs index 8fe13bde..0f8f8a17 100644 --- a/src/platform_impl/linux/wayland/event_loop/mod.rs +++ b/src/platform_impl/linux/wayland/event_loop/mod.rs @@ -6,6 +6,8 @@ use std::process; use std::rc::Rc; use std::time::{Duration, Instant}; +use raw_window_handle::{RawDisplayHandle, WaylandDisplayHandle}; + use sctk::reexports::client::protocol::wl_compositor::WlCompositor; use sctk::reexports::client::protocol::wl_shm::WlShm; use sctk::reexports::client::Display; @@ -71,6 +73,14 @@ pub struct EventLoopWindowTarget { _marker: std::marker::PhantomData, } +impl EventLoopWindowTarget { + pub fn raw_display_handle(&self) -> RawDisplayHandle { + let mut display_handle = WaylandDisplayHandle::empty(); + display_handle.display = self.display.get_display_ptr() as *mut _; + RawDisplayHandle::Wayland(display_handle) + } +} + pub struct EventLoop { /// Event loop. event_loop: calloop::EventLoop<'static, WinitState>, diff --git a/src/platform_impl/linux/wayland/window/mod.rs b/src/platform_impl/linux/wayland/window/mod.rs index c0613528..a471cc13 100644 --- a/src/platform_impl/linux/wayland/window/mod.rs +++ b/src/platform_impl/linux/wayland/window/mod.rs @@ -7,7 +7,9 @@ use sctk::reexports::client::Display; use sctk::reexports::calloop; -use raw_window_handle::WaylandHandle; +use raw_window_handle::{ + RawDisplayHandle, RawWindowHandle, WaylandDisplayHandle, WaylandWindowHandle, +}; use sctk::window::Decorations; use crate::dpi::{LogicalSize, PhysicalPosition, PhysicalSize, Position, Size}; @@ -579,11 +581,17 @@ impl Window { } #[inline] - pub fn raw_window_handle(&self) -> WaylandHandle { - let mut handle = WaylandHandle::empty(); - handle.display = self.display.get_display_ptr() as *mut _; - handle.surface = self.surface.as_ref().c_ptr() as *mut _; - handle + pub fn raw_window_handle(&self) -> RawWindowHandle { + let mut window_handle = WaylandWindowHandle::empty(); + window_handle.surface = self.surface.as_ref().c_ptr() as *mut _; + RawWindowHandle::Wayland(window_handle) + } + + #[inline] + pub fn raw_display_handle(&self) -> RawDisplayHandle { + let mut display_handle = WaylandDisplayHandle::empty(); + display_handle.display = self.display.get_display_ptr() as *mut _; + RawDisplayHandle::Wayland(display_handle) } #[inline] diff --git a/src/platform_impl/linux/x11/mod.rs b/src/platform_impl/linux/x11/mod.rs index ff6f0123..2fe262cc 100644 --- a/src/platform_impl/linux/x11/mod.rs +++ b/src/platform_impl/linux/x11/mod.rs @@ -40,6 +40,7 @@ use std::{ use libc::{self, setlocale, LC_CTYPE}; use mio::{unix::SourceFd, Events, Interest, Poll, Token, Waker}; +use raw_window_handle::{RawDisplayHandle, XlibDisplayHandle}; use self::{ dnd::{Dnd, DndState}, @@ -558,6 +559,14 @@ impl EventLoopWindowTarget { .select_xinput_events(self.root, ffi::XIAllMasterDevices, mask) .queue(); } + + pub fn raw_display_handle(&self) -> raw_window_handle::RawDisplayHandle { + let mut display_handle = XlibDisplayHandle::empty(); + display_handle.display = self.xconn.display as *mut _; + display_handle.screen = + unsafe { (self.xconn.xlib.XDefaultScreen)(self.xconn.display as *mut _) }; + RawDisplayHandle::Xlib(display_handle) + } } impl EventLoopProxy { diff --git a/src/platform_impl/linux/x11/window.rs b/src/platform_impl/linux/x11/window.rs index fa4bd144..eb332647 100644 --- a/src/platform_impl/linux/x11/window.rs +++ b/src/platform_impl/linux/x11/window.rs @@ -1,4 +1,3 @@ -use raw_window_handle::XlibHandle; use std::{ cmp, env, ffi::CString, @@ -8,10 +7,11 @@ use std::{ ptr, slice, sync::Arc, }; -use x11_dl::xlib::TrueColor; use libc; use parking_lot::Mutex; +use raw_window_handle::{RawDisplayHandle, RawWindowHandle, XlibDisplayHandle, XlibWindowHandle}; +use x11_dl::xlib::TrueColor; use crate::{ dpi::{PhysicalPosition, PhysicalSize, Position, Size}, @@ -1509,10 +1509,17 @@ impl UnownedWindow { } #[inline] - pub fn raw_window_handle(&self) -> XlibHandle { - let mut handle = XlibHandle::empty(); - handle.window = self.xlib_window(); - handle.display = self.xlib_display(); - handle + pub fn raw_window_handle(&self) -> RawWindowHandle { + let mut window_handle = XlibWindowHandle::empty(); + window_handle.window = self.xlib_window(); + RawWindowHandle::Xlib(window_handle) + } + + #[inline] + pub fn raw_display_handle(&self) -> RawDisplayHandle { + let mut display_handle = XlibDisplayHandle::empty(); + display_handle.display = self.xlib_display(); + display_handle.screen = self.screen_id; + RawDisplayHandle::Xlib(display_handle) } } diff --git a/src/platform_impl/macos/event_loop.rs b/src/platform_impl/macos/event_loop.rs index 4a8b058c..ea031513 100644 --- a/src/platform_impl/macos/event_loop.rs +++ b/src/platform_impl/macos/event_loop.rs @@ -17,6 +17,7 @@ use cocoa::{ foundation::{NSInteger, NSPoint, NSTimeInterval}, }; use objc::rc::autoreleasepool; +use raw_window_handle::{AppKitDisplayHandle, RawDisplayHandle}; use crate::{ event::Event, @@ -87,6 +88,11 @@ impl EventLoopWindowTarget { let monitor = monitor::primary_monitor(); Some(RootMonitorHandle { inner: monitor }) } + + #[inline] + pub fn raw_display_handle(&self) -> RawDisplayHandle { + RawDisplayHandle::AppKit(AppKitDisplayHandle::empty()) + } } impl EventLoopWindowTarget { diff --git a/src/platform_impl/macos/window.rs b/src/platform_impl/macos/window.rs index 11d43f5a..f804a275 100644 --- a/src/platform_impl/macos/window.rs +++ b/src/platform_impl/macos/window.rs @@ -1,4 +1,3 @@ -use raw_window_handle::{AppKitHandle, RawWindowHandle}; use std::{ collections::VecDeque, convert::TryInto, @@ -10,6 +9,10 @@ use std::{ }, }; +use raw_window_handle::{ + AppKitDisplayHandle, AppKitWindowHandle, RawDisplayHandle, RawWindowHandle, +}; + use crate::{ dpi::{ LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize, Position, Size, Size::Logical, @@ -1144,10 +1147,15 @@ impl UnownedWindow { #[inline] pub fn raw_window_handle(&self) -> RawWindowHandle { - let mut handle = AppKitHandle::empty(); - handle.ns_window = *self.ns_window as *mut _; - handle.ns_view = *self.ns_view as *mut _; - RawWindowHandle::AppKit(handle) + let mut window_handle = AppKitWindowHandle::empty(); + window_handle.ns_window = *self.ns_window as *mut _; + window_handle.ns_view = *self.ns_view as *mut _; + RawWindowHandle::AppKit(window_handle) + } + + #[inline] + pub fn raw_display_handle(&self) -> RawDisplayHandle { + RawDisplayHandle::AppKit(AppKitDisplayHandle::empty()) } } diff --git a/src/platform_impl/web/event_loop/window_target.rs b/src/platform_impl/web/event_loop/window_target.rs index b9367629..6b15e3dd 100644 --- a/src/platform_impl/web/event_loop/window_target.rs +++ b/src/platform_impl/web/event_loop/window_target.rs @@ -1,3 +1,10 @@ +use std::cell::RefCell; +use std::clone::Clone; +use std::collections::{vec_deque::IntoIter as VecDequeIter, VecDeque}; +use std::rc::Rc; + +use raw_window_handle::{RawDisplayHandle, WebDisplayHandle}; + use super::{ super::monitor::MonitorHandle, backend, device::DeviceId, proxy::EventLoopProxy, runner, window::WindowId, @@ -10,10 +17,6 @@ use crate::event::{ use crate::event_loop::ControlFlow; use crate::monitor::MonitorHandle as RootMH; use crate::window::{Theme, WindowId as RootWindowId}; -use std::cell::RefCell; -use std::clone::Clone; -use std::collections::{vec_deque::IntoIter as VecDequeIter, VecDeque}; -use std::rc::Rc; pub struct EventLoopWindowTarget { pub(crate) runner: runner::Shared, @@ -279,4 +282,8 @@ impl EventLoopWindowTarget { inner: MonitorHandle, }) } + + pub fn raw_display_handle(&self) -> RawDisplayHandle { + RawDisplayHandle::Web(WebDisplayHandle::empty()) + } } diff --git a/src/platform_impl/web/window.rs b/src/platform_impl/web/window.rs index fe1d4b22..492baefc 100644 --- a/src/platform_impl/web/window.rs +++ b/src/platform_impl/web/window.rs @@ -7,7 +7,7 @@ use crate::window::{ CursorGrabMode, CursorIcon, Fullscreen, UserAttentionType, WindowAttributes, WindowId as RootWI, }; -use raw_window_handle::{RawWindowHandle, WebHandle}; +use raw_window_handle::{RawDisplayHandle, RawWindowHandle, WebDisplayHandle, WebWindowHandle}; use super::{backend, monitor::MonitorHandle, EventLoopWindowTarget}; @@ -359,9 +359,14 @@ impl Window { #[inline] pub fn raw_window_handle(&self) -> RawWindowHandle { - let mut handle = WebHandle::empty(); - handle.id = self.id.0; - RawWindowHandle::Web(handle) + let mut window_handle = WebWindowHandle::empty(); + window_handle.id = self.id.0; + RawWindowHandle::Web(window_handle) + } + + #[inline] + pub fn raw_display_handle(&self) -> RawDisplayHandle { + RawDisplayHandle::Web(WebDisplayHandle::empty()) } } diff --git a/src/platform_impl/windows/event_loop.rs b/src/platform_impl/windows/event_loop.rs index 1872f422..a89ab134 100644 --- a/src/platform_impl/windows/event_loop.rs +++ b/src/platform_impl/windows/event_loop.rs @@ -2,8 +2,6 @@ mod runner; -use once_cell::sync::Lazy; -use parking_lot::Mutex; use std::{ cell::Cell, collections::VecDeque, @@ -19,6 +17,10 @@ use std::{ time::{Duration, Instant}, }; +use once_cell::sync::Lazy; +use parking_lot::Mutex; +use raw_window_handle::{RawDisplayHandle, WindowsDisplayHandle}; + use windows_sys::Win32::{ Devices::HumanInterfaceDevice::MOUSE_MOVE_RELATIVE, Foundation::{BOOL, HANDLE, HWND, LPARAM, LRESULT, POINT, RECT, WAIT_TIMEOUT, WPARAM}, @@ -314,6 +316,10 @@ impl EventLoopWindowTarget { let monitor = monitor::primary_monitor(); Some(RootMonitorHandle { inner: monitor }) } + + pub fn raw_display_handle(&self) -> RawDisplayHandle { + RawDisplayHandle::Windows(WindowsDisplayHandle::empty()) + } } /// Returns the id of the main thread. diff --git a/src/platform_impl/windows/window.rs b/src/platform_impl/windows/window.rs index bc55a2a4..1041c847 100644 --- a/src/platform_impl/windows/window.rs +++ b/src/platform_impl/windows/window.rs @@ -1,7 +1,9 @@ #![cfg(target_os = "windows")] use parking_lot::Mutex; -use raw_window_handle::{RawWindowHandle, Win32Handle}; +use raw_window_handle::{ + RawDisplayHandle, RawWindowHandle, Win32WindowHandle, WindowsDisplayHandle, +}; use std::{ cell::Cell, ffi::c_void, @@ -260,10 +262,15 @@ impl Window { #[inline] pub fn raw_window_handle(&self) -> RawWindowHandle { - let mut handle = Win32Handle::empty(); - handle.hwnd = self.window.0 as *mut _; - handle.hinstance = self.hinstance() as *mut _; - RawWindowHandle::Win32(handle) + let mut window_handle = Win32WindowHandle::empty(); + window_handle.hwnd = self.window.0 as *mut _; + window_handle.hinstance = self.hinstance() as *mut _; + RawWindowHandle::Win32(window_handle) + } + + #[inline] + pub fn raw_display_handle(&self) -> RawDisplayHandle { + RawDisplayHandle::Windows(WindowsDisplayHandle::empty()) } #[inline] diff --git a/src/window.rs b/src/window.rs index 0dc31e22..4e1cb18b 100644 --- a/src/window.rs +++ b/src/window.rs @@ -1,6 +1,10 @@ //! The [`Window`] struct and associated types. use std::fmt; +use raw_window_handle::{ + HasRawDisplayHandle, HasRawWindowHandle, RawDisplayHandle, RawWindowHandle, +}; + use crate::{ dpi::{PhysicalPosition, PhysicalSize, Position, Size}, error::{ExternalError, NotSupportedError, OsError}, @@ -1032,8 +1036,7 @@ impl Window { self.window.primary_monitor() } } - -unsafe impl raw_window_handle::HasRawWindowHandle for Window { +unsafe impl HasRawWindowHandle for Window { /// Returns a [`raw_window_handle::RawWindowHandle`] for the Window /// /// ## Platform-specific @@ -1049,11 +1052,21 @@ unsafe impl raw_window_handle::HasRawWindowHandle for Window { /// /// [`Event::Resumed`]: crate::event::Event::Resumed /// [`Event::Suspended`]: crate::event::Event::Suspended - fn raw_window_handle(&self) -> raw_window_handle::RawWindowHandle { + fn raw_window_handle(&self) -> RawWindowHandle { self.window.raw_window_handle() } } +unsafe impl HasRawDisplayHandle for Window { + /// Returns a [`raw_window_handle::RawDisplayHandle`] used by the [`EventLoop`] that + /// created a window. + /// + /// [`EventLoop`]: crate::event_loop::EventLoop + fn raw_display_handle(&self) -> RawDisplayHandle { + self.window.raw_display_handle() + } +} + /// The behavior of cursor grabbing. /// /// Use this enum with [`Window::set_cursor_grab`] to grab the cursor.