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::Cursor;
6 use crate::Device;
7 #[cfg(any(feature = "v3_22", feature = "dox"))]
8 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))]
9 use crate::DeviceTool;
10 use crate::Display;
11 use crate::Event;
12 use crate::GrabStatus;
13 use crate::SeatCapabilities;
14 use crate::Window;
15 use glib::object::ObjectType as ObjectType_;
16 use glib::signal::connect_raw;
17 use glib::signal::SignalHandlerId;
18 use glib::translate::*;
19 use std::boxed::Box as Box_;
20 use std::fmt;
21 use std::mem::transmute;
22 
23 glib::wrapper! {
24     #[doc(alias = "GdkSeat")]
25     pub struct Seat(Object<ffi::GdkSeat>);
26 
27     match fn {
28         type_ => || ffi::gdk_seat_get_type(),
29     }
30 }
31 
32 impl Seat {
33     #[doc(alias = "gdk_seat_get_capabilities")]
34     #[doc(alias = "get_capabilities")]
capabilities(&self) -> SeatCapabilities35     pub fn capabilities(&self) -> SeatCapabilities {
36         unsafe { from_glib(ffi::gdk_seat_get_capabilities(self.to_glib_none().0)) }
37     }
38 
39     #[doc(alias = "gdk_seat_get_display")]
40     #[doc(alias = "get_display")]
display(&self) -> Option<Display>41     pub fn display(&self) -> Option<Display> {
42         unsafe { from_glib_none(ffi::gdk_seat_get_display(self.to_glib_none().0)) }
43     }
44 
45     #[doc(alias = "gdk_seat_get_keyboard")]
46     #[doc(alias = "get_keyboard")]
keyboard(&self) -> Option<Device>47     pub fn keyboard(&self) -> Option<Device> {
48         unsafe { from_glib_none(ffi::gdk_seat_get_keyboard(self.to_glib_none().0)) }
49     }
50 
51     #[doc(alias = "gdk_seat_get_pointer")]
52     #[doc(alias = "get_pointer")]
pointer(&self) -> Option<Device>53     pub fn pointer(&self) -> Option<Device> {
54         unsafe { from_glib_none(ffi::gdk_seat_get_pointer(self.to_glib_none().0)) }
55     }
56 
57     #[doc(alias = "gdk_seat_get_slaves")]
58     #[doc(alias = "get_slaves")]
slaves(&self, capabilities: SeatCapabilities) -> Vec<Device>59     pub fn slaves(&self, capabilities: SeatCapabilities) -> Vec<Device> {
60         unsafe {
61             FromGlibPtrContainer::from_glib_container(ffi::gdk_seat_get_slaves(
62                 self.to_glib_none().0,
63                 capabilities.into_glib(),
64             ))
65         }
66     }
67 
68     #[doc(alias = "gdk_seat_grab")]
grab( &self, window: &Window, capabilities: SeatCapabilities, owner_events: bool, cursor: Option<&Cursor>, event: Option<&Event>, prepare_func: Option<&mut dyn (FnMut(&Seat, &Window))>, ) -> GrabStatus69     pub fn grab(
70         &self,
71         window: &Window,
72         capabilities: SeatCapabilities,
73         owner_events: bool,
74         cursor: Option<&Cursor>,
75         event: Option<&Event>,
76         prepare_func: Option<&mut dyn (FnMut(&Seat, &Window))>,
77     ) -> GrabStatus {
78         let prepare_func_data: Option<&mut dyn (FnMut(&Seat, &Window))> = prepare_func;
79         unsafe extern "C" fn prepare_func_func(
80             seat: *mut ffi::GdkSeat,
81             window: *mut ffi::GdkWindow,
82             user_data: glib::ffi::gpointer,
83         ) {
84             let seat = from_glib_borrow(seat);
85             let window = from_glib_borrow(window);
86             let callback: *mut Option<&mut dyn (FnMut(&Seat, &Window))> =
87                 user_data as *const _ as usize as *mut Option<&mut dyn (FnMut(&Seat, &Window))>;
88             if let Some(ref mut callback) = *callback {
89                 callback(&seat, &window)
90             } else {
91                 panic!("cannot get closure...")
92             };
93         }
94         let prepare_func = if prepare_func_data.is_some() {
95             Some(prepare_func_func as _)
96         } else {
97             None
98         };
99         let super_callback0: &Option<&mut dyn (FnMut(&Seat, &Window))> = &prepare_func_data;
100         unsafe {
101             from_glib(ffi::gdk_seat_grab(
102                 self.to_glib_none().0,
103                 window.to_glib_none().0,
104                 capabilities.into_glib(),
105                 owner_events.into_glib(),
106                 cursor.to_glib_none().0,
107                 event.to_glib_none().0,
108                 prepare_func,
109                 super_callback0 as *const _ as usize as *mut _,
110             ))
111         }
112     }
113 
114     #[doc(alias = "gdk_seat_ungrab")]
ungrab(&self)115     pub fn ungrab(&self) {
116         unsafe {
117             ffi::gdk_seat_ungrab(self.to_glib_none().0);
118         }
119     }
120 
121     #[cfg(any(feature = "v3_20", feature = "dox"))]
122     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
123     #[doc(alias = "device-added")]
connect_device_added<F: Fn(&Self, &Device) + 'static>(&self, f: F) -> SignalHandlerId124     pub fn connect_device_added<F: Fn(&Self, &Device) + 'static>(&self, f: F) -> SignalHandlerId {
125         unsafe extern "C" fn device_added_trampoline<F: Fn(&Seat, &Device) + 'static>(
126             this: *mut ffi::GdkSeat,
127             device: *mut ffi::GdkDevice,
128             f: glib::ffi::gpointer,
129         ) {
130             let f: &F = &*(f as *const F);
131             f(&from_glib_borrow(this), &from_glib_borrow(device))
132         }
133         unsafe {
134             let f: Box_<F> = Box_::new(f);
135             connect_raw(
136                 self.as_ptr() as *mut _,
137                 b"device-added\0".as_ptr() as *const _,
138                 Some(transmute::<_, unsafe extern "C" fn()>(
139                     device_added_trampoline::<F> as *const (),
140                 )),
141                 Box_::into_raw(f),
142             )
143         }
144     }
145 
146     #[cfg(any(feature = "v3_20", feature = "dox"))]
147     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
148     #[doc(alias = "device-removed")]
connect_device_removed<F: Fn(&Self, &Device) + 'static>(&self, f: F) -> SignalHandlerId149     pub fn connect_device_removed<F: Fn(&Self, &Device) + 'static>(&self, f: F) -> SignalHandlerId {
150         unsafe extern "C" fn device_removed_trampoline<F: Fn(&Seat, &Device) + 'static>(
151             this: *mut ffi::GdkSeat,
152             device: *mut ffi::GdkDevice,
153             f: glib::ffi::gpointer,
154         ) {
155             let f: &F = &*(f as *const F);
156             f(&from_glib_borrow(this), &from_glib_borrow(device))
157         }
158         unsafe {
159             let f: Box_<F> = Box_::new(f);
160             connect_raw(
161                 self.as_ptr() as *mut _,
162                 b"device-removed\0".as_ptr() as *const _,
163                 Some(transmute::<_, unsafe extern "C" fn()>(
164                     device_removed_trampoline::<F> as *const (),
165                 )),
166                 Box_::into_raw(f),
167             )
168         }
169     }
170 
171     #[cfg(any(feature = "v3_22", feature = "dox"))]
172     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))]
173     #[doc(alias = "tool-added")]
connect_tool_added<F: Fn(&Self, &DeviceTool) + 'static>(&self, f: F) -> SignalHandlerId174     pub fn connect_tool_added<F: Fn(&Self, &DeviceTool) + 'static>(&self, f: F) -> SignalHandlerId {
175         unsafe extern "C" fn tool_added_trampoline<F: Fn(&Seat, &DeviceTool) + 'static>(
176             this: *mut ffi::GdkSeat,
177             tool: *mut ffi::GdkDeviceTool,
178             f: glib::ffi::gpointer,
179         ) {
180             let f: &F = &*(f as *const F);
181             f(&from_glib_borrow(this), &from_glib_borrow(tool))
182         }
183         unsafe {
184             let f: Box_<F> = Box_::new(f);
185             connect_raw(
186                 self.as_ptr() as *mut _,
187                 b"tool-added\0".as_ptr() as *const _,
188                 Some(transmute::<_, unsafe extern "C" fn()>(
189                     tool_added_trampoline::<F> as *const (),
190                 )),
191                 Box_::into_raw(f),
192             )
193         }
194     }
195 
196     #[cfg(any(feature = "v3_22", feature = "dox"))]
197     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))]
198     #[doc(alias = "tool-removed")]
connect_tool_removed<F: Fn(&Self, &DeviceTool) + 'static>( &self, f: F, ) -> SignalHandlerId199     pub fn connect_tool_removed<F: Fn(&Self, &DeviceTool) + 'static>(
200         &self,
201         f: F,
202     ) -> SignalHandlerId {
203         unsafe extern "C" fn tool_removed_trampoline<F: Fn(&Seat, &DeviceTool) + 'static>(
204             this: *mut ffi::GdkSeat,
205             tool: *mut ffi::GdkDeviceTool,
206             f: glib::ffi::gpointer,
207         ) {
208             let f: &F = &*(f as *const F);
209             f(&from_glib_borrow(this), &from_glib_borrow(tool))
210         }
211         unsafe {
212             let f: Box_<F> = Box_::new(f);
213             connect_raw(
214                 self.as_ptr() as *mut _,
215                 b"tool-removed\0".as_ptr() as *const _,
216                 Some(transmute::<_, unsafe extern "C" fn()>(
217                     tool_removed_trampoline::<F> as *const (),
218                 )),
219                 Box_::into_raw(f),
220             )
221         }
222     }
223 }
224 
225 impl fmt::Display for Seat {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result226     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
227         f.write_str("Seat")
228     }
229 }
230