gdk/auto/
screen.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 cairo;
6use gdk_sys;
7use glib::object::IsA;
8use glib::object::ObjectType as ObjectType_;
9use glib::signal::connect_raw;
10use glib::signal::SignalHandlerId;
11use glib::translate::*;
12use glib::GString;
13use glib_sys;
14use std::boxed::Box as Box_;
15use std::fmt;
16use std::mem::transmute;
17use Display;
18use Rectangle;
19use Visual;
20use Window;
21
22glib_wrapper! {
23    pub struct Screen(Object<gdk_sys::GdkScreen, ScreenClass>);
24
25    match fn {
26        get_type => || gdk_sys::gdk_screen_get_type(),
27    }
28}
29
30impl Screen {
31    #[cfg_attr(feature = "v3_22", deprecated)]
32    pub fn get_active_window(&self) -> Option<Window> {
33        unsafe { from_glib_full(gdk_sys::gdk_screen_get_active_window(self.to_glib_none().0)) }
34    }
35
36    pub fn get_display(&self) -> Display {
37        unsafe { from_glib_none(gdk_sys::gdk_screen_get_display(self.to_glib_none().0)) }
38    }
39
40    #[cfg_attr(feature = "v3_22", deprecated)]
41    pub fn get_height(&self) -> i32 {
42        unsafe { gdk_sys::gdk_screen_get_height(self.to_glib_none().0) }
43    }
44
45    #[cfg_attr(feature = "v3_22", deprecated)]
46    pub fn get_height_mm(&self) -> i32 {
47        unsafe { gdk_sys::gdk_screen_get_height_mm(self.to_glib_none().0) }
48    }
49
50    #[cfg_attr(feature = "v3_22", deprecated)]
51    pub fn get_monitor_at_point(&self, x: i32, y: i32) -> i32 {
52        unsafe { gdk_sys::gdk_screen_get_monitor_at_point(self.to_glib_none().0, x, y) }
53    }
54
55    #[cfg_attr(feature = "v3_22", deprecated)]
56    pub fn get_monitor_at_window<P: IsA<Window>>(&self, window: &P) -> i32 {
57        unsafe {
58            gdk_sys::gdk_screen_get_monitor_at_window(
59                self.to_glib_none().0,
60                window.as_ref().to_glib_none().0,
61            )
62        }
63    }
64
65    #[cfg_attr(feature = "v3_22", deprecated)]
66    pub fn get_monitor_geometry(&self, monitor_num: i32) -> Rectangle {
67        unsafe {
68            let mut dest = Rectangle::uninitialized();
69            gdk_sys::gdk_screen_get_monitor_geometry(
70                self.to_glib_none().0,
71                monitor_num,
72                dest.to_glib_none_mut().0,
73            );
74            dest
75        }
76    }
77
78    #[cfg_attr(feature = "v3_22", deprecated)]
79    pub fn get_monitor_height_mm(&self, monitor_num: i32) -> i32 {
80        unsafe { gdk_sys::gdk_screen_get_monitor_height_mm(self.to_glib_none().0, monitor_num) }
81    }
82
83    #[cfg_attr(feature = "v3_22", deprecated)]
84    pub fn get_monitor_plug_name(&self, monitor_num: i32) -> Option<GString> {
85        unsafe {
86            from_glib_full(gdk_sys::gdk_screen_get_monitor_plug_name(
87                self.to_glib_none().0,
88                monitor_num,
89            ))
90        }
91    }
92
93    #[cfg_attr(feature = "v3_22", deprecated)]
94    pub fn get_monitor_scale_factor(&self, monitor_num: i32) -> i32 {
95        unsafe { gdk_sys::gdk_screen_get_monitor_scale_factor(self.to_glib_none().0, monitor_num) }
96    }
97
98    #[cfg_attr(feature = "v3_22", deprecated)]
99    pub fn get_monitor_width_mm(&self, monitor_num: i32) -> i32 {
100        unsafe { gdk_sys::gdk_screen_get_monitor_width_mm(self.to_glib_none().0, monitor_num) }
101    }
102
103    #[cfg_attr(feature = "v3_22", deprecated)]
104    pub fn get_monitor_workarea(&self, monitor_num: i32) -> Rectangle {
105        unsafe {
106            let mut dest = Rectangle::uninitialized();
107            gdk_sys::gdk_screen_get_monitor_workarea(
108                self.to_glib_none().0,
109                monitor_num,
110                dest.to_glib_none_mut().0,
111            );
112            dest
113        }
114    }
115
116    #[cfg_attr(feature = "v3_22", deprecated)]
117    pub fn get_n_monitors(&self) -> i32 {
118        unsafe { gdk_sys::gdk_screen_get_n_monitors(self.to_glib_none().0) }
119    }
120
121    #[cfg_attr(feature = "v3_22", deprecated)]
122    pub fn get_number(&self) -> i32 {
123        unsafe { gdk_sys::gdk_screen_get_number(self.to_glib_none().0) }
124    }
125
126    #[cfg_attr(feature = "v3_22", deprecated)]
127    pub fn get_primary_monitor(&self) -> i32 {
128        unsafe { gdk_sys::gdk_screen_get_primary_monitor(self.to_glib_none().0) }
129    }
130
131    pub fn get_resolution(&self) -> f64 {
132        unsafe { gdk_sys::gdk_screen_get_resolution(self.to_glib_none().0) }
133    }
134
135    pub fn get_rgba_visual(&self) -> Option<Visual> {
136        unsafe { from_glib_none(gdk_sys::gdk_screen_get_rgba_visual(self.to_glib_none().0)) }
137    }
138
139    pub fn get_root_window(&self) -> Option<Window> {
140        unsafe { from_glib_none(gdk_sys::gdk_screen_get_root_window(self.to_glib_none().0)) }
141    }
142
143    pub fn get_system_visual(&self) -> Option<Visual> {
144        unsafe { from_glib_none(gdk_sys::gdk_screen_get_system_visual(self.to_glib_none().0)) }
145    }
146
147    pub fn get_toplevel_windows(&self) -> Vec<Window> {
148        unsafe {
149            FromGlibPtrContainer::from_glib_container(gdk_sys::gdk_screen_get_toplevel_windows(
150                self.to_glib_none().0,
151            ))
152        }
153    }
154
155    #[cfg_attr(feature = "v3_22", deprecated)]
156    pub fn get_width(&self) -> i32 {
157        unsafe { gdk_sys::gdk_screen_get_width(self.to_glib_none().0) }
158    }
159
160    #[cfg_attr(feature = "v3_22", deprecated)]
161    pub fn get_width_mm(&self) -> i32 {
162        unsafe { gdk_sys::gdk_screen_get_width_mm(self.to_glib_none().0) }
163    }
164
165    pub fn get_window_stack(&self) -> Vec<Window> {
166        unsafe {
167            FromGlibPtrContainer::from_glib_full(gdk_sys::gdk_screen_get_window_stack(
168                self.to_glib_none().0,
169            ))
170        }
171    }
172
173    pub fn is_composited(&self) -> bool {
174        unsafe { from_glib(gdk_sys::gdk_screen_is_composited(self.to_glib_none().0)) }
175    }
176
177    pub fn list_visuals(&self) -> Vec<Visual> {
178        unsafe {
179            FromGlibPtrContainer::from_glib_container(gdk_sys::gdk_screen_list_visuals(
180                self.to_glib_none().0,
181            ))
182        }
183    }
184
185    #[cfg_attr(feature = "v3_22", deprecated)]
186    pub fn make_display_name(&self) -> GString {
187        unsafe { from_glib_full(gdk_sys::gdk_screen_make_display_name(self.to_glib_none().0)) }
188    }
189
190    pub fn set_font_options(&self, options: Option<&cairo::FontOptions>) {
191        unsafe {
192            gdk_sys::gdk_screen_set_font_options(self.to_glib_none().0, options.to_glib_none().0);
193        }
194    }
195
196    pub fn set_resolution(&self, dpi: f64) {
197        unsafe {
198            gdk_sys::gdk_screen_set_resolution(self.to_glib_none().0, dpi);
199        }
200    }
201
202    //pub fn get_property_font_options(&self) -> /*Unimplemented*/Fundamental: Pointer {
203    //    unsafe {
204    //        let mut value = Value::from_type(</*Unknown type*/ as StaticType>::static_type());
205    //        gobject_sys::g_object_get_property(self.as_ptr() as *mut gobject_sys::GObject, b"font-options\0".as_ptr() as *const _, value.to_glib_none_mut().0);
206    //        value.get().unwrap()
207    //    }
208    //}
209
210    pub fn get_default() -> Option<Screen> {
211        assert_initialized_main_thread!();
212        unsafe { from_glib_none(gdk_sys::gdk_screen_get_default()) }
213    }
214
215    #[cfg_attr(feature = "v3_22", deprecated)]
216    pub fn height() -> i32 {
217        assert_initialized_main_thread!();
218        unsafe { gdk_sys::gdk_screen_height() }
219    }
220
221    #[cfg_attr(feature = "v3_22", deprecated)]
222    pub fn height_mm() -> i32 {
223        assert_initialized_main_thread!();
224        unsafe { gdk_sys::gdk_screen_height_mm() }
225    }
226
227    #[cfg_attr(feature = "v3_22", deprecated)]
228    pub fn width() -> i32 {
229        assert_initialized_main_thread!();
230        unsafe { gdk_sys::gdk_screen_width() }
231    }
232
233    #[cfg_attr(feature = "v3_22", deprecated)]
234    pub fn width_mm() -> i32 {
235        assert_initialized_main_thread!();
236        unsafe { gdk_sys::gdk_screen_width_mm() }
237    }
238
239    pub fn connect_composited_changed<F: Fn(&Screen) + 'static>(&self, f: F) -> SignalHandlerId {
240        unsafe extern "C" fn composited_changed_trampoline<F: Fn(&Screen) + 'static>(
241            this: *mut gdk_sys::GdkScreen,
242            f: glib_sys::gpointer,
243        ) {
244            let f: &F = &*(f as *const F);
245            f(&from_glib_borrow(this))
246        }
247        unsafe {
248            let f: Box_<F> = Box_::new(f);
249            connect_raw(
250                self.as_ptr() as *mut _,
251                b"composited-changed\0".as_ptr() as *const _,
252                Some(transmute(composited_changed_trampoline::<F> as usize)),
253                Box_::into_raw(f),
254            )
255        }
256    }
257
258    pub fn connect_monitors_changed<F: Fn(&Screen) + 'static>(&self, f: F) -> SignalHandlerId {
259        unsafe extern "C" fn monitors_changed_trampoline<F: Fn(&Screen) + 'static>(
260            this: *mut gdk_sys::GdkScreen,
261            f: glib_sys::gpointer,
262        ) {
263            let f: &F = &*(f as *const F);
264            f(&from_glib_borrow(this))
265        }
266        unsafe {
267            let f: Box_<F> = Box_::new(f);
268            connect_raw(
269                self.as_ptr() as *mut _,
270                b"monitors-changed\0".as_ptr() as *const _,
271                Some(transmute(monitors_changed_trampoline::<F> as usize)),
272                Box_::into_raw(f),
273            )
274        }
275    }
276
277    pub fn connect_size_changed<F: Fn(&Screen) + 'static>(&self, f: F) -> SignalHandlerId {
278        unsafe extern "C" fn size_changed_trampoline<F: Fn(&Screen) + 'static>(
279            this: *mut gdk_sys::GdkScreen,
280            f: glib_sys::gpointer,
281        ) {
282            let f: &F = &*(f as *const F);
283            f(&from_glib_borrow(this))
284        }
285        unsafe {
286            let f: Box_<F> = Box_::new(f);
287            connect_raw(
288                self.as_ptr() as *mut _,
289                b"size-changed\0".as_ptr() as *const _,
290                Some(transmute(size_changed_trampoline::<F> as usize)),
291                Box_::into_raw(f),
292            )
293        }
294    }
295
296    pub fn connect_property_font_options_notify<F: Fn(&Screen) + 'static>(
297        &self,
298        f: F,
299    ) -> SignalHandlerId {
300        unsafe extern "C" fn notify_font_options_trampoline<F: Fn(&Screen) + 'static>(
301            this: *mut gdk_sys::GdkScreen,
302            _param_spec: glib_sys::gpointer,
303            f: glib_sys::gpointer,
304        ) {
305            let f: &F = &*(f as *const F);
306            f(&from_glib_borrow(this))
307        }
308        unsafe {
309            let f: Box_<F> = Box_::new(f);
310            connect_raw(
311                self.as_ptr() as *mut _,
312                b"notify::font-options\0".as_ptr() as *const _,
313                Some(transmute(notify_font_options_trampoline::<F> as usize)),
314                Box_::into_raw(f),
315            )
316        }
317    }
318
319    pub fn connect_property_resolution_notify<F: Fn(&Screen) + 'static>(
320        &self,
321        f: F,
322    ) -> SignalHandlerId {
323        unsafe extern "C" fn notify_resolution_trampoline<F: Fn(&Screen) + 'static>(
324            this: *mut gdk_sys::GdkScreen,
325            _param_spec: glib_sys::gpointer,
326            f: glib_sys::gpointer,
327        ) {
328            let f: &F = &*(f as *const F);
329            f(&from_glib_borrow(this))
330        }
331        unsafe {
332            let f: Box_<F> = Box_::new(f);
333            connect_raw(
334                self.as_ptr() as *mut _,
335                b"notify::resolution\0".as_ptr() as *const _,
336                Some(transmute(notify_resolution_trampoline::<F> as usize)),
337                Box_::into_raw(f),
338            )
339        }
340    }
341}
342
343impl fmt::Display for Screen {
344    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
345        write!(f, "Screen")
346    }
347}