diff --git a/src/os/windows.rs b/src/os/windows.rs index e37b4185..6d8b7981 100644 --- a/src/os/windows.rs +++ b/src/os/windows.rs @@ -3,6 +3,7 @@ use libc; use Window; use WindowBuilder; +use winapi; /// Additional methods on `Window` that are specific to Windows. pub trait WindowExt { @@ -23,8 +24,14 @@ impl WindowExt for Window { /// Additional methods on `WindowBuilder` that are specific to Windows. pub trait WindowBuilderExt { - + fn with_parent_window(self, parent: winapi::HWND) -> WindowBuilder; } impl WindowBuilderExt for WindowBuilder { + /// Sets a parent to the window to be created + #[inline] + fn with_parent_window(mut self, parent: winapi::HWND) -> WindowBuilder { + self.platform_specific.parent = Some(parent); + self + } } diff --git a/src/platform/windows/init.rs b/src/platform/windows/init.rs index bc563847..2d3b1537 100644 --- a/src/platform/windows/init.rs +++ b/src/platform/windows/init.rs @@ -9,6 +9,7 @@ use super::WindowState; use super::Window; use super::MonitorId; use super::WindowWrapper; +use super::PlatformSpecificWindowBuilderAttributes; use CreationError; use CreationError::OsError; @@ -24,9 +25,9 @@ use kernel32; use dwmapi; use user32; -pub fn new_window(window: &WindowAttributes) -> Result { +pub fn new_window(window: &WindowAttributes, pl_attribs: &PlatformSpecificWindowBuilderAttributes) -> Result { let window = window.clone(); - + let attribs = pl_attribs.clone(); // initializing variables to be sent to the task let title = OsStr::new(&window.title).encode_wide().chain(Some(0).into_iter()) @@ -39,7 +40,7 @@ pub fn new_window(window: &WindowAttributes) -> Result { thread::spawn(move || { unsafe { // creating and sending the `Window` - match init(title, &window) { + match init(title, &window, attribs) { Ok(w) => tx.send(Ok(w)).ok(), Err(e) => { tx.send(Err(e)).ok(); @@ -65,7 +66,7 @@ pub fn new_window(window: &WindowAttributes) -> Result { rx.recv().unwrap() } -unsafe fn init(title: Vec, window: &WindowAttributes) -> Result { +unsafe fn init(title: Vec, window: &WindowAttributes, pl_attribs: PlatformSpecificWindowBuilderAttributes) -> Result { // registering the window class let class_name = register_window_class(); @@ -84,8 +85,16 @@ unsafe fn init(title: Vec, window: &WindowAttributes) -> Result, window: &WindowAttributes) -> Result, +} + +unsafe impl Send for PlatformSpecificWindowBuilderAttributes {} +unsafe impl Sync for PlatformSpecificWindowBuilderAttributes {} + #[derive(Clone, Default)] pub struct PlatformSpecificHeadlessBuilderAttributes; @@ -93,10 +99,10 @@ impl WindowProxy { impl Window { /// See the docs in the crate root file. - pub fn new(window: &WindowAttributes, _: &PlatformSpecificWindowBuilderAttributes) + pub fn new(window: &WindowAttributes, pl_attribs: &PlatformSpecificWindowBuilderAttributes) -> Result { - init::new_window(window) + init::new_window(window, pl_attribs) } /// See the docs in the crate root file. diff --git a/src/window.rs b/src/window.rs index cbc9731a..415541c5 100644 --- a/src/window.rs +++ b/src/window.rs @@ -373,6 +373,7 @@ impl WindowProxy { self.proxy.wakeup_event_loop(); } } + /// An iterator for the `poll_events` function. pub struct PollEventsIterator<'a>(platform::PollEventsIterator<'a>);