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