@@ -61,6 +61,10 @@ pub(super) struct WindowInner {
6161 /// Only set if we created the parent window, i.e. we are running in
6262 /// parentless mode
6363 ns_window : Cell < Option < id > > ,
64+
65+ /// Only set when running in parented mode.
66+ parent_ns_window : Option < id > ,
67+
6468 /// Our subclassed NSView
6569 ns_view : id ,
6670
@@ -109,7 +113,9 @@ impl WindowInner {
109113
110114 fn raw_window_handle ( & self ) -> RawWindowHandle {
111115 if self . open . get ( ) {
112- let ns_window = self . ns_window . get ( ) . unwrap_or ( ptr:: null_mut ( ) ) as * mut c_void ;
116+ let ns_window =
117+ self . ns_window . get ( ) . or ( self . parent_ns_window ) . unwrap_or ( ptr:: null_mut ( ) )
118+ as * mut c_void ;
113119
114120 let mut handle = AppKitWindowHandle :: empty ( ) ;
115121 handle. ns_window = ns_window;
@@ -155,6 +161,11 @@ impl<'a> Window<'a> {
155161 open : Cell :: new ( true ) ,
156162 ns_app : Cell :: new ( None ) ,
157163 ns_window : Cell :: new ( None ) ,
164+ parent_ns_window : if handle. ns_window . is_null ( ) {
165+ None
166+ } else {
167+ Some ( handle. ns_window . cast ( ) )
168+ } ,
158169 ns_view,
159170
160171 #[ cfg( feature = "opengl" ) ]
@@ -230,6 +241,7 @@ impl<'a> Window<'a> {
230241 open : Cell :: new ( true ) ,
231242 ns_app : Cell :: new ( Some ( app) ) ,
232243 ns_window : Cell :: new ( Some ( ns_window) ) ,
244+ parent_ns_window : None ,
233245 ns_view,
234246
235247 #[ cfg( feature = "opengl" ) ]
0 commit comments