1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use crate::{Device, DeviceTool, Display, SeatCapabilities};
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::boxed::Box as Box_;
glib::wrapper! {
/// The [`Seat`][crate::Seat] object represents a collection of input devices
/// that belong to a user.
///
/// This is an Abstract Base Class, you cannot instantiate it.
///
/// ## Properties
///
///
/// #### `display`
/// [`Display`][crate::Display] of this seat.
///
/// Readable | Writeable | Construct Only
///
/// ## Signals
///
///
/// #### `device-added`
/// Emitted when a new input device is related to this seat.
///
///
///
///
/// #### `device-removed`
/// Emitted when an input device is removed (e.g. unplugged).
///
///
///
///
/// #### `tool-added`
/// Emitted whenever a new tool is made known to the seat.
///
/// The tool may later be assigned to a device (i.e. on
/// proximity with a tablet). The device will emit the
/// [`tool-changed`][struct@crate::Device#tool-changed] signal accordingly.
///
/// A same tool may be used by several devices.
///
///
///
///
/// #### `tool-removed`
/// Emitted whenever a tool is no longer known to this @seat.
///
///
///
/// # Implements
///
/// [`SeatExt`][trait@crate::prelude::SeatExt]
#[doc(alias = "GdkSeat")]
pub struct Seat(Object<ffi::GdkSeat>);
match fn {
type_ => || ffi::gdk_seat_get_type(),
}
}
impl Seat {
pub const NONE: Option<&'static Seat> = None;
}
mod sealed {
pub trait Sealed {}
impl<T: super::IsA<super::Seat>> Sealed for T {}
}
/// Trait containing all [`struct@Seat`] methods.
///
/// # Implementors
///
/// [`Seat`][struct@crate::Seat]
pub trait SeatExt: IsA<Seat> + sealed::Sealed + 'static {
/// Returns the capabilities this [`Seat`][crate::Seat] currently has.
///
/// # Returns
///
/// the seat capabilities
#[doc(alias = "gdk_seat_get_capabilities")]
#[doc(alias = "get_capabilities")]
fn capabilities(&self) -> SeatCapabilities {
unsafe {
from_glib(ffi::gdk_seat_get_capabilities(
self.as_ref().to_glib_none().0,
))
}
}
/// Returns the devices that match the given capabilities.
/// ## `capabilities`
/// capabilities to get devices for
///
/// # Returns
///
/// A list
/// of `GdkDevices`. The list must be freed with g_list_free(),
/// the elements are owned by GTK and must not be freed.
#[doc(alias = "gdk_seat_get_devices")]
#[doc(alias = "get_devices")]
fn devices(&self, capabilities: SeatCapabilities) -> Vec<Device> {
unsafe {
FromGlibPtrContainer::from_glib_container(ffi::gdk_seat_get_devices(
self.as_ref().to_glib_none().0,
capabilities.into_glib(),
))
}
}
/// Returns the [`Display`][crate::Display] this seat belongs to.
///
/// # Returns
///
/// a [`Display`][crate::Display]. This object
/// is owned by GTK and must not be freed.
#[doc(alias = "gdk_seat_get_display")]
#[doc(alias = "get_display")]
fn display(&self) -> Display {
unsafe { from_glib_none(ffi::gdk_seat_get_display(self.as_ref().to_glib_none().0)) }
}
/// Returns the device that routes keyboard events.
///
/// # Returns
///
/// a [`Device`][crate::Device] with keyboard
/// capabilities. This object is owned by GTK and must not be freed.
#[doc(alias = "gdk_seat_get_keyboard")]
#[doc(alias = "get_keyboard")]
fn keyboard(&self) -> Option<Device> {
unsafe { from_glib_none(ffi::gdk_seat_get_keyboard(self.as_ref().to_glib_none().0)) }
}
/// Returns the device that routes pointer events.
///
/// # Returns
///
/// a [`Device`][crate::Device] with pointer
/// capabilities. This object is owned by GTK and must not be freed.
#[doc(alias = "gdk_seat_get_pointer")]
#[doc(alias = "get_pointer")]
fn pointer(&self) -> Option<Device> {
unsafe { from_glib_none(ffi::gdk_seat_get_pointer(self.as_ref().to_glib_none().0)) }
}
/// Returns all `GdkDeviceTools` that are known to the application.
///
/// # Returns
///
///
/// A list of tools. Free with g_list_free().
#[doc(alias = "gdk_seat_get_tools")]
#[doc(alias = "get_tools")]
fn tools(&self) -> Vec<DeviceTool> {
unsafe {
FromGlibPtrContainer::from_glib_container(ffi::gdk_seat_get_tools(
self.as_ref().to_glib_none().0,
))
}
}
/// Emitted when a new input device is related to this seat.
/// ## `device`
/// the newly added [`Device`][crate::Device].
#[doc(alias = "device-added")]
fn connect_device_added<F: Fn(&Self, &Device) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn device_added_trampoline<P: IsA<Seat>, F: Fn(&P, &Device) + 'static>(
this: *mut ffi::GdkSeat,
device: *mut ffi::GdkDevice,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(
Seat::from_glib_borrow(this).unsafe_cast_ref(),
&from_glib_borrow(device),
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"device-added\0".as_ptr() as *const _,
Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
device_added_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted when an input device is removed (e.g. unplugged).
/// ## `device`
/// the just removed [`Device`][crate::Device].
#[doc(alias = "device-removed")]
fn connect_device_removed<F: Fn(&Self, &Device) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn device_removed_trampoline<
P: IsA<Seat>,
F: Fn(&P, &Device) + 'static,
>(
this: *mut ffi::GdkSeat,
device: *mut ffi::GdkDevice,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(
Seat::from_glib_borrow(this).unsafe_cast_ref(),
&from_glib_borrow(device),
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"device-removed\0".as_ptr() as *const _,
Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
device_removed_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted whenever a new tool is made known to the seat.
///
/// The tool may later be assigned to a device (i.e. on
/// proximity with a tablet). The device will emit the
/// [`tool-changed`][struct@crate::Device#tool-changed] signal accordingly.
///
/// A same tool may be used by several devices.
/// ## `tool`
/// the new [`DeviceTool`][crate::DeviceTool] known to the seat
#[doc(alias = "tool-added")]
fn connect_tool_added<F: Fn(&Self, &DeviceTool) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn tool_added_trampoline<
P: IsA<Seat>,
F: Fn(&P, &DeviceTool) + 'static,
>(
this: *mut ffi::GdkSeat,
tool: *mut ffi::GdkDeviceTool,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(
Seat::from_glib_borrow(this).unsafe_cast_ref(),
&from_glib_borrow(tool),
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"tool-added\0".as_ptr() as *const _,
Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
tool_added_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted whenever a tool is no longer known to this @seat.
/// ## `tool`
/// the just removed [`DeviceTool`][crate::DeviceTool]
#[doc(alias = "tool-removed")]
fn connect_tool_removed<F: Fn(&Self, &DeviceTool) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn tool_removed_trampoline<
P: IsA<Seat>,
F: Fn(&P, &DeviceTool) + 'static,
>(
this: *mut ffi::GdkSeat,
tool: *mut ffi::GdkDeviceTool,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(
Seat::from_glib_borrow(this).unsafe_cast_ref(),
&from_glib_borrow(tool),
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"tool-removed\0".as_ptr() as *const _,
Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
tool_removed_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
impl<O: IsA<Seat>> SeatExt for O {}