diff --git a/src/api/cocoa/mod.rs b/src/api/cocoa/mod.rs index 186578d7..f75adb2d 100644 --- a/src/api/cocoa/mod.rs +++ b/src/api/cocoa/mod.rs @@ -30,7 +30,9 @@ use std::str::FromStr; use std::str::from_utf8; use std::sync::Mutex; use std::ops::Deref; +use std::os::raw::c_void; +use os::macos::WindowExt; use events::ElementState; use events::{self, MouseButton, TouchPhase}; @@ -177,6 +179,18 @@ pub struct Window { unsafe impl Send for Window {} unsafe impl Sync for Window {} +impl WindowExt for Window { + #[inline] + fn get_nswindow(&self) -> *mut c_void { + *self.window as *mut c_void + } + + #[inline] + fn get_nsview(&self) -> *mut c_void { + *self.view as *mut c_void + } +} + #[derive(Clone)] pub struct WindowProxy; diff --git a/src/os/macos.rs b/src/os/macos.rs index a632e3e2..31e29d0d 100644 --- a/src/os/macos.rs +++ b/src/os/macos.rs @@ -9,15 +9,13 @@ use {Window, WindowBuilder}; pub trait WindowExt { /// Returns a pointer to the cocoa `NSWindow` that is used by this window. /// - /// The pointer will become invalid when the glutin `Window` is destroyed. + /// The pointer will become invalid when the `Window` is destroyed. fn get_nswindow(&self) -> *mut c_void; -} -impl WindowExt for Window { - #[inline] - fn get_nswindow(&self) -> *mut c_void { - self.window.platform_window() as *mut c_void - } + /// Returns a pointer to the cocoa `NSView` that is used by this window. + /// + /// The pointer will become invalid when the `Window` is destroyed. + fn get_nsview(&self) -> *mut c_void; } /// Corresponds to `NSApplicationActivationPolicy`.