Skip to content

Commit 7539aef

Browse files
committed
breaking: Change Win32 to use pointers instead of ints
Needed as per new Win32 metadata updates Fixes: #171 Signed-off-by: John Nunley <dev@notgull.net>
1 parent 0f8c07c commit 7539aef

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ mod tests {
471471
assert_not_impl_any!(WaylandWindowHandle: Send, Sync);
472472
assert_impl_all!(DrmWindowHandle: Send, Sync);
473473
assert_not_impl_any!(GbmWindowHandle: Send, Sync);
474-
assert_impl_all!(Win32WindowHandle: Send, Sync);
474+
assert_not_impl_any!(Win32WindowHandle: Send, Sync);
475475
assert_not_impl_any!(WinRtWindowHandle: Send, Sync);
476476
assert_not_impl_any!(WebCanvasWindowHandle: Send, Sync);
477477
assert_not_impl_any!(WebOffscreenCanvasWindowHandle: Send, Sync);

src/windows.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use core::ffi::c_void;
2-
use core::num::NonZeroIsize;
32
use core::ptr::NonNull;
43

54
use super::DisplayHandle;
@@ -51,9 +50,9 @@ impl DisplayHandle<'static> {
5150
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
5251
pub struct Win32WindowHandle {
5352
/// A Win32 `HWND` handle.
54-
pub hwnd: NonZeroIsize,
53+
pub hwnd: NonNull<c_void>,
5554
/// The `GWLP_HINSTANCE` associated with this type's `HWND`.
56-
pub hinstance: Option<NonZeroIsize>,
55+
pub hinstance: Option<NonNull<c_void>>,
5756
}
5857

5958
impl Win32WindowHandle {
@@ -67,20 +66,21 @@ impl Win32WindowHandle {
6766
/// # Example
6867
///
6968
/// ```
70-
/// # use core::num::NonZeroIsize;
69+
/// # use core::ffi::c_void;
70+
/// # use core::ptr::NonNull;
7171
/// # use raw_window_handle::Win32WindowHandle;
72-
/// # struct HWND(isize);
72+
/// # struct HWND(*mut c_void);
7373
/// #
7474
/// let window: HWND;
75-
/// # window = HWND(1);
76-
/// let mut handle = Win32WindowHandle::new(NonZeroIsize::new(window.0).unwrap());
75+
/// # window = HWND(1 as *mut c_void);
76+
/// let mut handle = Win32WindowHandle::new(NonNull::new(window.0).unwrap());
7777
/// // Optionally set the GWLP_HINSTANCE.
7878
/// # #[cfg(only_for_showcase)]
79-
/// let hinstance = NonZeroIsize::new(unsafe { GetWindowLongPtrW(window, GWLP_HINSTANCE) }).unwrap();
79+
/// let hinstance = NonNull::new(unsafe { GetWindowLongPtrW(window, GWLP_HINSTANCE) }).unwrap();
8080
/// # let hinstance = None;
8181
/// handle.hinstance = hinstance;
8282
/// ```
83-
pub fn new(hwnd: NonZeroIsize) -> Self {
83+
pub fn new(hwnd: NonNull<c_void>) -> Self {
8484
Self {
8585
hwnd,
8686
hinstance: None,

0 commit comments

Comments
 (0)