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 
5 use crate::AppLaunchContext;
6 use crate::Atom;
7 use crate::Device;
8 use crate::DeviceManager;
9 use crate::Event;
10 #[cfg(any(feature = "v3_22", feature = "dox"))]
11 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))]
12 use crate::Monitor;
13 use crate::Screen;
14 #[cfg(any(feature = "v3_20", feature = "dox"))]
15 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
16 use crate::Seat;
17 use crate::Window;
18 use glib::object::ObjectType as ObjectType_;
19 use glib::signal::connect_raw;
20 use glib::signal::SignalHandlerId;
21 use glib::translate::*;
22 use std::boxed::Box as Box_;
23 use std::fmt;
24 use std::mem;
25 use std::mem::transmute;
26 
27 glib::wrapper! {
28     #[doc(alias = "GdkDisplay")]
29     pub struct Display(Object<ffi::GdkDisplay>);
30 
31     match fn {
32         type_ => || ffi::gdk_display_get_type(),
33     }
34 }
35 
36 impl Display {
37     #[doc(alias = "gdk_display_beep")]
beep(&self)38     pub fn beep(&self) {
39         unsafe {
40             ffi::gdk_display_beep(self.to_glib_none().0);
41         }
42     }
43 
44     #[doc(alias = "gdk_display_close")]
close(&self)45     pub fn close(&self) {
46         unsafe {
47             ffi::gdk_display_close(self.to_glib_none().0);
48         }
49     }
50 
51     #[doc(alias = "gdk_display_device_is_grabbed")]
device_is_grabbed(&self, device: &Device) -> bool52     pub fn device_is_grabbed(&self, device: &Device) -> bool {
53         unsafe {
54             from_glib(ffi::gdk_display_device_is_grabbed(
55                 self.to_glib_none().0,
56                 device.to_glib_none().0,
57             ))
58         }
59     }
60 
61     #[doc(alias = "gdk_display_flush")]
flush(&self)62     pub fn flush(&self) {
63         unsafe {
64             ffi::gdk_display_flush(self.to_glib_none().0);
65         }
66     }
67 
68     #[doc(alias = "gdk_display_get_app_launch_context")]
69     #[doc(alias = "get_app_launch_context")]
app_launch_context(&self) -> Option<AppLaunchContext>70     pub fn app_launch_context(&self) -> Option<AppLaunchContext> {
71         unsafe {
72             from_glib_full(ffi::gdk_display_get_app_launch_context(
73                 self.to_glib_none().0,
74             ))
75         }
76     }
77 
78     #[doc(alias = "gdk_display_get_default_cursor_size")]
79     #[doc(alias = "get_default_cursor_size")]
default_cursor_size(&self) -> u3280     pub fn default_cursor_size(&self) -> u32 {
81         unsafe { ffi::gdk_display_get_default_cursor_size(self.to_glib_none().0) }
82     }
83 
84     #[doc(alias = "gdk_display_get_default_group")]
85     #[doc(alias = "get_default_group")]
default_group(&self) -> Window86     pub fn default_group(&self) -> Window {
87         unsafe { from_glib_none(ffi::gdk_display_get_default_group(self.to_glib_none().0)) }
88     }
89 
90     #[doc(alias = "gdk_display_get_default_screen")]
91     #[doc(alias = "get_default_screen")]
default_screen(&self) -> Screen92     pub fn default_screen(&self) -> Screen {
93         unsafe { from_glib_none(ffi::gdk_display_get_default_screen(self.to_glib_none().0)) }
94     }
95 
96     #[cfg(any(feature = "v3_20", feature = "dox"))]
97     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
98     #[doc(alias = "gdk_display_get_default_seat")]
99     #[doc(alias = "get_default_seat")]
default_seat(&self) -> Option<Seat>100     pub fn default_seat(&self) -> Option<Seat> {
101         unsafe { from_glib_none(ffi::gdk_display_get_default_seat(self.to_glib_none().0)) }
102     }
103 
104     #[cfg_attr(feature = "v3_20", deprecated = "Since 3.20")]
105     #[doc(alias = "gdk_display_get_device_manager")]
106     #[doc(alias = "get_device_manager")]
device_manager(&self) -> Option<DeviceManager>107     pub fn device_manager(&self) -> Option<DeviceManager> {
108         unsafe { from_glib_none(ffi::gdk_display_get_device_manager(self.to_glib_none().0)) }
109     }
110 
111     #[doc(alias = "gdk_display_get_event")]
112     #[doc(alias = "get_event")]
event(&self) -> Option<Event>113     pub fn event(&self) -> Option<Event> {
114         unsafe { from_glib_full(ffi::gdk_display_get_event(self.to_glib_none().0)) }
115     }
116 
117     #[doc(alias = "gdk_display_get_maximal_cursor_size")]
118     #[doc(alias = "get_maximal_cursor_size")]
maximal_cursor_size(&self) -> (u32, u32)119     pub fn maximal_cursor_size(&self) -> (u32, u32) {
120         unsafe {
121             let mut width = mem::MaybeUninit::uninit();
122             let mut height = mem::MaybeUninit::uninit();
123             ffi::gdk_display_get_maximal_cursor_size(
124                 self.to_glib_none().0,
125                 width.as_mut_ptr(),
126                 height.as_mut_ptr(),
127             );
128             let width = width.assume_init();
129             let height = height.assume_init();
130             (width, height)
131         }
132     }
133 
134     #[cfg(any(feature = "v3_22", feature = "dox"))]
135     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))]
136     #[doc(alias = "gdk_display_get_monitor")]
137     #[doc(alias = "get_monitor")]
monitor(&self, monitor_num: i32) -> Option<Monitor>138     pub fn monitor(&self, monitor_num: i32) -> Option<Monitor> {
139         unsafe {
140             from_glib_none(ffi::gdk_display_get_monitor(
141                 self.to_glib_none().0,
142                 monitor_num,
143             ))
144         }
145     }
146 
147     #[cfg(any(feature = "v3_22", feature = "dox"))]
148     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))]
149     #[doc(alias = "gdk_display_get_monitor_at_point")]
150     #[doc(alias = "get_monitor_at_point")]
monitor_at_point(&self, x: i32, y: i32) -> Option<Monitor>151     pub fn monitor_at_point(&self, x: i32, y: i32) -> Option<Monitor> {
152         unsafe {
153             from_glib_none(ffi::gdk_display_get_monitor_at_point(
154                 self.to_glib_none().0,
155                 x,
156                 y,
157             ))
158         }
159     }
160 
161     #[cfg(any(feature = "v3_22", feature = "dox"))]
162     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))]
163     #[doc(alias = "gdk_display_get_monitor_at_window")]
164     #[doc(alias = "get_monitor_at_window")]
monitor_at_window(&self, window: &Window) -> Option<Monitor>165     pub fn monitor_at_window(&self, window: &Window) -> Option<Monitor> {
166         unsafe {
167             from_glib_none(ffi::gdk_display_get_monitor_at_window(
168                 self.to_glib_none().0,
169                 window.to_glib_none().0,
170             ))
171         }
172     }
173 
174     #[cfg(any(feature = "v3_22", feature = "dox"))]
175     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))]
176     #[doc(alias = "gdk_display_get_n_monitors")]
177     #[doc(alias = "get_n_monitors")]
n_monitors(&self) -> i32178     pub fn n_monitors(&self) -> i32 {
179         unsafe { ffi::gdk_display_get_n_monitors(self.to_glib_none().0) }
180     }
181 
182     #[doc(alias = "gdk_display_get_name")]
183     #[doc(alias = "get_name")]
name(&self) -> glib::GString184     pub fn name(&self) -> glib::GString {
185         unsafe { from_glib_none(ffi::gdk_display_get_name(self.to_glib_none().0)) }
186     }
187 
188     #[cfg(any(feature = "v3_22", feature = "dox"))]
189     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))]
190     #[doc(alias = "gdk_display_get_primary_monitor")]
191     #[doc(alias = "get_primary_monitor")]
primary_monitor(&self) -> Option<Monitor>192     pub fn primary_monitor(&self) -> Option<Monitor> {
193         unsafe { from_glib_none(ffi::gdk_display_get_primary_monitor(self.to_glib_none().0)) }
194     }
195 
196     #[cfg_attr(feature = "v3_20", deprecated = "Since 3.20")]
197     #[doc(alias = "gdk_display_get_screen")]
198     #[doc(alias = "get_screen")]
screen(&self, screen_num: i32) -> Screen199     pub fn screen(&self, screen_num: i32) -> Screen {
200         unsafe {
201             from_glib_none(ffi::gdk_display_get_screen(
202                 self.to_glib_none().0,
203                 screen_num,
204             ))
205         }
206     }
207 
208     #[doc(alias = "gdk_display_has_pending")]
has_pending(&self) -> bool209     pub fn has_pending(&self) -> bool {
210         unsafe { from_glib(ffi::gdk_display_has_pending(self.to_glib_none().0)) }
211     }
212 
213     #[doc(alias = "gdk_display_is_closed")]
is_closed(&self) -> bool214     pub fn is_closed(&self) -> bool {
215         unsafe { from_glib(ffi::gdk_display_is_closed(self.to_glib_none().0)) }
216     }
217 
218     #[cfg(any(feature = "v3_20", feature = "dox"))]
219     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
220     #[doc(alias = "gdk_display_list_seats")]
list_seats(&self) -> Vec<Seat>221     pub fn list_seats(&self) -> Vec<Seat> {
222         unsafe {
223             FromGlibPtrContainer::from_glib_container(ffi::gdk_display_list_seats(
224                 self.to_glib_none().0,
225             ))
226         }
227     }
228 
229     #[doc(alias = "gdk_display_notify_startup_complete")]
notify_startup_complete(&self, startup_id: &str)230     pub fn notify_startup_complete(&self, startup_id: &str) {
231         unsafe {
232             ffi::gdk_display_notify_startup_complete(
233                 self.to_glib_none().0,
234                 startup_id.to_glib_none().0,
235             );
236         }
237     }
238 
239     #[doc(alias = "gdk_display_peek_event")]
peek_event(&self) -> Option<Event>240     pub fn peek_event(&self) -> Option<Event> {
241         unsafe { from_glib_full(ffi::gdk_display_peek_event(self.to_glib_none().0)) }
242     }
243 
244     #[doc(alias = "gdk_display_put_event")]
put_event(&self, event: &Event)245     pub fn put_event(&self, event: &Event) {
246         unsafe {
247             ffi::gdk_display_put_event(self.to_glib_none().0, event.to_glib_none().0);
248         }
249     }
250 
251     #[doc(alias = "gdk_display_request_selection_notification")]
request_selection_notification(&self, selection: &Atom) -> bool252     pub fn request_selection_notification(&self, selection: &Atom) -> bool {
253         unsafe {
254             from_glib(ffi::gdk_display_request_selection_notification(
255                 self.to_glib_none().0,
256                 selection.to_glib_none().0,
257             ))
258         }
259     }
260 
261     #[doc(alias = "gdk_display_set_double_click_distance")]
set_double_click_distance(&self, distance: u32)262     pub fn set_double_click_distance(&self, distance: u32) {
263         unsafe {
264             ffi::gdk_display_set_double_click_distance(self.to_glib_none().0, distance);
265         }
266     }
267 
268     #[doc(alias = "gdk_display_set_double_click_time")]
set_double_click_time(&self, msec: u32)269     pub fn set_double_click_time(&self, msec: u32) {
270         unsafe {
271             ffi::gdk_display_set_double_click_time(self.to_glib_none().0, msec);
272         }
273     }
274 
275     #[doc(alias = "gdk_display_store_clipboard")]
store_clipboard(&self, clipboard_window: &Window, time_: u32, targets: &[&Atom])276     pub fn store_clipboard(&self, clipboard_window: &Window, time_: u32, targets: &[&Atom]) {
277         let n_targets = targets.len() as i32;
278         unsafe {
279             ffi::gdk_display_store_clipboard(
280                 self.to_glib_none().0,
281                 clipboard_window.to_glib_none().0,
282                 time_,
283                 targets.to_glib_none().0,
284                 n_targets,
285             );
286         }
287     }
288 
289     #[doc(alias = "gdk_display_supports_clipboard_persistence")]
supports_clipboard_persistence(&self) -> bool290     pub fn supports_clipboard_persistence(&self) -> bool {
291         unsafe {
292             from_glib(ffi::gdk_display_supports_clipboard_persistence(
293                 self.to_glib_none().0,
294             ))
295         }
296     }
297 
298     #[doc(alias = "gdk_display_supports_cursor_alpha")]
supports_cursor_alpha(&self) -> bool299     pub fn supports_cursor_alpha(&self) -> bool {
300         unsafe {
301             from_glib(ffi::gdk_display_supports_cursor_alpha(
302                 self.to_glib_none().0,
303             ))
304         }
305     }
306 
307     #[doc(alias = "gdk_display_supports_cursor_color")]
supports_cursor_color(&self) -> bool308     pub fn supports_cursor_color(&self) -> bool {
309         unsafe {
310             from_glib(ffi::gdk_display_supports_cursor_color(
311                 self.to_glib_none().0,
312             ))
313         }
314     }
315 
316     #[doc(alias = "gdk_display_supports_input_shapes")]
supports_input_shapes(&self) -> bool317     pub fn supports_input_shapes(&self) -> bool {
318         unsafe {
319             from_glib(ffi::gdk_display_supports_input_shapes(
320                 self.to_glib_none().0,
321             ))
322         }
323     }
324 
325     #[doc(alias = "gdk_display_supports_selection_notification")]
supports_selection_notification(&self) -> bool326     pub fn supports_selection_notification(&self) -> bool {
327         unsafe {
328             from_glib(ffi::gdk_display_supports_selection_notification(
329                 self.to_glib_none().0,
330             ))
331         }
332     }
333 
334     #[doc(alias = "gdk_display_supports_shapes")]
supports_shapes(&self) -> bool335     pub fn supports_shapes(&self) -> bool {
336         unsafe { from_glib(ffi::gdk_display_supports_shapes(self.to_glib_none().0)) }
337     }
338 
339     #[doc(alias = "gdk_display_sync")]
sync(&self)340     pub fn sync(&self) {
341         unsafe {
342             ffi::gdk_display_sync(self.to_glib_none().0);
343         }
344     }
345 
346     #[doc(alias = "gdk_display_get_default")]
347     #[doc(alias = "get_default")]
default() -> Option<Display>348     pub fn default() -> Option<Display> {
349         assert_initialized_main_thread!();
350         unsafe { from_glib_none(ffi::gdk_display_get_default()) }
351     }
352 
353     #[doc(alias = "gdk_display_open")]
open(display_name: &str) -> Option<Display>354     pub fn open(display_name: &str) -> Option<Display> {
355         assert_initialized_main_thread!();
356         unsafe { from_glib_none(ffi::gdk_display_open(display_name.to_glib_none().0)) }
357     }
358 
359     #[doc(alias = "closed")]
connect_closed<F: Fn(&Self, bool) + 'static>(&self, f: F) -> SignalHandlerId360     pub fn connect_closed<F: Fn(&Self, bool) + 'static>(&self, f: F) -> SignalHandlerId {
361         unsafe extern "C" fn closed_trampoline<F: Fn(&Display, bool) + 'static>(
362             this: *mut ffi::GdkDisplay,
363             is_error: glib::ffi::gboolean,
364             f: glib::ffi::gpointer,
365         ) {
366             let f: &F = &*(f as *const F);
367             f(&from_glib_borrow(this), from_glib(is_error))
368         }
369         unsafe {
370             let f: Box_<F> = Box_::new(f);
371             connect_raw(
372                 self.as_ptr() as *mut _,
373                 b"closed\0".as_ptr() as *const _,
374                 Some(transmute::<_, unsafe extern "C" fn()>(
375                     closed_trampoline::<F> as *const (),
376                 )),
377                 Box_::into_raw(f),
378             )
379         }
380     }
381 
382     #[cfg(any(feature = "v3_22", feature = "dox"))]
383     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))]
384     #[doc(alias = "monitor-added")]
connect_monitor_added<F: Fn(&Self, &Monitor) + 'static>(&self, f: F) -> SignalHandlerId385     pub fn connect_monitor_added<F: Fn(&Self, &Monitor) + 'static>(&self, f: F) -> SignalHandlerId {
386         unsafe extern "C" fn monitor_added_trampoline<F: Fn(&Display, &Monitor) + 'static>(
387             this: *mut ffi::GdkDisplay,
388             monitor: *mut ffi::GdkMonitor,
389             f: glib::ffi::gpointer,
390         ) {
391             let f: &F = &*(f as *const F);
392             f(&from_glib_borrow(this), &from_glib_borrow(monitor))
393         }
394         unsafe {
395             let f: Box_<F> = Box_::new(f);
396             connect_raw(
397                 self.as_ptr() as *mut _,
398                 b"monitor-added\0".as_ptr() as *const _,
399                 Some(transmute::<_, unsafe extern "C" fn()>(
400                     monitor_added_trampoline::<F> as *const (),
401                 )),
402                 Box_::into_raw(f),
403             )
404         }
405     }
406 
407     #[cfg(any(feature = "v3_22", feature = "dox"))]
408     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))]
409     #[doc(alias = "monitor-removed")]
connect_monitor_removed<F: Fn(&Self, &Monitor) + 'static>( &self, f: F, ) -> SignalHandlerId410     pub fn connect_monitor_removed<F: Fn(&Self, &Monitor) + 'static>(
411         &self,
412         f: F,
413     ) -> SignalHandlerId {
414         unsafe extern "C" fn monitor_removed_trampoline<F: Fn(&Display, &Monitor) + 'static>(
415             this: *mut ffi::GdkDisplay,
416             monitor: *mut ffi::GdkMonitor,
417             f: glib::ffi::gpointer,
418         ) {
419             let f: &F = &*(f as *const F);
420             f(&from_glib_borrow(this), &from_glib_borrow(monitor))
421         }
422         unsafe {
423             let f: Box_<F> = Box_::new(f);
424             connect_raw(
425                 self.as_ptr() as *mut _,
426                 b"monitor-removed\0".as_ptr() as *const _,
427                 Some(transmute::<_, unsafe extern "C" fn()>(
428                     monitor_removed_trampoline::<F> as *const (),
429                 )),
430                 Box_::into_raw(f),
431             )
432         }
433     }
434 
435     #[doc(alias = "opened")]
connect_opened<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId436     pub fn connect_opened<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
437         unsafe extern "C" fn opened_trampoline<F: Fn(&Display) + 'static>(
438             this: *mut ffi::GdkDisplay,
439             f: glib::ffi::gpointer,
440         ) {
441             let f: &F = &*(f as *const F);
442             f(&from_glib_borrow(this))
443         }
444         unsafe {
445             let f: Box_<F> = Box_::new(f);
446             connect_raw(
447                 self.as_ptr() as *mut _,
448                 b"opened\0".as_ptr() as *const _,
449                 Some(transmute::<_, unsafe extern "C" fn()>(
450                     opened_trampoline::<F> as *const (),
451                 )),
452                 Box_::into_raw(f),
453             )
454         }
455     }
456 
457     #[cfg(any(feature = "v3_20", feature = "dox"))]
458     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
459     #[doc(alias = "seat-added")]
connect_seat_added<F: Fn(&Self, &Seat) + 'static>(&self, f: F) -> SignalHandlerId460     pub fn connect_seat_added<F: Fn(&Self, &Seat) + 'static>(&self, f: F) -> SignalHandlerId {
461         unsafe extern "C" fn seat_added_trampoline<F: Fn(&Display, &Seat) + 'static>(
462             this: *mut ffi::GdkDisplay,
463             seat: *mut ffi::GdkSeat,
464             f: glib::ffi::gpointer,
465         ) {
466             let f: &F = &*(f as *const F);
467             f(&from_glib_borrow(this), &from_glib_borrow(seat))
468         }
469         unsafe {
470             let f: Box_<F> = Box_::new(f);
471             connect_raw(
472                 self.as_ptr() as *mut _,
473                 b"seat-added\0".as_ptr() as *const _,
474                 Some(transmute::<_, unsafe extern "C" fn()>(
475                     seat_added_trampoline::<F> as *const (),
476                 )),
477                 Box_::into_raw(f),
478             )
479         }
480     }
481 
482     #[cfg(any(feature = "v3_20", feature = "dox"))]
483     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
484     #[doc(alias = "seat-removed")]
connect_seat_removed<F: Fn(&Self, &Seat) + 'static>(&self, f: F) -> SignalHandlerId485     pub fn connect_seat_removed<F: Fn(&Self, &Seat) + 'static>(&self, f: F) -> SignalHandlerId {
486         unsafe extern "C" fn seat_removed_trampoline<F: Fn(&Display, &Seat) + 'static>(
487             this: *mut ffi::GdkDisplay,
488             seat: *mut ffi::GdkSeat,
489             f: glib::ffi::gpointer,
490         ) {
491             let f: &F = &*(f as *const F);
492             f(&from_glib_borrow(this), &from_glib_borrow(seat))
493         }
494         unsafe {
495             let f: Box_<F> = Box_::new(f);
496             connect_raw(
497                 self.as_ptr() as *mut _,
498                 b"seat-removed\0".as_ptr() as *const _,
499                 Some(transmute::<_, unsafe extern "C" fn()>(
500                     seat_removed_trampoline::<F> as *const (),
501                 )),
502                 Box_::into_raw(f),
503             )
504         }
505     }
506 }
507 
508 impl fmt::Display for Display {
509     #[inline]
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result510     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
511         f.write_str(&self.name())
512     }
513 }
514