diff --git a/Cargo.toml b/Cargo.toml index e335061..f45bdc3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,13 +9,14 @@ authors = [ "Billy Messenger ", "Anton Lazarev ", "Joakim FrostegÄrd ", + "Robbert van der Helm ", ] edition = "2018" license = "MIT OR Apache-2.0" [dependencies] keyboard-types = { version = "0.6.1", default-features = false } -raw-window-handle = "0.3.3" +raw-window-handle = "0.4.2" [target.'cfg(target_os="linux")'.dependencies] xcb = { version = "0.9", features = ["thread", "xlib_xcb", "dri2"] } diff --git a/src/macos/window.rs b/src/macos/window.rs index 5b71b6f..bfe8316 100644 --- a/src/macos/window.rs +++ b/src/macos/window.rs @@ -16,7 +16,7 @@ use keyboard_types::KeyboardEvent; use objc::{msg_send, runtime::Object, sel, sel_impl}; -use raw_window_handle::{macos::MacOSHandle, HasRawWindowHandle, RawWindowHandle}; +use raw_window_handle::{AppKitHandle, HasRawWindowHandle, RawWindowHandle}; use crate::{ Event, EventStatus, WindowEvent, WindowHandler, WindowInfo, WindowOpenOptions, @@ -55,7 +55,7 @@ unsafe impl HasRawWindowHandle for WindowHandle { } } - RawWindowHandle::MacOS(MacOSHandle { ..MacOSHandle::empty() }) + RawWindowHandle::AppKit(AppKitHandle::empty()) } } @@ -114,7 +114,7 @@ impl Window { { let pool = unsafe { NSAutoreleasePool::new(nil) }; - let handle = if let RawWindowHandle::MacOS(handle) = parent.raw_window_handle() { + let handle = if let RawWindowHandle::AppKit(handle) = parent.raw_window_handle() { handle } else { panic!("Not a macOS window"); @@ -388,10 +388,10 @@ unsafe impl HasRawWindowHandle for Window { fn raw_window_handle(&self) -> RawWindowHandle { let ns_window = self.ns_window.unwrap_or(::std::ptr::null_mut()) as *mut c_void; - RawWindowHandle::MacOS(MacOSHandle { - ns_window, - ns_view: self.ns_view as *mut c_void, - ..MacOSHandle::empty() - }) + let mut handle = AppKitHandle::empty(); + handle.ns_window = ns_window; + handle.ns_view = self.ns_view as *mut c_void; + + RawWindowHandle::AppKit(handle) } } diff --git a/src/win/window.rs b/src/win/window.rs index f91ac17..08720f0 100644 --- a/src/win/window.rs +++ b/src/win/window.rs @@ -23,7 +23,7 @@ use std::ptr::null_mut; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; -use raw_window_handle::{windows::WindowsHandle, HasRawWindowHandle, RawWindowHandle}; +use raw_window_handle::{HasRawWindowHandle, RawWindowHandle, Win32Handle}; const BV_WINDOW_MUST_CLOSE: UINT = WM_USER + 1; @@ -80,12 +80,12 @@ impl WindowHandle { unsafe impl HasRawWindowHandle for WindowHandle { fn raw_window_handle(&self) -> RawWindowHandle { if let Some(hwnd) = self.hwnd { - RawWindowHandle::Windows(WindowsHandle { - hwnd: hwnd as *mut std::ffi::c_void, - ..WindowsHandle::empty() - }) + let mut handle = Win32Handle::empty(); + handle.hwnd = hwnd as *mut std::ffi::c_void; + + RawWindowHandle::Win32(handle) } else { - RawWindowHandle::Windows(WindowsHandle { ..WindowsHandle::empty() }) + RawWindowHandle::Win32(Win32Handle::empty()) } } } @@ -372,7 +372,7 @@ impl Window { B: Send + 'static, { let parent = match parent.raw_window_handle() { - RawWindowHandle::Windows(h) => h.hwnd as HWND, + RawWindowHandle::Win32(h) => h.hwnd as HWND, h => panic!("unsupported parent handle {:?}", h), }; @@ -560,9 +560,9 @@ impl Window { unsafe impl HasRawWindowHandle for Window { fn raw_window_handle(&self) -> RawWindowHandle { - RawWindowHandle::Windows(WindowsHandle { - hwnd: self.hwnd as *mut std::ffi::c_void, - ..WindowsHandle::empty() - }) + let mut handle = Win32Handle::empty(); + handle.hwnd = self.hwnd as *mut std::ffi::c_void; + + RawWindowHandle::Win32(handle) } } diff --git a/src/x11/window.rs b/src/x11/window.rs index 2041623..f9cff75 100644 --- a/src/x11/window.rs +++ b/src/x11/window.rs @@ -6,7 +6,7 @@ use std::sync::Arc; use std::thread; use std::time::*; -use raw_window_handle::{unix::XlibHandle, HasRawWindowHandle, RawWindowHandle}; +use raw_window_handle::{HasRawWindowHandle, RawWindowHandle, XlibHandle}; use super::XcbConnection; use crate::{ @@ -49,7 +49,7 @@ unsafe impl HasRawWindowHandle for WindowHandle { } } - RawWindowHandle::Xlib(XlibHandle { ..raw_window_handle::unix::XlibHandle::empty() }) + RawWindowHandle::Xlib(XlibHandle::empty()) } } @@ -595,11 +595,11 @@ impl Window { unsafe impl HasRawWindowHandle for Window { fn raw_window_handle(&self) -> RawWindowHandle { - RawWindowHandle::Xlib(XlibHandle { - window: self.window_id as c_ulong, - display: self.xcb_connection.conn.get_raw_dpy() as *mut c_void, - ..raw_window_handle::unix::XlibHandle::empty() - }) + let mut handle = XlibHandle::empty(); + handle.window = self.window_id as c_ulong; + handle.display = self.xcb_connection.conn.get_raw_dpy() as *mut c_void; + + RawWindowHandle::Xlib(handle) } }