Skip to main content

gstreamer_vulkan/auto/
vulkan_window.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
4// DO NOT EDIT
5
6use crate::{VulkanDevice, VulkanDisplay, ffi};
7use glib::{
8    object::ObjectType as _,
9    prelude::*,
10    signal::{SignalHandlerId, connect_raw},
11    translate::*,
12};
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16    #[doc(alias = "GstVulkanWindow")]
17    pub struct VulkanWindow(Object<ffi::GstVulkanWindow, ffi::GstVulkanWindowClass>) @extends gst::Object;
18
19    match fn {
20        type_ => || ffi::gst_vulkan_window_get_type(),
21    }
22}
23
24impl VulkanWindow {
25    pub const NONE: Option<&'static VulkanWindow> = None;
26
27    #[doc(alias = "gst_vulkan_window_new")]
28    pub fn new(display: &impl IsA<VulkanDisplay>) -> VulkanWindow {
29        skip_assert_initialized!();
30        unsafe {
31            from_glib_full(ffi::gst_vulkan_window_new(
32                display.as_ref().to_glib_none().0,
33            ))
34        }
35    }
36}
37
38unsafe impl Send for VulkanWindow {}
39unsafe impl Sync for VulkanWindow {}
40
41pub trait VulkanWindowExt: IsA<VulkanWindow> + 'static {
42    #[doc(alias = "gst_vulkan_window_close")]
43    fn close(&self) {
44        unsafe {
45            ffi::gst_vulkan_window_close(self.as_ref().to_glib_none().0);
46        }
47    }
48
49    #[doc(alias = "gst_vulkan_window_get_display")]
50    #[doc(alias = "get_display")]
51    fn display(&self) -> VulkanDisplay {
52        unsafe {
53            from_glib_full(ffi::gst_vulkan_window_get_display(
54                self.as_ref().to_glib_none().0,
55            ))
56        }
57    }
58
59    #[doc(alias = "gst_vulkan_window_get_presentation_support")]
60    #[doc(alias = "get_presentation_support")]
61    fn is_presentation_support(
62        &self,
63        device: &impl IsA<VulkanDevice>,
64        queue_family_idx: u32,
65    ) -> bool {
66        unsafe {
67            from_glib(ffi::gst_vulkan_window_get_presentation_support(
68                self.as_ref().to_glib_none().0,
69                device.as_ref().to_glib_none().0,
70                queue_family_idx,
71            ))
72        }
73    }
74
75    //#[doc(alias = "gst_vulkan_window_get_surface")]
76    //#[doc(alias = "get_surface")]
77    //fn surface(&self) -> Result</*Ignored*/vulkan::SurfaceKHR, glib::Error> {
78    //    unsafe { TODO: call ffi:gst_vulkan_window_get_surface() }
79    //}
80
81    #[doc(alias = "gst_vulkan_window_get_surface_dimensions")]
82    #[doc(alias = "get_surface_dimensions")]
83    fn surface_dimensions(&self) -> (u32, u32) {
84        unsafe {
85            let mut width = std::mem::MaybeUninit::uninit();
86            let mut height = std::mem::MaybeUninit::uninit();
87            ffi::gst_vulkan_window_get_surface_dimensions(
88                self.as_ref().to_glib_none().0,
89                width.as_mut_ptr(),
90                height.as_mut_ptr(),
91            );
92            (width.assume_init(), height.assume_init())
93        }
94    }
95
96    #[doc(alias = "gst_vulkan_window_handle_events")]
97    fn handle_events(&self, handle_events: bool) {
98        unsafe {
99            ffi::gst_vulkan_window_handle_events(
100                self.as_ref().to_glib_none().0,
101                handle_events.into_glib(),
102            );
103        }
104    }
105
106    #[doc(alias = "gst_vulkan_window_open")]
107    fn open(&self) -> Result<(), glib::Error> {
108        unsafe {
109            let mut error = std::ptr::null_mut();
110            let is_ok = ffi::gst_vulkan_window_open(self.as_ref().to_glib_none().0, &mut error);
111            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
112            if error.is_null() {
113                Ok(())
114            } else {
115                Err(from_glib_full(error))
116            }
117        }
118    }
119
120    #[doc(alias = "gst_vulkan_window_redraw")]
121    fn redraw(&self) {
122        unsafe {
123            ffi::gst_vulkan_window_redraw(self.as_ref().to_glib_none().0);
124        }
125    }
126
127    #[doc(alias = "gst_vulkan_window_resize")]
128    fn resize(&self, width: i32, height: i32) {
129        unsafe {
130            ffi::gst_vulkan_window_resize(self.as_ref().to_glib_none().0, width, height);
131        }
132    }
133
134    #[doc(alias = "gst_vulkan_window_send_key_event")]
135    fn send_key_event(&self, event_type: &str, key_str: &str) {
136        unsafe {
137            ffi::gst_vulkan_window_send_key_event(
138                self.as_ref().to_glib_none().0,
139                event_type.to_glib_none().0,
140                key_str.to_glib_none().0,
141            );
142        }
143    }
144
145    #[doc(alias = "gst_vulkan_window_send_mouse_event")]
146    fn send_mouse_event(&self, event_type: &str, button: i32, posx: f64, posy: f64) {
147        unsafe {
148            ffi::gst_vulkan_window_send_mouse_event(
149                self.as_ref().to_glib_none().0,
150                event_type.to_glib_none().0,
151                button,
152                posx,
153                posy,
154            );
155        }
156    }
157
158    //#[doc(alias = "gst_vulkan_window_set_window_handle")]
159    //fn set_window_handle(&self, handle: /*Unimplemented*/Basic: UIntPtr) {
160    //    unsafe { TODO: call ffi:gst_vulkan_window_set_window_handle() }
161    //}
162
163    #[doc(alias = "close")]
164    fn connect_close<F: Fn(&Self) -> bool + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
165        unsafe extern "C" fn close_trampoline<
166            P: IsA<VulkanWindow>,
167            F: Fn(&P) -> bool + Send + Sync + 'static,
168        >(
169            this: *mut ffi::GstVulkanWindow,
170            f: glib::ffi::gpointer,
171        ) -> glib::ffi::gboolean {
172            unsafe {
173                let f: &F = &*(f as *const F);
174                f(VulkanWindow::from_glib_borrow(this).unsafe_cast_ref()).into_glib()
175            }
176        }
177        unsafe {
178            let f: Box_<F> = Box_::new(f);
179            connect_raw(
180                self.as_ptr() as *mut _,
181                c"close".as_ptr(),
182                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
183                    close_trampoline::<Self, F> as *const (),
184                )),
185                Box_::into_raw(f),
186            )
187        }
188    }
189
190    #[doc(alias = "draw")]
191    fn connect_draw<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
192        unsafe extern "C" fn draw_trampoline<
193            P: IsA<VulkanWindow>,
194            F: Fn(&P) + Send + Sync + 'static,
195        >(
196            this: *mut ffi::GstVulkanWindow,
197            f: glib::ffi::gpointer,
198        ) {
199            unsafe {
200                let f: &F = &*(f as *const F);
201                f(VulkanWindow::from_glib_borrow(this).unsafe_cast_ref())
202            }
203        }
204        unsafe {
205            let f: Box_<F> = Box_::new(f);
206            connect_raw(
207                self.as_ptr() as *mut _,
208                c"draw".as_ptr(),
209                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
210                    draw_trampoline::<Self, F> as *const (),
211                )),
212                Box_::into_raw(f),
213            )
214        }
215    }
216
217    #[doc(alias = "key-event")]
218    fn connect_key_event<F: Fn(&Self, &str, &str) + Send + Sync + 'static>(
219        &self,
220        f: F,
221    ) -> SignalHandlerId {
222        unsafe extern "C" fn key_event_trampoline<
223            P: IsA<VulkanWindow>,
224            F: Fn(&P, &str, &str) + Send + Sync + 'static,
225        >(
226            this: *mut ffi::GstVulkanWindow,
227            id: *mut std::ffi::c_char,
228            key: *mut std::ffi::c_char,
229            f: glib::ffi::gpointer,
230        ) {
231            unsafe {
232                let f: &F = &*(f as *const F);
233                f(
234                    VulkanWindow::from_glib_borrow(this).unsafe_cast_ref(),
235                    &glib::GString::from_glib_borrow(id),
236                    &glib::GString::from_glib_borrow(key),
237                )
238            }
239        }
240        unsafe {
241            let f: Box_<F> = Box_::new(f);
242            connect_raw(
243                self.as_ptr() as *mut _,
244                c"key-event".as_ptr(),
245                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
246                    key_event_trampoline::<Self, F> as *const (),
247                )),
248                Box_::into_raw(f),
249            )
250        }
251    }
252
253    #[doc(alias = "mouse-event")]
254    fn connect_mouse_event<F: Fn(&Self, &str, i32, f64, f64) + Send + Sync + 'static>(
255        &self,
256        f: F,
257    ) -> SignalHandlerId {
258        unsafe extern "C" fn mouse_event_trampoline<
259            P: IsA<VulkanWindow>,
260            F: Fn(&P, &str, i32, f64, f64) + Send + Sync + 'static,
261        >(
262            this: *mut ffi::GstVulkanWindow,
263            id: *mut std::ffi::c_char,
264            button: std::ffi::c_int,
265            x: std::ffi::c_double,
266            y: std::ffi::c_double,
267            f: glib::ffi::gpointer,
268        ) {
269            unsafe {
270                let f: &F = &*(f as *const F);
271                f(
272                    VulkanWindow::from_glib_borrow(this).unsafe_cast_ref(),
273                    &glib::GString::from_glib_borrow(id),
274                    button,
275                    x,
276                    y,
277                )
278            }
279        }
280        unsafe {
281            let f: Box_<F> = Box_::new(f);
282            connect_raw(
283                self.as_ptr() as *mut _,
284                c"mouse-event".as_ptr(),
285                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
286                    mouse_event_trampoline::<Self, F> as *const (),
287                )),
288                Box_::into_raw(f),
289            )
290        }
291    }
292
293    #[doc(alias = "resize")]
294    fn connect_resize<F: Fn(&Self, u32, u32) + Send + Sync + 'static>(
295        &self,
296        f: F,
297    ) -> SignalHandlerId {
298        unsafe extern "C" fn resize_trampoline<
299            P: IsA<VulkanWindow>,
300            F: Fn(&P, u32, u32) + Send + Sync + 'static,
301        >(
302            this: *mut ffi::GstVulkanWindow,
303            object: std::ffi::c_uint,
304            p0: std::ffi::c_uint,
305            f: glib::ffi::gpointer,
306        ) {
307            unsafe {
308                let f: &F = &*(f as *const F);
309                f(
310                    VulkanWindow::from_glib_borrow(this).unsafe_cast_ref(),
311                    object,
312                    p0,
313                )
314            }
315        }
316        unsafe {
317            let f: Box_<F> = Box_::new(f);
318            connect_raw(
319                self.as_ptr() as *mut _,
320                c"resize".as_ptr(),
321                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
322                    resize_trampoline::<Self, F> as *const (),
323                )),
324                Box_::into_raw(f),
325            )
326        }
327    }
328
329    #[doc(alias = "display")]
330    fn connect_display_notify<F: Fn(&Self) + Send + Sync + 'static>(
331        &self,
332        f: F,
333    ) -> SignalHandlerId {
334        unsafe extern "C" fn notify_display_trampoline<
335            P: IsA<VulkanWindow>,
336            F: Fn(&P) + Send + Sync + 'static,
337        >(
338            this: *mut ffi::GstVulkanWindow,
339            _param_spec: glib::ffi::gpointer,
340            f: glib::ffi::gpointer,
341        ) {
342            unsafe {
343                let f: &F = &*(f as *const F);
344                f(VulkanWindow::from_glib_borrow(this).unsafe_cast_ref())
345            }
346        }
347        unsafe {
348            let f: Box_<F> = Box_::new(f);
349            connect_raw(
350                self.as_ptr() as *mut _,
351                c"notify::display".as_ptr(),
352                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
353                    notify_display_trampoline::<Self, F> as *const (),
354                )),
355                Box_::into_raw(f),
356            )
357        }
358    }
359}
360
361impl<O: IsA<VulkanWindow>> VulkanWindowExt for O {}