1
0
Fork 0

replace *mut c_void with RawWindowHandle in Parent::WithParent

This commit is contained in:
William Light 2020-09-12 19:06:21 +02:00
parent 47b122c86e
commit 29461b14e4
3 changed files with 21 additions and 7 deletions

View file

@ -1,4 +1,4 @@
use std::ffi::c_void; use raw_window_handle::RawWindowHandle;
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
mod win; mod win;
@ -25,7 +25,7 @@ pub use mouse_cursor::MouseCursor;
pub enum Parent { pub enum Parent {
None, None,
AsIfParented, AsIfParented,
WithParent(*mut c_void), WithParent(RawWindowHandle),
} }
unsafe impl Send for Parent {} unsafe impl Send for Parent {}

View file

@ -16,7 +16,11 @@ use std::ffi::c_void;
use std::ptr::null_mut; use std::ptr::null_mut;
use std::rc::Rc; use std::rc::Rc;
use raw_window_handle::{windows::WindowsHandle, HasRawWindowHandle, RawWindowHandle}; use raw_window_handle::{
windows::WindowsHandle,
HasRawWindowHandle,
RawWindowHandle
};
use crate::{ use crate::{
Event, KeyboardEvent, MouseButton, MouseEvent, Parent::WithParent, ScrollDelta, WindowEvent, 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 // todo: add check flags https://github.com/wrl/rutabaga/blob/f30ff67e157375cafdbafe5fb549f1790443a3a8/src/platform/win/window.c#L351
let parent = match options.parent { let parent = match options.parent {
WithParent(p) => { WithParent(RawWindowHandle::Windows(h)) => {
flags = WS_CHILD | WS_VISIBLE; flags = WS_CHILD | WS_VISIBLE;
p h.hwnd
} }
WithParent(h) => panic!("unsupported parent handle {:?}", h)
_ => { _ => {
AdjustWindowRectEx(&mut rect, flags, FALSE, 0); AdjustWindowRectEx(&mut rect, flags, FALSE, 0);
null_mut() null_mut()

View file

@ -3,7 +3,11 @@ use std::sync::mpsc;
use std::time::*; use std::time::*;
use std::thread; use std::thread;
use raw_window_handle::{unix::XlibHandle, HasRawWindowHandle, RawWindowHandle}; use raw_window_handle::{
unix::XlibHandle,
HasRawWindowHandle,
RawWindowHandle
};
use super::XcbConnection; use super::XcbConnection;
use crate::{ use crate::{
@ -67,7 +71,11 @@ impl Window {
// Convert parent into something that X understands // Convert parent into something that X understands
let parent_id = match options.parent { 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(), Parent::None | Parent::AsIfParented => screen.root(),
}; };