Skip to main content

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 crate::{Display, Visual, Window, ffi};
6use glib::{
7    object::ObjectType as _,
8    prelude::*,
9    signal::{SignalHandlerId, connect_raw},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "GdkScreen")]
16    pub struct Screen(Object<ffi::GdkScreen>);
17
18    match fn {
19        type_ => || ffi::gdk_screen_get_type(),
20    }
21}
22
23impl Screen {
24    #[doc(alias = "gdk_screen_get_display")]
25    #[doc(alias = "get_display")]
26    pub fn display(&self) -> Display {
27        unsafe { from_glib_none(ffi::gdk_screen_get_display(self.to_glib_none().0)) }
28    }
29
30    #[doc(alias = "gdk_screen_get_resolution")]
31    #[doc(alias = "get_resolution")]
32    pub fn resolution(&self) -> f64 {
33        unsafe { ffi::gdk_screen_get_resolution(self.to_glib_none().0) }
34    }
35
36    #[doc(alias = "gdk_screen_get_rgba_visual")]
37    #[doc(alias = "get_rgba_visual")]
38    pub fn rgba_visual(&self) -> Option<Visual> {
39        unsafe { from_glib_none(ffi::gdk_screen_get_rgba_visual(self.to_glib_none().0)) }
40    }
41
42    #[doc(alias = "gdk_screen_get_root_window")]
43    #[doc(alias = "get_root_window")]
44    pub fn root_window(&self) -> Option<Window> {
45        unsafe { from_glib_none(ffi::gdk_screen_get_root_window(self.to_glib_none().0)) }
46    }
47
48    #[doc(alias = "gdk_screen_get_system_visual")]
49    #[doc(alias = "get_system_visual")]
50    pub fn system_visual(&self) -> Option<Visual> {
51        unsafe { from_glib_none(ffi::gdk_screen_get_system_visual(self.to_glib_none().0)) }
52    }
53
54    #[doc(alias = "gdk_screen_get_toplevel_windows")]
55    #[doc(alias = "get_toplevel_windows")]
56    pub fn toplevel_windows(&self) -> Vec<Window> {
57        unsafe {
58            FromGlibPtrContainer::from_glib_container(ffi::gdk_screen_get_toplevel_windows(
59                self.to_glib_none().0,
60            ))
61        }
62    }
63
64    #[doc(alias = "gdk_screen_get_window_stack")]
65    #[doc(alias = "get_window_stack")]
66    pub fn window_stack(&self) -> Vec<Window> {
67        unsafe {
68            FromGlibPtrContainer::from_glib_full(ffi::gdk_screen_get_window_stack(
69                self.to_glib_none().0,
70            ))
71        }
72    }
73
74    #[doc(alias = "gdk_screen_is_composited")]
75    pub fn is_composited(&self) -> bool {
76        unsafe { from_glib(ffi::gdk_screen_is_composited(self.to_glib_none().0)) }
77    }
78
79    #[doc(alias = "gdk_screen_list_visuals")]
80    pub fn list_visuals(&self) -> Vec<Visual> {
81        unsafe {
82            FromGlibPtrContainer::from_glib_container(ffi::gdk_screen_list_visuals(
83                self.to_glib_none().0,
84            ))
85        }
86    }
87
88    #[doc(alias = "gdk_screen_set_font_options")]
89    #[doc(alias = "font-options")]
90    pub fn set_font_options(&self, options: Option<&cairo::FontOptions>) {
91        unsafe {
92            ffi::gdk_screen_set_font_options(self.to_glib_none().0, options.to_glib_none().0);
93        }
94    }
95
96    #[doc(alias = "gdk_screen_set_resolution")]
97    #[doc(alias = "resolution")]
98    pub fn set_resolution(&self, dpi: f64) {
99        unsafe {
100            ffi::gdk_screen_set_resolution(self.to_glib_none().0, dpi);
101        }
102    }
103
104    #[doc(alias = "gdk_screen_get_default")]
105    #[doc(alias = "get_default")]
106    #[allow(clippy::should_implement_trait)]
107    pub fn default() -> Option<Screen> {
108        assert_initialized_main_thread!();
109        unsafe { from_glib_none(ffi::gdk_screen_get_default()) }
110    }
111
112    #[doc(alias = "composited-changed")]
113    pub fn connect_composited_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
114        unsafe extern "C" fn composited_changed_trampoline<F: Fn(&Screen) + 'static>(
115            this: *mut ffi::GdkScreen,
116            f: glib::ffi::gpointer,
117        ) {
118            unsafe {
119                let f: &F = &*(f as *const F);
120                f(&from_glib_borrow(this))
121            }
122        }
123        unsafe {
124            let f: Box_<F> = Box_::new(f);
125            connect_raw(
126                self.as_ptr() as *mut _,
127                c"composited-changed".as_ptr(),
128                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
129                    composited_changed_trampoline::<F> as *const (),
130                )),
131                Box_::into_raw(f),
132            )
133        }
134    }
135
136    #[doc(alias = "monitors-changed")]
137    pub fn connect_monitors_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
138        unsafe extern "C" fn monitors_changed_trampoline<F: Fn(&Screen) + 'static>(
139            this: *mut ffi::GdkScreen,
140            f: glib::ffi::gpointer,
141        ) {
142            unsafe {
143                let f: &F = &*(f as *const F);
144                f(&from_glib_borrow(this))
145            }
146        }
147        unsafe {
148            let f: Box_<F> = Box_::new(f);
149            connect_raw(
150                self.as_ptr() as *mut _,
151                c"monitors-changed".as_ptr(),
152                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
153                    monitors_changed_trampoline::<F> as *const (),
154                )),
155                Box_::into_raw(f),
156            )
157        }
158    }
159
160    #[doc(alias = "size-changed")]
161    pub fn connect_size_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
162        unsafe extern "C" fn size_changed_trampoline<F: Fn(&Screen) + 'static>(
163            this: *mut ffi::GdkScreen,
164            f: glib::ffi::gpointer,
165        ) {
166            unsafe {
167                let f: &F = &*(f as *const F);
168                f(&from_glib_borrow(this))
169            }
170        }
171        unsafe {
172            let f: Box_<F> = Box_::new(f);
173            connect_raw(
174                self.as_ptr() as *mut _,
175                c"size-changed".as_ptr(),
176                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
177                    size_changed_trampoline::<F> as *const (),
178                )),
179                Box_::into_raw(f),
180            )
181        }
182    }
183
184    #[doc(alias = "font-options")]
185    pub fn connect_font_options_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
186        unsafe extern "C" fn notify_font_options_trampoline<F: Fn(&Screen) + 'static>(
187            this: *mut ffi::GdkScreen,
188            _param_spec: glib::ffi::gpointer,
189            f: glib::ffi::gpointer,
190        ) {
191            unsafe {
192                let f: &F = &*(f as *const F);
193                f(&from_glib_borrow(this))
194            }
195        }
196        unsafe {
197            let f: Box_<F> = Box_::new(f);
198            connect_raw(
199                self.as_ptr() as *mut _,
200                c"notify::font-options".as_ptr(),
201                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
202                    notify_font_options_trampoline::<F> as *const (),
203                )),
204                Box_::into_raw(f),
205            )
206        }
207    }
208
209    #[doc(alias = "resolution")]
210    pub fn connect_resolution_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
211        unsafe extern "C" fn notify_resolution_trampoline<F: Fn(&Screen) + 'static>(
212            this: *mut ffi::GdkScreen,
213            _param_spec: glib::ffi::gpointer,
214            f: glib::ffi::gpointer,
215        ) {
216            unsafe {
217                let f: &F = &*(f as *const F);
218                f(&from_glib_borrow(this))
219            }
220        }
221        unsafe {
222            let f: Box_<F> = Box_::new(f);
223            connect_raw(
224                self.as_ptr() as *mut _,
225                c"notify::resolution".as_ptr(),
226                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
227                    notify_resolution_trampoline::<F> as *const (),
228                )),
229                Box_::into_raw(f),
230            )
231        }
232    }
233}