gdk4_macos/auto/
macos_surface.rs1use crate::ffi;
6use glib::{
7 prelude::*,
8 signal::{connect_raw, SignalHandlerId},
9 translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14 #[doc(alias = "GdkMacosSurface")]
15 pub struct MacosSurface(Object<ffi::GdkMacosSurface, ffi::GdkMacosSurfaceClass>) @extends gdk::Surface;
16
17 match fn {
18 type_ => || ffi::gdk_macos_surface_get_type(),
19 }
20}
21
22impl MacosSurface {
23 #[doc(alias = "native")]
24 pub fn connect_native_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
25 unsafe extern "C" fn notify_native_trampoline<F: Fn(&MacosSurface) + 'static>(
26 this: *mut ffi::GdkMacosSurface,
27 _param_spec: glib::ffi::gpointer,
28 f: glib::ffi::gpointer,
29 ) {
30 let f: &F = &*(f as *const F);
31 f(&from_glib_borrow(this))
32 }
33 unsafe {
34 let f: Box_<F> = Box_::new(f);
35 connect_raw(
36 self.as_ptr() as *mut _,
37 c"notify::native".as_ptr() as *const _,
38 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
39 notify_native_trampoline::<F> as *const (),
40 )),
41 Box_::into_raw(f),
42 )
43 }
44 }
45}