Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/macos/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ pub(super) struct WindowInner {
/// Only set if we created the parent window, i.e. we are running in
/// parentless mode
ns_window: Cell<Option<id>>,

/// Only set when running in parented mode.
parent_ns_window: Option<id>,

/// Our subclassed NSView
ns_view: id,

Expand Down Expand Up @@ -109,7 +113,9 @@ impl WindowInner {

fn raw_window_handle(&self) -> RawWindowHandle {
if self.open.get() {
let ns_window = self.ns_window.get().unwrap_or(ptr::null_mut()) as *mut c_void;
let ns_window =
self.ns_window.get().or(self.parent_ns_window).unwrap_or(ptr::null_mut())
as *mut c_void;

let mut handle = AppKitWindowHandle::empty();
handle.ns_window = ns_window;
Expand Down Expand Up @@ -155,6 +161,11 @@ impl<'a> Window<'a> {
open: Cell::new(true),
ns_app: Cell::new(None),
ns_window: Cell::new(None),
parent_ns_window: if handle.ns_window.is_null() {
None
} else {
Some(handle.ns_window.cast())
},
ns_view,

#[cfg(feature = "opengl")]
Expand Down Expand Up @@ -230,6 +241,7 @@ impl<'a> Window<'a> {
open: Cell::new(true),
ns_app: Cell::new(Some(app)),
ns_window: Cell::new(Some(ns_window)),
parent_ns_window: None,
ns_view,

#[cfg(feature = "opengl")]
Expand Down
Loading