Skip to main content

gdk4/auto/
seat.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::{Device, DeviceTool, Display, SeatCapabilities, 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 = "GdkSeat")]
16    pub struct Seat(Object<ffi::GdkSeat>);
17
18    match fn {
19        type_ => || ffi::gdk_seat_get_type(),
20    }
21}
22
23impl Seat {
24    pub const NONE: Option<&'static Seat> = None;
25}
26
27pub trait SeatExt: IsA<Seat> + 'static {
28    #[doc(alias = "gdk_seat_get_capabilities")]
29    #[doc(alias = "get_capabilities")]
30    fn capabilities(&self) -> SeatCapabilities {
31        unsafe {
32            from_glib(ffi::gdk_seat_get_capabilities(
33                self.as_ref().to_glib_none().0,
34            ))
35        }
36    }
37
38    #[doc(alias = "gdk_seat_get_devices")]
39    #[doc(alias = "get_devices")]
40    fn devices(&self, capabilities: SeatCapabilities) -> Vec<Device> {
41        unsafe {
42            FromGlibPtrContainer::from_glib_container(ffi::gdk_seat_get_devices(
43                self.as_ref().to_glib_none().0,
44                capabilities.into_glib(),
45            ))
46        }
47    }
48
49    #[doc(alias = "gdk_seat_get_display")]
50    #[doc(alias = "get_display")]
51    fn display(&self) -> Display {
52        unsafe { from_glib_none(ffi::gdk_seat_get_display(self.as_ref().to_glib_none().0)) }
53    }
54
55    #[doc(alias = "gdk_seat_get_keyboard")]
56    #[doc(alias = "get_keyboard")]
57    fn keyboard(&self) -> Option<Device> {
58        unsafe { from_glib_none(ffi::gdk_seat_get_keyboard(self.as_ref().to_glib_none().0)) }
59    }
60
61    #[doc(alias = "gdk_seat_get_pointer")]
62    #[doc(alias = "get_pointer")]
63    fn pointer(&self) -> Option<Device> {
64        unsafe { from_glib_none(ffi::gdk_seat_get_pointer(self.as_ref().to_glib_none().0)) }
65    }
66
67    #[doc(alias = "gdk_seat_get_tools")]
68    #[doc(alias = "get_tools")]
69    fn tools(&self) -> Vec<DeviceTool> {
70        unsafe {
71            FromGlibPtrContainer::from_glib_container(ffi::gdk_seat_get_tools(
72                self.as_ref().to_glib_none().0,
73            ))
74        }
75    }
76
77    #[doc(alias = "device-added")]
78    fn connect_device_added<F: Fn(&Self, &Device) + 'static>(&self, f: F) -> SignalHandlerId {
79        unsafe extern "C" fn device_added_trampoline<P: IsA<Seat>, F: Fn(&P, &Device) + 'static>(
80            this: *mut ffi::GdkSeat,
81            device: *mut ffi::GdkDevice,
82            f: glib::ffi::gpointer,
83        ) {
84            unsafe {
85                let f: &F = &*(f as *const F);
86                f(
87                    Seat::from_glib_borrow(this).unsafe_cast_ref(),
88                    &from_glib_borrow(device),
89                )
90            }
91        }
92        unsafe {
93            let f: Box_<F> = Box_::new(f);
94            connect_raw(
95                self.as_ptr() as *mut _,
96                c"device-added".as_ptr(),
97                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
98                    device_added_trampoline::<Self, F> as *const (),
99                )),
100                Box_::into_raw(f),
101            )
102        }
103    }
104
105    #[doc(alias = "device-removed")]
106    fn connect_device_removed<F: Fn(&Self, &Device) + 'static>(&self, f: F) -> SignalHandlerId {
107        unsafe extern "C" fn device_removed_trampoline<
108            P: IsA<Seat>,
109            F: Fn(&P, &Device) + 'static,
110        >(
111            this: *mut ffi::GdkSeat,
112            device: *mut ffi::GdkDevice,
113            f: glib::ffi::gpointer,
114        ) {
115            unsafe {
116                let f: &F = &*(f as *const F);
117                f(
118                    Seat::from_glib_borrow(this).unsafe_cast_ref(),
119                    &from_glib_borrow(device),
120                )
121            }
122        }
123        unsafe {
124            let f: Box_<F> = Box_::new(f);
125            connect_raw(
126                self.as_ptr() as *mut _,
127                c"device-removed".as_ptr(),
128                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
129                    device_removed_trampoline::<Self, F> as *const (),
130                )),
131                Box_::into_raw(f),
132            )
133        }
134    }
135
136    #[doc(alias = "tool-added")]
137    fn connect_tool_added<F: Fn(&Self, &DeviceTool) + 'static>(&self, f: F) -> SignalHandlerId {
138        unsafe extern "C" fn tool_added_trampoline<
139            P: IsA<Seat>,
140            F: Fn(&P, &DeviceTool) + 'static,
141        >(
142            this: *mut ffi::GdkSeat,
143            tool: *mut ffi::GdkDeviceTool,
144            f: glib::ffi::gpointer,
145        ) {
146            unsafe {
147                let f: &F = &*(f as *const F);
148                f(
149                    Seat::from_glib_borrow(this).unsafe_cast_ref(),
150                    &from_glib_borrow(tool),
151                )
152            }
153        }
154        unsafe {
155            let f: Box_<F> = Box_::new(f);
156            connect_raw(
157                self.as_ptr() as *mut _,
158                c"tool-added".as_ptr(),
159                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
160                    tool_added_trampoline::<Self, F> as *const (),
161                )),
162                Box_::into_raw(f),
163            )
164        }
165    }
166
167    #[doc(alias = "tool-removed")]
168    fn connect_tool_removed<F: Fn(&Self, &DeviceTool) + 'static>(&self, f: F) -> SignalHandlerId {
169        unsafe extern "C" fn tool_removed_trampoline<
170            P: IsA<Seat>,
171            F: Fn(&P, &DeviceTool) + 'static,
172        >(
173            this: *mut ffi::GdkSeat,
174            tool: *mut ffi::GdkDeviceTool,
175            f: glib::ffi::gpointer,
176        ) {
177            unsafe {
178                let f: &F = &*(f as *const F);
179                f(
180                    Seat::from_glib_borrow(this).unsafe_cast_ref(),
181                    &from_glib_borrow(tool),
182                )
183            }
184        }
185        unsafe {
186            let f: Box_<F> = Box_::new(f);
187            connect_raw(
188                self.as_ptr() as *mut _,
189                c"tool-removed".as_ptr(),
190                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
191                    tool_removed_trampoline::<Self, F> as *const (),
192                )),
193                Box_::into_raw(f),
194            )
195        }
196    }
197}
198
199impl<O: IsA<Seat>> SeatExt for O {}