Upgrade to raw-window-handle 0.4.x
The main change is that all of these types are simplified, there are more different OS-specific window handle types, and they are no longer gated behind the respective targets which makes the library a bit easier to use for applications.
This commit is contained in:
parent
625fde7957
commit
d76b02df44
|
@ -9,13 +9,14 @@ authors = [
|
||||||
"Billy Messenger <billydm@protonmail.com>",
|
"Billy Messenger <billydm@protonmail.com>",
|
||||||
"Anton Lazarev <https://antonok.com>",
|
"Anton Lazarev <https://antonok.com>",
|
||||||
"Joakim Frostegård <joakim.frostegard@gmail.com>",
|
"Joakim Frostegård <joakim.frostegard@gmail.com>",
|
||||||
|
"Robbert van der Helm <mail@robbertvanderhelm.nl>",
|
||||||
]
|
]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
keyboard-types = { version = "0.6.1", default-features = false }
|
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]
|
[target.'cfg(target_os="linux")'.dependencies]
|
||||||
xcb = { version = "0.9", features = ["thread", "xlib_xcb", "dri2"] }
|
xcb = { version = "0.9", features = ["thread", "xlib_xcb", "dri2"] }
|
||||||
|
|
|
@ -16,7 +16,7 @@ use keyboard_types::KeyboardEvent;
|
||||||
|
|
||||||
use objc::{msg_send, runtime::Object, sel, sel_impl};
|
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::{
|
use crate::{
|
||||||
Event, EventStatus, WindowEvent, WindowHandler, WindowInfo, WindowOpenOptions,
|
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 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
|
handle
|
||||||
} else {
|
} else {
|
||||||
panic!("Not a macOS window");
|
panic!("Not a macOS window");
|
||||||
|
@ -388,10 +388,10 @@ unsafe impl HasRawWindowHandle for Window {
|
||||||
fn raw_window_handle(&self) -> RawWindowHandle {
|
fn raw_window_handle(&self) -> RawWindowHandle {
|
||||||
let ns_window = self.ns_window.unwrap_or(::std::ptr::null_mut()) as *mut c_void;
|
let ns_window = self.ns_window.unwrap_or(::std::ptr::null_mut()) as *mut c_void;
|
||||||
|
|
||||||
RawWindowHandle::MacOS(MacOSHandle {
|
let mut handle = AppKitHandle::empty();
|
||||||
ns_window,
|
handle.ns_window = ns_window;
|
||||||
ns_view: self.ns_view as *mut c_void,
|
handle.ns_view = self.ns_view as *mut c_void;
|
||||||
..MacOSHandle::empty()
|
|
||||||
})
|
RawWindowHandle::AppKit(handle)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ use std::ptr::null_mut;
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
use std::sync::Arc;
|
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;
|
const BV_WINDOW_MUST_CLOSE: UINT = WM_USER + 1;
|
||||||
|
|
||||||
|
@ -80,12 +80,12 @@ impl WindowHandle {
|
||||||
unsafe impl HasRawWindowHandle for WindowHandle {
|
unsafe impl HasRawWindowHandle for WindowHandle {
|
||||||
fn raw_window_handle(&self) -> RawWindowHandle {
|
fn raw_window_handle(&self) -> RawWindowHandle {
|
||||||
if let Some(hwnd) = self.hwnd {
|
if let Some(hwnd) = self.hwnd {
|
||||||
RawWindowHandle::Windows(WindowsHandle {
|
let mut handle = Win32Handle::empty();
|
||||||
hwnd: hwnd as *mut std::ffi::c_void,
|
handle.hwnd = hwnd as *mut std::ffi::c_void;
|
||||||
..WindowsHandle::empty()
|
|
||||||
})
|
RawWindowHandle::Win32(handle)
|
||||||
} else {
|
} else {
|
||||||
RawWindowHandle::Windows(WindowsHandle { ..WindowsHandle::empty() })
|
RawWindowHandle::Win32(Win32Handle::empty())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -372,7 +372,7 @@ impl Window {
|
||||||
B: Send + 'static,
|
B: Send + 'static,
|
||||||
{
|
{
|
||||||
let parent = match parent.raw_window_handle() {
|
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),
|
h => panic!("unsupported parent handle {:?}", h),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -560,9 +560,9 @@ impl Window {
|
||||||
|
|
||||||
unsafe impl HasRawWindowHandle for Window {
|
unsafe impl HasRawWindowHandle for Window {
|
||||||
fn raw_window_handle(&self) -> RawWindowHandle {
|
fn raw_window_handle(&self) -> RawWindowHandle {
|
||||||
RawWindowHandle::Windows(WindowsHandle {
|
let mut handle = Win32Handle::empty();
|
||||||
hwnd: self.hwnd as *mut std::ffi::c_void,
|
handle.hwnd = self.hwnd as *mut std::ffi::c_void;
|
||||||
..WindowsHandle::empty()
|
|
||||||
})
|
RawWindowHandle::Win32(handle)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ use std::sync::Arc;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use std::time::*;
|
use std::time::*;
|
||||||
|
|
||||||
use raw_window_handle::{unix::XlibHandle, HasRawWindowHandle, RawWindowHandle};
|
use raw_window_handle::{HasRawWindowHandle, RawWindowHandle, XlibHandle};
|
||||||
|
|
||||||
use super::XcbConnection;
|
use super::XcbConnection;
|
||||||
use crate::{
|
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 {
|
unsafe impl HasRawWindowHandle for Window {
|
||||||
fn raw_window_handle(&self) -> RawWindowHandle {
|
fn raw_window_handle(&self) -> RawWindowHandle {
|
||||||
RawWindowHandle::Xlib(XlibHandle {
|
let mut handle = XlibHandle::empty();
|
||||||
window: self.window_id as c_ulong,
|
handle.window = self.window_id as c_ulong;
|
||||||
display: self.xcb_connection.conn.get_raw_dpy() as *mut c_void,
|
handle.display = self.xcb_connection.conn.get_raw_dpy() as *mut c_void;
|
||||||
..raw_window_handle::unix::XlibHandle::empty()
|
|
||||||
})
|
RawWindowHandle::Xlib(handle)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue