mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-25 23:01:30 +11:00
Merge pull request #18 from tomaka/macos-nsview
Add get_nsview to WindowExt for MacOS
This commit is contained in:
commit
10a2a52cb1
|
@ -30,7 +30,9 @@ use std::str::FromStr;
|
||||||
use std::str::from_utf8;
|
use std::str::from_utf8;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
use std::os::raw::c_void;
|
||||||
|
|
||||||
|
use os::macos::WindowExt;
|
||||||
use events::ElementState;
|
use events::ElementState;
|
||||||
use events::{self, MouseButton, TouchPhase};
|
use events::{self, MouseButton, TouchPhase};
|
||||||
|
|
||||||
|
@ -177,6 +179,18 @@ pub struct Window {
|
||||||
unsafe impl Send for Window {}
|
unsafe impl Send for Window {}
|
||||||
unsafe impl Sync 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)]
|
#[derive(Clone)]
|
||||||
pub struct WindowProxy;
|
pub struct WindowProxy;
|
||||||
|
|
||||||
|
|
|
@ -9,15 +9,13 @@ use {Window, WindowBuilder};
|
||||||
pub trait WindowExt {
|
pub trait WindowExt {
|
||||||
/// Returns a pointer to the cocoa `NSWindow` that is used by this window.
|
/// 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;
|
fn get_nswindow(&self) -> *mut c_void;
|
||||||
}
|
|
||||||
|
|
||||||
impl WindowExt for Window {
|
/// Returns a pointer to the cocoa `NSView` that is used by this window.
|
||||||
#[inline]
|
///
|
||||||
fn get_nswindow(&self) -> *mut c_void {
|
/// The pointer will become invalid when the `Window` is destroyed.
|
||||||
self.window.platform_window() as *mut c_void
|
fn get_nsview(&self) -> *mut c_void;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Corresponds to `NSApplicationActivationPolicy`.
|
/// Corresponds to `NSApplicationActivationPolicy`.
|
||||||
|
|
Loading…
Reference in a new issue