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