Add get_nsview to WindowExt for MacOS

This commit is contained in:
Pierre Krieger 2016-10-06 18:58:15 +02:00
parent 41e1a768e5
commit d5b88f1d5f
2 changed files with 19 additions and 7 deletions

View file

@ -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;

View file

@ -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`.