[go: up one dir, main page]

gdk4/auto/
frame_clock.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// DO NOT EDIT
4
5use crate::{ffi, FrameClockPhase, FrameTimings};
6use glib::{
7    object::ObjectType as _,
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "GdkFrameClock")]
16    pub struct FrameClock(Object<ffi::GdkFrameClock, ffi::GdkFrameClockClass>);
17
18    match fn {
19        type_ => || ffi::gdk_frame_clock_get_type(),
20    }
21}
22
23impl FrameClock {
24    #[doc(alias = "gdk_frame_clock_begin_updating")]
25    pub fn begin_updating(&self) {
26        unsafe {
27            ffi::gdk_frame_clock_begin_updating(self.to_glib_none().0);
28        }
29    }
30
31    #[doc(alias = "gdk_frame_clock_end_updating")]
32    pub fn end_updating(&self) {
33        unsafe {
34            ffi::gdk_frame_clock_end_updating(self.to_glib_none().0);
35        }
36    }
37
38    #[doc(alias = "gdk_frame_clock_get_current_timings")]
39    #[doc(alias = "get_current_timings")]
40    pub fn current_timings(&self) -> Option<FrameTimings> {
41        unsafe {
42            from_glib_none(ffi::gdk_frame_clock_get_current_timings(
43                self.to_glib_none().0,
44            ))
45        }
46    }
47
48    #[doc(alias = "gdk_frame_clock_get_fps")]
49    #[doc(alias = "get_fps")]
50    pub fn fps(&self) -> f64 {
51        unsafe { ffi::gdk_frame_clock_get_fps(self.to_glib_none().0) }
52    }
53
54    #[doc(alias = "gdk_frame_clock_get_frame_counter")]
55    #[doc(alias = "get_frame_counter")]
56    pub fn frame_counter(&self) -> i64 {
57        unsafe { ffi::gdk_frame_clock_get_frame_counter(self.to_glib_none().0) }
58    }
59
60    #[doc(alias = "gdk_frame_clock_get_frame_time")]
61    #[doc(alias = "get_frame_time")]
62    pub fn frame_time(&self) -> i64 {
63        unsafe { ffi::gdk_frame_clock_get_frame_time(self.to_glib_none().0) }
64    }
65
66    #[doc(alias = "gdk_frame_clock_get_history_start")]
67    #[doc(alias = "get_history_start")]
68    pub fn history_start(&self) -> i64 {
69        unsafe { ffi::gdk_frame_clock_get_history_start(self.to_glib_none().0) }
70    }
71
72    #[doc(alias = "gdk_frame_clock_get_refresh_info")]
73    #[doc(alias = "get_refresh_info")]
74    pub fn refresh_info(&self, base_time: i64) -> (i64, i64) {
75        unsafe {
76            let mut refresh_interval_return = std::mem::MaybeUninit::uninit();
77            let mut presentation_time_return = std::mem::MaybeUninit::uninit();
78            ffi::gdk_frame_clock_get_refresh_info(
79                self.to_glib_none().0,
80                base_time,
81                refresh_interval_return.as_mut_ptr(),
82                presentation_time_return.as_mut_ptr(),
83            );
84            (
85                refresh_interval_return.assume_init(),
86                presentation_time_return.assume_init(),
87            )
88        }
89    }
90
91    #[doc(alias = "gdk_frame_clock_get_timings")]
92    #[doc(alias = "get_timings")]
93    pub fn timings(&self, frame_counter: i64) -> Option<FrameTimings> {
94        unsafe {
95            from_glib_none(ffi::gdk_frame_clock_get_timings(
96                self.to_glib_none().0,
97                frame_counter,
98            ))
99        }
100    }
101
102    #[doc(alias = "gdk_frame_clock_request_phase")]
103    pub fn request_phase(&self, phase: FrameClockPhase) {
104        unsafe {
105            ffi::gdk_frame_clock_request_phase(self.to_glib_none().0, phase.into_glib());
106        }
107    }
108
109    #[doc(alias = "after-paint")]
110    pub fn connect_after_paint<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
111        unsafe extern "C" fn after_paint_trampoline<F: Fn(&FrameClock) + 'static>(
112            this: *mut ffi::GdkFrameClock,
113            f: glib::ffi::gpointer,
114        ) {
115            let f: &F = &*(f as *const F);
116            f(&from_glib_borrow(this))
117        }
118        unsafe {
119            let f: Box_<F> = Box_::new(f);
120            connect_raw(
121                self.as_ptr() as *mut _,
122                c"after-paint".as_ptr() as *const _,
123                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
124                    after_paint_trampoline::<F> as *const (),
125                )),
126                Box_::into_raw(f),
127            )
128        }
129    }
130
131    #[doc(alias = "before-paint")]
132    pub fn connect_before_paint<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
133        unsafe extern "C" fn before_paint_trampoline<F: Fn(&FrameClock) + 'static>(
134            this: *mut ffi::GdkFrameClock,
135            f: glib::ffi::gpointer,
136        ) {
137            let f: &F = &*(f as *const F);
138            f(&from_glib_borrow(this))
139        }
140        unsafe {
141            let f: Box_<F> = Box_::new(f);
142            connect_raw(
143                self.as_ptr() as *mut _,
144                c"before-paint".as_ptr() as *const _,
145                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
146                    before_paint_trampoline::<F> as *const (),
147                )),
148                Box_::into_raw(f),
149            )
150        }
151    }
152
153    #[doc(alias = "flush-events")]
154    pub fn connect_flush_events<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
155        unsafe extern "C" fn flush_events_trampoline<F: Fn(&FrameClock) + 'static>(
156            this: *mut ffi::GdkFrameClock,
157            f: glib::ffi::gpointer,
158        ) {
159            let f: &F = &*(f as *const F);
160            f(&from_glib_borrow(this))
161        }
162        unsafe {
163            let f: Box_<F> = Box_::new(f);
164            connect_raw(
165                self.as_ptr() as *mut _,
166                c"flush-events".as_ptr() as *const _,
167                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
168                    flush_events_trampoline::<F> as *const (),
169                )),
170                Box_::into_raw(f),
171            )
172        }
173    }
174
175    #[doc(alias = "layout")]
176    pub fn connect_layout<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
177        unsafe extern "C" fn layout_trampoline<F: Fn(&FrameClock) + 'static>(
178            this: *mut ffi::GdkFrameClock,
179            f: glib::ffi::gpointer,
180        ) {
181            let f: &F = &*(f as *const F);
182            f(&from_glib_borrow(this))
183        }
184        unsafe {
185            let f: Box_<F> = Box_::new(f);
186            connect_raw(
187                self.as_ptr() as *mut _,
188                c"layout".as_ptr() as *const _,
189                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
190                    layout_trampoline::<F> as *const (),
191                )),
192                Box_::into_raw(f),
193            )
194        }
195    }
196
197    #[doc(alias = "paint")]
198    pub fn connect_paint<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
199        unsafe extern "C" fn paint_trampoline<F: Fn(&FrameClock) + 'static>(
200            this: *mut ffi::GdkFrameClock,
201            f: glib::ffi::gpointer,
202        ) {
203            let f: &F = &*(f as *const F);
204            f(&from_glib_borrow(this))
205        }
206        unsafe {
207            let f: Box_<F> = Box_::new(f);
208            connect_raw(
209                self.as_ptr() as *mut _,
210                c"paint".as_ptr() as *const _,
211                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
212                    paint_trampoline::<F> as *const (),
213                )),
214                Box_::into_raw(f),
215            )
216        }
217    }
218
219    #[doc(alias = "resume-events")]
220    pub fn connect_resume_events<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
221        unsafe extern "C" fn resume_events_trampoline<F: Fn(&FrameClock) + 'static>(
222            this: *mut ffi::GdkFrameClock,
223            f: glib::ffi::gpointer,
224        ) {
225            let f: &F = &*(f as *const F);
226            f(&from_glib_borrow(this))
227        }
228        unsafe {
229            let f: Box_<F> = Box_::new(f);
230            connect_raw(
231                self.as_ptr() as *mut _,
232                c"resume-events".as_ptr() as *const _,
233                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
234                    resume_events_trampoline::<F> as *const (),
235                )),
236                Box_::into_raw(f),
237            )
238        }
239    }
240
241    #[doc(alias = "update")]
242    pub fn connect_update<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
243        unsafe extern "C" fn update_trampoline<F: Fn(&FrameClock) + 'static>(
244            this: *mut ffi::GdkFrameClock,
245            f: glib::ffi::gpointer,
246        ) {
247            let f: &F = &*(f as *const F);
248            f(&from_glib_borrow(this))
249        }
250        unsafe {
251            let f: Box_<F> = Box_::new(f);
252            connect_raw(
253                self.as_ptr() as *mut _,
254                c"update".as_ptr() as *const _,
255                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
256                    update_trampoline::<F> as *const (),
257                )),
258                Box_::into_raw(f),
259            )
260        }
261    }
262}