gdk4_macos/macos_surface.rs
1// Take a look at the license at the top of the repository in the LICENSE file.
2
3#[cfg(feature = "v4_8")]
4use crate::ffi;
5#[cfg(not(feature = "v4_8"))]
6use crate::prelude::*;
7use crate::{id, MacosSurface};
8#[cfg(feature = "v4_8")]
9use glib::translate::*;
10#[cfg(not(feature = "v4_8"))]
11use std::ffi::c_void;
12
13impl MacosSurface {
14 /// Gets the underlying NSWindow used by the surface.
15 ///
16 /// The NSWindow's contentView is an implementation detail and may change
17 /// between releases of GTK.
18 ///
19 /// # Returns
20 ///
21 /// a #NSWindow or [`None`]
22 #[doc(alias = "gdk_macos_surface_get_native_window")]
23 #[doc(alias = "get_native_window")]
24 pub fn native(&self) -> id {
25 #[cfg(feature = "v4_8")]
26 unsafe {
27 let native_window_ptr = ffi::gdk_macos_surface_get_native_window(self.to_glib_none().0);
28 native_window_ptr as id
29 }
30
31 #[cfg(not(feature = "v4_8"))]
32 {
33 let native_window_ptr: *mut c_void = ObjectExt::property(self, "native");
34 native_window_ptr as id
35 }
36 }
37}