diff --git a/src/lib.rs b/src/lib.rs index d03dc60..fb84d94 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -use std::ffi::c_void; +use raw_window_handle::RawWindowHandle; #[cfg(target_os = "windows")] mod win; @@ -25,7 +25,7 @@ pub use mouse_cursor::MouseCursor; pub enum Parent { None, AsIfParented, - WithParent(*mut c_void), + WithParent(RawWindowHandle), } unsafe impl Send for Parent {} diff --git a/src/win/window.rs b/src/win/window.rs index 81a9439..990c68b 100644 --- a/src/win/window.rs +++ b/src/win/window.rs @@ -16,7 +16,11 @@ use std::ffi::c_void; use std::ptr::null_mut; use std::rc::Rc; -use raw_window_handle::{windows::WindowsHandle, HasRawWindowHandle, RawWindowHandle}; +use raw_window_handle::{ + windows::WindowsHandle, + HasRawWindowHandle, + RawWindowHandle +}; use crate::{ Event, KeyboardEvent, MouseButton, MouseEvent, Parent::WithParent, ScrollDelta, WindowEvent, @@ -187,11 +191,13 @@ impl Window { // todo: add check flags https://github.com/wrl/rutabaga/blob/f30ff67e157375cafdbafe5fb549f1790443a3a8/src/platform/win/window.c#L351 let parent = match options.parent { - WithParent(p) => { + WithParent(RawWindowHandle::Windows(h)) => { flags = WS_CHILD | WS_VISIBLE; - p + h.hwnd } + WithParent(h) => panic!("unsupported parent handle {:?}", h) + _ => { AdjustWindowRectEx(&mut rect, flags, FALSE, 0); null_mut() diff --git a/src/x11/window.rs b/src/x11/window.rs index 325aae6..5a9f1b7 100644 --- a/src/x11/window.rs +++ b/src/x11/window.rs @@ -3,7 +3,11 @@ use std::sync::mpsc; use std::time::*; use std::thread; -use raw_window_handle::{unix::XlibHandle, HasRawWindowHandle, RawWindowHandle}; +use raw_window_handle::{ + unix::XlibHandle, + HasRawWindowHandle, + RawWindowHandle +}; use super::XcbConnection; use crate::{ @@ -67,7 +71,11 @@ impl Window { // Convert parent into something that X understands let parent_id = match options.parent { - Parent::WithParent(p) => p as u32, + Parent::WithParent(RawWindowHandle::Xlib(h)) => h.window as u32, + Parent::WithParent(RawWindowHandle::Xcb(h)) => h.window, + Parent::WithParent(h) => + panic!("unsupported parent handle type {:?}", h), + Parent::None | Parent::AsIfParented => screen.root(), };