gdk4_macos/
macos_surface.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Take a look at the license at the top of the repository in the LICENSE file.

#[cfg(feature = "v4_8")]
use crate::ffi;
#[cfg(not(feature = "v4_8"))]
use crate::prelude::*;
use crate::{id, MacosSurface};
#[cfg(feature = "v4_8")]
use glib::translate::*;
#[cfg(not(feature = "v4_8"))]
use std::ffi::c_void;

impl MacosSurface {
    /// Gets the underlying NSWindow used by the surface.
    ///
    /// The NSWindow's contentView is an implementation detail and may change
    /// between releases of GTK.
    ///
    /// # Returns
    ///
    /// a #NSWindow or [`None`]
    #[doc(alias = "gdk_macos_surface_get_native_window")]
    #[doc(alias = "get_native_window")]
    pub fn native(&self) -> id {
        #[cfg(feature = "v4_8")]
        unsafe {
            let native_window_ptr = ffi::gdk_macos_surface_get_native_window(self.to_glib_none().0);
            native_window_ptr as id
        }

        #[cfg(not(feature = "v4_8"))]
        {
            let native_window_ptr: *mut c_void = ObjectExt::property(self, "native");
            native_window_ptr as id
        }
    }
}