From c8c85c2580e8ee15b5b509bca2a5e130e929bc81 Mon Sep 17 00:00:00 2001 From: Alex Janka Date: Thu, 8 Feb 2024 15:16:43 +1100 Subject: [PATCH] content view pointer --- src/appkit/window/mod.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/appkit/window/mod.rs b/src/appkit/window/mod.rs index 8e1d412..d79d744 100644 --- a/src/appkit/window/mod.rs +++ b/src/appkit/window/mod.rs @@ -50,7 +50,7 @@ pub struct Window { pub objc: Id, /// A delegate for this window. - pub delegate: Option> + pub delegate: Option>, } impl Default for Window { @@ -108,21 +108,21 @@ impl Window { Window { objc: objc, - delegate: None + delegate: None, } } pub(crate) unsafe fn existing(window: *mut Object) -> Window { Window { objc: Id::retain(window).unwrap(), - delegate: None + delegate: None, } } } impl Window where - T: WindowDelegate + 'static + T: WindowDelegate + 'static, { /// Constructs a new Window with a `config` and `delegate`. Using a `WindowDelegate` enables /// you to respond to window lifecycle events - visibility, movement, and so on. It also @@ -180,13 +180,13 @@ where { (&mut delegate).did_load(Window { delegate: None, - objc: objc.clone() + objc: objc.clone(), }); } Window { objc: objc, - delegate: Some(delegate) + delegate: Some(delegate), } } } @@ -338,6 +338,10 @@ impl Window { } } + pub unsafe fn content_view_ptr(&self) -> Option> { + std::ptr::NonNull::new(self.content_view() as *mut std::ffi::c_void) + } + /// Return the objc ContentView from the window pub(crate) unsafe fn content_view(&self) -> id { let id: *mut Object = msg_send![&*self.objc, contentView]; @@ -514,7 +518,7 @@ impl Window { pub fn begin_sheet(&self, window: &Window, completion: F) where F: Fn() + Send + Sync + 'static, - W: WindowDelegate + 'static + W: WindowDelegate + 'static, { let block = ConcreteBlock::new(move |_response: NSInteger| { completion(); @@ -529,7 +533,7 @@ impl Window { /// Closes a sheet. pub fn end_sheet(&self, window: &Window) where - W: WindowDelegate + 'static + W: WindowDelegate + 'static, { unsafe { let _: () = msg_send![&*self.objc, endSheet:&*window.objc];