Skip to content

Commit

Permalink
If ns_view is null, use the window to get the default ns_view.
Browse files Browse the repository at this point in the history
 * Based on change: https://github.com/gfx-rs/wgpu/pull/462/files
 * Potentially resolves gfx-rs#3329
  • Loading branch information
aclysma committed Aug 12, 2020
1 parent c99c99b commit 5fa0044
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/backend/metal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,15 @@ impl hal::Instance<Backend> for Instance {
}
#[cfg(target_os = "macos")]
raw_window_handle::RawWindowHandle::MacOS(handle) => {
Ok(self.create_surface_from_nsview(handle.ns_view, false))
let ns_view =
if handle.ns_view.is_null() {
let ns_window = handle.ns_window as *mut Object;
unsafe { msg_send![ns_window, contentView] }
} else {
handle.ns_view
};

Ok(self.create_surface_from_nsview(ns_view, false))
}
_ => Err(hal::window::InitError::UnsupportedWindowHandle),
}
Expand Down

0 comments on commit 5fa0044

Please sign in to comment.