gdk/auto/device.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::{
6 Atom, AxisFlags, AxisUse, DeviceManager, DeviceTool, DeviceType, Display, InputMode,
7 InputSource, ModifierType, Screen, Seat, Window, ffi,
8};
9use glib::{
10 object::ObjectType as _,
11 prelude::*,
12 signal::{SignalHandlerId, connect_raw},
13 translate::*,
14};
15use std::boxed::Box as Box_;
16
17glib::wrapper! {
18 /// The [`Device`][crate::Device] object represents a single input device, such
19 /// as a keyboard, a mouse, a touchpad, etc.
20 ///
21 /// See the [`DeviceManager`][crate::DeviceManager] documentation for more information
22 /// about the various kinds of master and slave devices, and their
23 /// relationships.
24 ///
25 /// This is an Abstract Base Class, you cannot instantiate it.
26 ///
27 /// ## Properties
28 ///
29 ///
30 /// #### `associated-device`
31 /// Associated pointer or keyboard with this device, if any. Devices of type [`DeviceType::Master`][crate::DeviceType::Master]
32 /// always come in keyboard/pointer pairs. Other device types will have a [`None`] associated device.
33 ///
34 /// Readable
35 ///
36 ///
37 /// #### `axes`
38 /// The axes currently available for this device.
39 ///
40 /// Readable
41 ///
42 ///
43 /// #### `device-manager`
44 /// The [`DeviceManager`][crate::DeviceManager] the [`Device`][crate::Device] pertains to.
45 ///
46 /// Readable | Writable | Construct Only
47 ///
48 ///
49 /// #### `display`
50 /// The [`Display`][crate::Display] the [`Device`][crate::Device] pertains to.
51 ///
52 /// Readable | Writable | Construct Only
53 ///
54 ///
55 /// #### `has-cursor`
56 /// Whether the device is represented by a cursor on the screen. Devices of type
57 /// [`DeviceType::Master`][crate::DeviceType::Master] will have [`true`] here.
58 ///
59 /// Readable | Writable | Construct Only
60 ///
61 ///
62 /// #### `input-mode`
63 /// Readable | Writable
64 ///
65 ///
66 /// #### `input-source`
67 /// Source type for the device.
68 ///
69 /// Readable | Writable | Construct Only
70 ///
71 ///
72 /// #### `n-axes`
73 /// Number of axes in the device.
74 ///
75 /// Readable
76 ///
77 ///
78 /// #### `name`
79 /// The device name.
80 ///
81 /// Readable | Writable | Construct Only
82 ///
83 ///
84 /// #### `num-touches`
85 /// The maximal number of concurrent touches on a touch device.
86 /// Will be 0 if the device is not a touch device or if the number
87 /// of touches is unknown.
88 ///
89 /// Readable | Writable | Construct Only
90 ///
91 ///
92 /// #### `product-id`
93 /// Product ID of this device, see [`DeviceExt::product_id()`][crate::prelude::DeviceExt::product_id()].
94 ///
95 /// Readable | Writable | Construct Only
96 ///
97 ///
98 /// #### `seat`
99 /// [`Seat`][crate::Seat] of this device.
100 ///
101 /// Readable | Writable
102 ///
103 ///
104 /// #### `tool`
105 /// Readable
106 ///
107 ///
108 /// #### `type`
109 /// Device role in the device manager.
110 ///
111 /// Readable | Writable | Construct Only
112 ///
113 ///
114 /// #### `vendor-id`
115 /// Vendor ID of this device, see [`DeviceExt::vendor_id()`][crate::prelude::DeviceExt::vendor_id()].
116 ///
117 /// Readable | Writable | Construct Only
118 ///
119 /// ## Signals
120 ///
121 ///
122 /// #### `changed`
123 /// The ::changed signal is emitted either when the [`Device`][crate::Device]
124 /// has changed the number of either axes or keys. For example
125 /// In X this will normally happen when the slave device routing
126 /// events through the master device changes (for example, user
127 /// switches from the USB mouse to a tablet), in that case the
128 /// master device will change to reflect the new slave device
129 /// axes and keys.
130 ///
131 ///
132 ///
133 ///
134 /// #### `tool-changed`
135 /// The ::tool-changed signal is emitted on pen/eraser
136 /// `GdkDevices` whenever tools enter or leave proximity.
137 ///
138 ///
139 ///
140 /// # Implements
141 ///
142 /// [`DeviceExt`][trait@crate::prelude::DeviceExt], [`DeviceExtManual`][trait@crate::prelude::DeviceExtManual]
143 #[doc(alias = "GdkDevice")]
144 pub struct Device(Object<ffi::GdkDevice>);
145
146 match fn {
147 type_ => || ffi::gdk_device_get_type(),
148 }
149}
150
151impl Device {
152 pub const NONE: Option<&'static Device> = None;
153}
154
155/// Trait containing all [`struct@Device`] methods.
156///
157/// # Implementors
158///
159/// [`DevicePad`][struct@crate::DevicePad], [`Device`][struct@crate::Device]
160pub trait DeviceExt: IsA<Device> + 'static {
161 /// Returns the associated device to `self`, if `self` is of type
162 /// [`DeviceType::Master`][crate::DeviceType::Master], it will return the paired pointer or
163 /// keyboard.
164 ///
165 /// If `self` is of type [`DeviceType::Slave`][crate::DeviceType::Slave], it will return
166 /// the master device to which `self` is attached to.
167 ///
168 /// If `self` is of type [`DeviceType::Floating`][crate::DeviceType::Floating], [`None`] will be
169 /// returned, as there is no associated device.
170 ///
171 /// # Returns
172 ///
173 /// The associated device, or
174 /// [`None`]
175 #[doc(alias = "gdk_device_get_associated_device")]
176 #[doc(alias = "get_associated_device")]
177 #[doc(alias = "associated-device")]
178 #[must_use]
179 fn associated_device(&self) -> Option<Device> {
180 unsafe {
181 from_glib_none(ffi::gdk_device_get_associated_device(
182 self.as_ref().to_glib_none().0,
183 ))
184 }
185 }
186
187 /// Returns the axes currently available on the device.
188 #[doc(alias = "gdk_device_get_axes")]
189 #[doc(alias = "get_axes")]
190 fn axes(&self) -> AxisFlags {
191 unsafe { from_glib(ffi::gdk_device_get_axes(self.as_ref().to_glib_none().0)) }
192 }
193
194 //#[doc(alias = "gdk_device_get_axis")]
195 //#[doc(alias = "get_axis")]
196 //fn axis(&self, axes: &[f64], use_: AxisUse) -> Option<f64> {
197 // unsafe { TODO: call ffi:gdk_device_get_axis() }
198 //}
199
200 /// Returns the axis use for `index_`.
201 /// ## `index_`
202 /// the index of the axis.
203 ///
204 /// # Returns
205 ///
206 /// a [`AxisUse`][crate::AxisUse] specifying how the axis is used.
207 #[doc(alias = "gdk_device_get_axis_use")]
208 #[doc(alias = "get_axis_use")]
209 fn axis_use(&self, index_: u32) -> AxisUse {
210 unsafe {
211 from_glib(ffi::gdk_device_get_axis_use(
212 self.as_ref().to_glib_none().0,
213 index_,
214 ))
215 }
216 }
217
218 //#[doc(alias = "gdk_device_get_axis_value")]
219 //#[doc(alias = "get_axis_value")]
220 //fn axis_value(&self, axes: &[f64], axis_label: &Atom) -> Option<f64> {
221 // unsafe { TODO: call ffi:gdk_device_get_axis_value() }
222 //}
223
224 /// Returns the device type for `self`.
225 ///
226 /// # Returns
227 ///
228 /// the [`DeviceType`][crate::DeviceType] for `self`.
229 #[doc(alias = "gdk_device_get_device_type")]
230 #[doc(alias = "get_device_type")]
231 fn device_type(&self) -> DeviceType {
232 unsafe {
233 from_glib(ffi::gdk_device_get_device_type(
234 self.as_ref().to_glib_none().0,
235 ))
236 }
237 }
238
239 /// Returns the [`Display`][crate::Display] to which `self` pertains.
240 ///
241 /// # Returns
242 ///
243 /// a [`Display`][crate::Display]. This memory is owned
244 /// by GTK+, and must not be freed or unreffed.
245 #[doc(alias = "gdk_device_get_display")]
246 #[doc(alias = "get_display")]
247 fn display(&self) -> Display {
248 unsafe { from_glib_none(ffi::gdk_device_get_display(self.as_ref().to_glib_none().0)) }
249 }
250
251 /// Determines whether the pointer follows device motion.
252 /// This is not meaningful for keyboard devices, which don't have a pointer.
253 ///
254 /// # Returns
255 ///
256 /// [`true`] if the pointer follows device motion
257 #[doc(alias = "gdk_device_get_has_cursor")]
258 #[doc(alias = "get_has_cursor")]
259 #[doc(alias = "has-cursor")]
260 fn has_cursor(&self) -> bool {
261 unsafe {
262 from_glib(ffi::gdk_device_get_has_cursor(
263 self.as_ref().to_glib_none().0,
264 ))
265 }
266 }
267
268 /// If `index_` has a valid keyval, this function will return [`true`]
269 /// and fill in `keyval` and `modifiers` with the keyval settings.
270 /// ## `index_`
271 /// the index of the macro button to get.
272 ///
273 /// # Returns
274 ///
275 /// [`true`] if keyval is set for `index`.
276 ///
277 /// ## `keyval`
278 /// return value for the keyval.
279 ///
280 /// ## `modifiers`
281 /// return value for modifiers.
282 #[doc(alias = "gdk_device_get_key")]
283 #[doc(alias = "get_key")]
284 fn key(&self, index_: u32) -> Option<(u32, ModifierType)> {
285 unsafe {
286 let mut keyval = std::mem::MaybeUninit::uninit();
287 let mut modifiers = std::mem::MaybeUninit::uninit();
288 let ret = from_glib(ffi::gdk_device_get_key(
289 self.as_ref().to_glib_none().0,
290 index_,
291 keyval.as_mut_ptr(),
292 modifiers.as_mut_ptr(),
293 ));
294 if ret {
295 Some((keyval.assume_init(), from_glib(modifiers.assume_init())))
296 } else {
297 None
298 }
299 }
300 }
301
302 /// Gets information about which window the given pointer device is in, based on events
303 /// that have been received so far from the display server. If another application
304 /// has a pointer grab, or this application has a grab with owner_events = [`false`],
305 /// [`None`] may be returned even if the pointer is physically over one of this
306 /// application's windows.
307 ///
308 /// # Returns
309 ///
310 /// the last window the device
311 #[doc(alias = "gdk_device_get_last_event_window")]
312 #[doc(alias = "get_last_event_window")]
313 fn last_event_window(&self) -> Option<Window> {
314 unsafe {
315 from_glib_none(ffi::gdk_device_get_last_event_window(
316 self.as_ref().to_glib_none().0,
317 ))
318 }
319 }
320
321 /// Determines the mode of the device.
322 ///
323 /// # Returns
324 ///
325 /// a [`InputSource`][crate::InputSource]
326 #[doc(alias = "gdk_device_get_mode")]
327 #[doc(alias = "get_mode")]
328 fn mode(&self) -> InputMode {
329 unsafe { from_glib(ffi::gdk_device_get_mode(self.as_ref().to_glib_none().0)) }
330 }
331
332 /// Returns the number of axes the device currently has.
333 ///
334 /// # Returns
335 ///
336 /// the number of axes.
337 #[doc(alias = "gdk_device_get_n_axes")]
338 #[doc(alias = "get_n_axes")]
339 #[doc(alias = "n-axes")]
340 fn n_axes(&self) -> i32 {
341 unsafe { ffi::gdk_device_get_n_axes(self.as_ref().to_glib_none().0) }
342 }
343
344 /// Returns the number of keys the device currently has.
345 ///
346 /// # Returns
347 ///
348 /// the number of keys.
349 #[doc(alias = "gdk_device_get_n_keys")]
350 #[doc(alias = "get_n_keys")]
351 fn n_keys(&self) -> i32 {
352 unsafe { ffi::gdk_device_get_n_keys(self.as_ref().to_glib_none().0) }
353 }
354
355 /// Determines the name of the device.
356 ///
357 /// # Returns
358 ///
359 /// a name
360 #[doc(alias = "gdk_device_get_name")]
361 #[doc(alias = "get_name")]
362 fn name(&self) -> Option<glib::GString> {
363 unsafe { from_glib_none(ffi::gdk_device_get_name(self.as_ref().to_glib_none().0)) }
364 }
365
366 /// Gets the current location of `self`. As a slave device
367 /// coordinates are those of its master pointer, This function
368 /// may not be called on devices of type [`DeviceType::Slave`][crate::DeviceType::Slave],
369 /// unless there is an ongoing grab on them, see `gdk_device_grab()`.
370 ///
371 /// # Returns
372 ///
373 ///
374 /// ## `screen`
375 /// location to store the [`Screen`][crate::Screen]
376 /// the `self` is on, or [`None`].
377 ///
378 /// ## `x`
379 /// location to store root window X coordinate of `self`, or [`None`].
380 ///
381 /// ## `y`
382 /// location to store root window Y coordinate of `self`, or [`None`].
383 #[doc(alias = "gdk_device_get_position")]
384 #[doc(alias = "get_position")]
385 fn position(&self) -> (Screen, i32, i32) {
386 unsafe {
387 let mut screen = std::ptr::null_mut();
388 let mut x = std::mem::MaybeUninit::uninit();
389 let mut y = std::mem::MaybeUninit::uninit();
390 ffi::gdk_device_get_position(
391 self.as_ref().to_glib_none().0,
392 &mut screen,
393 x.as_mut_ptr(),
394 y.as_mut_ptr(),
395 );
396 (from_glib_none(screen), x.assume_init(), y.assume_init())
397 }
398 }
399
400 /// Gets the current location of `self` in double precision. As a slave device's
401 /// coordinates are those of its master pointer, this function
402 /// may not be called on devices of type [`DeviceType::Slave`][crate::DeviceType::Slave],
403 /// unless there is an ongoing grab on them. See `gdk_device_grab()`.
404 ///
405 /// # Returns
406 ///
407 ///
408 /// ## `screen`
409 /// location to store the [`Screen`][crate::Screen]
410 /// the `self` is on, or [`None`].
411 ///
412 /// ## `x`
413 /// location to store root window X coordinate of `self`, or [`None`].
414 ///
415 /// ## `y`
416 /// location to store root window Y coordinate of `self`, or [`None`].
417 #[doc(alias = "gdk_device_get_position_double")]
418 #[doc(alias = "get_position_double")]
419 fn position_double(&self) -> (Screen, f64, f64) {
420 unsafe {
421 let mut screen = std::ptr::null_mut();
422 let mut x = std::mem::MaybeUninit::uninit();
423 let mut y = std::mem::MaybeUninit::uninit();
424 ffi::gdk_device_get_position_double(
425 self.as_ref().to_glib_none().0,
426 &mut screen,
427 x.as_mut_ptr(),
428 y.as_mut_ptr(),
429 );
430 (from_glib_none(screen), x.assume_init(), y.assume_init())
431 }
432 }
433
434 /// Returns the product ID of this device, or [`None`] if this information couldn't
435 /// be obtained. This ID is retrieved from the device, and is thus constant for
436 /// it. See [`vendor_id()`][Self::vendor_id()] for more information.
437 ///
438 /// # Returns
439 ///
440 /// the product ID, or [`None`]
441 #[doc(alias = "gdk_device_get_product_id")]
442 #[doc(alias = "get_product_id")]
443 #[doc(alias = "product-id")]
444 fn product_id(&self) -> Option<glib::GString> {
445 unsafe {
446 from_glib_none(ffi::gdk_device_get_product_id(
447 self.as_ref().to_glib_none().0,
448 ))
449 }
450 }
451
452 /// Returns the [`Seat`][crate::Seat] the device belongs to.
453 ///
454 /// # Returns
455 ///
456 /// A [`Seat`][crate::Seat]. This memory is owned by GTK+ and
457 /// must not be freed.
458 #[doc(alias = "gdk_device_get_seat")]
459 #[doc(alias = "get_seat")]
460 fn seat(&self) -> Option<Seat> {
461 unsafe { from_glib_none(ffi::gdk_device_get_seat(self.as_ref().to_glib_none().0)) }
462 }
463
464 /// Determines the type of the device.
465 ///
466 /// # Returns
467 ///
468 /// a [`InputSource`][crate::InputSource]
469 #[doc(alias = "gdk_device_get_source")]
470 #[doc(alias = "get_source")]
471 fn source(&self) -> InputSource {
472 unsafe { from_glib(ffi::gdk_device_get_source(self.as_ref().to_glib_none().0)) }
473 }
474
475 //#[doc(alias = "gdk_device_get_state")]
476 //#[doc(alias = "get_state")]
477 //fn state(&self, window: &Window, axes: &[f64]) -> ModifierType {
478 // unsafe { TODO: call ffi:gdk_device_get_state() }
479 //}
480
481 ///
482 /// static GSettings *
483 /// get_device_settings (GdkDevice *device)
484 /// {
485 /// const gchar *vendor, *product;
486 /// GSettings *settings;
487 /// GdkDevice *device;
488 /// gchar *path;
489 ///
490 /// vendor = gdk_device_get_vendor_id (device);
491 /// product = gdk_device_get_product_id (device);
492 ///
493 /// path = g_strdup_printf ("/org/example/app/devices/`s`:`s`/", vendor, product);
494 /// settings = g_settings_new_with_path (DEVICE_SCHEMA, path);
495 /// g_free (path);
496 ///
497 /// return settings;
498 /// }
499 /// ]|
500 ///
501 /// # Returns
502 ///
503 /// the vendor ID, or [`None`]
504 #[doc(alias = "gdk_device_get_vendor_id")]
505 #[doc(alias = "get_vendor_id")]
506 #[doc(alias = "vendor-id")]
507 fn vendor_id(&self) -> Option<glib::GString> {
508 unsafe {
509 from_glib_none(ffi::gdk_device_get_vendor_id(
510 self.as_ref().to_glib_none().0,
511 ))
512 }
513 }
514
515 /// Obtains the window underneath `self`, returning the location of the device in `win_x` and `win_y`. Returns
516 /// [`None`] if the window tree under `self` is not known to GDK (for example, belongs to another application).
517 ///
518 /// As a slave device coordinates are those of its master pointer, This
519 /// function may not be called on devices of type [`DeviceType::Slave`][crate::DeviceType::Slave],
520 /// unless there is an ongoing grab on them, see `gdk_device_grab()`.
521 ///
522 /// # Returns
523 ///
524 /// the [`Window`][crate::Window] under the
525 /// device position, or [`None`].
526 ///
527 /// ## `win_x`
528 /// return location for the X coordinate of the device location,
529 /// relative to the window origin, or [`None`].
530 ///
531 /// ## `win_y`
532 /// return location for the Y coordinate of the device location,
533 /// relative to the window origin, or [`None`].
534 #[doc(alias = "gdk_device_get_window_at_position")]
535 #[doc(alias = "get_window_at_position")]
536 fn window_at_position(&self) -> (Option<Window>, i32, i32) {
537 unsafe {
538 let mut win_x = std::mem::MaybeUninit::uninit();
539 let mut win_y = std::mem::MaybeUninit::uninit();
540 let ret = from_glib_none(ffi::gdk_device_get_window_at_position(
541 self.as_ref().to_glib_none().0,
542 win_x.as_mut_ptr(),
543 win_y.as_mut_ptr(),
544 ));
545 (ret, win_x.assume_init(), win_y.assume_init())
546 }
547 }
548
549 /// Obtains the window underneath `self`, returning the location of the device in `win_x` and `win_y` in
550 /// double precision. Returns [`None`] if the window tree under `self` is not known to GDK (for example,
551 /// belongs to another application).
552 ///
553 /// As a slave device coordinates are those of its master pointer, This
554 /// function may not be called on devices of type [`DeviceType::Slave`][crate::DeviceType::Slave],
555 /// unless there is an ongoing grab on them, see `gdk_device_grab()`.
556 ///
557 /// # Returns
558 ///
559 /// the [`Window`][crate::Window] under the
560 /// device position, or [`None`].
561 ///
562 /// ## `win_x`
563 /// return location for the X coordinate of the device location,
564 /// relative to the window origin, or [`None`].
565 ///
566 /// ## `win_y`
567 /// return location for the Y coordinate of the device location,
568 /// relative to the window origin, or [`None`].
569 #[doc(alias = "gdk_device_get_window_at_position_double")]
570 #[doc(alias = "get_window_at_position_double")]
571 fn window_at_position_double(&self) -> (Option<Window>, f64, f64) {
572 unsafe {
573 let mut win_x = std::mem::MaybeUninit::uninit();
574 let mut win_y = std::mem::MaybeUninit::uninit();
575 let ret = from_glib_none(ffi::gdk_device_get_window_at_position_double(
576 self.as_ref().to_glib_none().0,
577 win_x.as_mut_ptr(),
578 win_y.as_mut_ptr(),
579 ));
580 (ret, win_x.assume_init(), win_y.assume_init())
581 }
582 }
583
584 /// Returns a `GList` of `GdkAtoms`, containing the labels for
585 /// the axes that `self` currently has.
586 ///
587 /// # Returns
588 ///
589 ///
590 /// A `GList` of `GdkAtoms`, free with `g_list_free()`.
591 #[doc(alias = "gdk_device_list_axes")]
592 fn list_axes(&self) -> Vec<Atom> {
593 unsafe {
594 FromGlibPtrContainer::from_glib_container(ffi::gdk_device_list_axes(
595 self.as_ref().to_glib_none().0,
596 ))
597 }
598 }
599
600 /// If the device if of type [`DeviceType::Master`][crate::DeviceType::Master], it will return
601 /// the list of slave devices attached to it, otherwise it will return
602 /// [`None`]
603 ///
604 /// # Returns
605 ///
606 ///
607 /// the list of slave devices, or [`None`]. The list must be
608 /// freed with `g_list_free()`, the contents of the list are
609 /// owned by GTK+ and should not be freed.
610 #[doc(alias = "gdk_device_list_slave_devices")]
611 fn list_slave_devices(&self) -> Vec<Device> {
612 unsafe {
613 FromGlibPtrContainer::from_glib_container(ffi::gdk_device_list_slave_devices(
614 self.as_ref().to_glib_none().0,
615 ))
616 }
617 }
618
619 /// Specifies how an axis of a device is used.
620 /// ## `index_`
621 /// the index of the axis
622 /// ## `use_`
623 /// specifies how the axis is used
624 #[doc(alias = "gdk_device_set_axis_use")]
625 fn set_axis_use(&self, index_: u32, use_: AxisUse) {
626 unsafe {
627 ffi::gdk_device_set_axis_use(self.as_ref().to_glib_none().0, index_, use_.into_glib());
628 }
629 }
630
631 /// Specifies the X key event to generate when a macro button of a device
632 /// is pressed.
633 /// ## `index_`
634 /// the index of the macro button to set
635 /// ## `keyval`
636 /// the keyval to generate
637 /// ## `modifiers`
638 /// the modifiers to set
639 #[doc(alias = "gdk_device_set_key")]
640 fn set_key(&self, index_: u32, keyval: u32, modifiers: ModifierType) {
641 unsafe {
642 ffi::gdk_device_set_key(
643 self.as_ref().to_glib_none().0,
644 index_,
645 keyval,
646 modifiers.into_glib(),
647 );
648 }
649 }
650
651 /// Sets a the mode of an input device. The mode controls if the
652 /// device is active and whether the device’s range is mapped to the
653 /// entire screen or to a single window.
654 ///
655 /// Note: This is only meaningful for floating devices, master devices (and
656 /// slaves connected to these) drive the pointer cursor, which is not limited
657 /// by the input mode.
658 /// ## `mode`
659 /// the input mode.
660 ///
661 /// # Returns
662 ///
663 /// [`true`] if the mode was successfully changed.
664 #[doc(alias = "gdk_device_set_mode")]
665 fn set_mode(&self, mode: InputMode) -> bool {
666 unsafe {
667 from_glib(ffi::gdk_device_set_mode(
668 self.as_ref().to_glib_none().0,
669 mode.into_glib(),
670 ))
671 }
672 }
673
674 /// Warps `self` in `display` to the point `x`,`y` on
675 /// the screen `screen`, unless the device is confined
676 /// to a window by a grab, in which case it will be moved
677 /// as far as allowed by the grab. Warping the pointer
678 /// creates events as if the user had moved the mouse
679 /// instantaneously to the destination.
680 ///
681 /// Note that the pointer should normally be under the
682 /// control of the user. This function was added to cover
683 /// some rare use cases like keyboard navigation support
684 /// for the color picker in the `GtkColorSelectionDialog`.
685 /// ## `screen`
686 /// the screen to warp `self` to.
687 /// ## `x`
688 /// the X coordinate of the destination.
689 /// ## `y`
690 /// the Y coordinate of the destination.
691 #[doc(alias = "gdk_device_warp")]
692 fn warp(&self, screen: &Screen, x: i32, y: i32) {
693 unsafe {
694 ffi::gdk_device_warp(
695 self.as_ref().to_glib_none().0,
696 screen.to_glib_none().0,
697 x,
698 y,
699 );
700 }
701 }
702
703 /// The [`DeviceManager`][crate::DeviceManager] the [`Device`][crate::Device] pertains to.
704 #[doc(alias = "device-manager")]
705 fn device_manager(&self) -> Option<DeviceManager> {
706 ObjectExt::property(self.as_ref(), "device-manager")
707 }
708
709 #[doc(alias = "input-mode")]
710 fn input_mode(&self) -> InputMode {
711 ObjectExt::property(self.as_ref(), "input-mode")
712 }
713
714 #[doc(alias = "input-mode")]
715 fn set_input_mode(&self, input_mode: InputMode) {
716 ObjectExt::set_property(self.as_ref(), "input-mode", input_mode)
717 }
718
719 /// Source type for the device.
720 #[doc(alias = "input-source")]
721 fn input_source(&self) -> InputSource {
722 ObjectExt::property(self.as_ref(), "input-source")
723 }
724
725 /// The maximal number of concurrent touches on a touch device.
726 /// Will be 0 if the device is not a touch device or if the number
727 /// of touches is unknown.
728 #[doc(alias = "num-touches")]
729 fn num_touches(&self) -> u32 {
730 ObjectExt::property(self.as_ref(), "num-touches")
731 }
732
733 /// [`Seat`][crate::Seat] of this device.
734 fn set_seat<P: IsA<Seat>>(&self, seat: Option<&P>) {
735 ObjectExt::set_property(self.as_ref(), "seat", seat)
736 }
737
738 fn tool(&self) -> Option<DeviceTool> {
739 ObjectExt::property(self.as_ref(), "tool")
740 }
741
742 /// Device role in the device manager.
743 #[doc(alias = "type")]
744 fn type_(&self) -> DeviceType {
745 ObjectExt::property(self.as_ref(), "type")
746 }
747
748 /// The ::changed signal is emitted either when the [`Device`][crate::Device]
749 /// has changed the number of either axes or keys. For example
750 /// In X this will normally happen when the slave device routing
751 /// events through the master device changes (for example, user
752 /// switches from the USB mouse to a tablet), in that case the
753 /// master device will change to reflect the new slave device
754 /// axes and keys.
755 #[doc(alias = "changed")]
756 fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
757 unsafe extern "C" fn changed_trampoline<P: IsA<Device>, F: Fn(&P) + 'static>(
758 this: *mut ffi::GdkDevice,
759 f: glib::ffi::gpointer,
760 ) {
761 unsafe {
762 let f: &F = &*(f as *const F);
763 f(Device::from_glib_borrow(this).unsafe_cast_ref())
764 }
765 }
766 unsafe {
767 let f: Box_<F> = Box_::new(f);
768 connect_raw(
769 self.as_ptr() as *mut _,
770 c"changed".as_ptr(),
771 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
772 changed_trampoline::<Self, F> as *const (),
773 )),
774 Box_::into_raw(f),
775 )
776 }
777 }
778
779 /// The ::tool-changed signal is emitted on pen/eraser
780 /// `GdkDevices` whenever tools enter or leave proximity.
781 /// ## `tool`
782 /// The new current tool
783 #[doc(alias = "tool-changed")]
784 fn connect_tool_changed<F: Fn(&Self, &DeviceTool) + 'static>(&self, f: F) -> SignalHandlerId {
785 unsafe extern "C" fn tool_changed_trampoline<
786 P: IsA<Device>,
787 F: Fn(&P, &DeviceTool) + 'static,
788 >(
789 this: *mut ffi::GdkDevice,
790 tool: *mut ffi::GdkDeviceTool,
791 f: glib::ffi::gpointer,
792 ) {
793 unsafe {
794 let f: &F = &*(f as *const F);
795 f(
796 Device::from_glib_borrow(this).unsafe_cast_ref(),
797 &from_glib_borrow(tool),
798 )
799 }
800 }
801 unsafe {
802 let f: Box_<F> = Box_::new(f);
803 connect_raw(
804 self.as_ptr() as *mut _,
805 c"tool-changed".as_ptr(),
806 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
807 tool_changed_trampoline::<Self, F> as *const (),
808 )),
809 Box_::into_raw(f),
810 )
811 }
812 }
813
814 #[doc(alias = "associated-device")]
815 fn connect_associated_device_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
816 unsafe extern "C" fn notify_associated_device_trampoline<
817 P: IsA<Device>,
818 F: Fn(&P) + 'static,
819 >(
820 this: *mut ffi::GdkDevice,
821 _param_spec: glib::ffi::gpointer,
822 f: glib::ffi::gpointer,
823 ) {
824 unsafe {
825 let f: &F = &*(f as *const F);
826 f(Device::from_glib_borrow(this).unsafe_cast_ref())
827 }
828 }
829 unsafe {
830 let f: Box_<F> = Box_::new(f);
831 connect_raw(
832 self.as_ptr() as *mut _,
833 c"notify::associated-device".as_ptr(),
834 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
835 notify_associated_device_trampoline::<Self, F> as *const (),
836 )),
837 Box_::into_raw(f),
838 )
839 }
840 }
841
842 #[doc(alias = "axes")]
843 fn connect_axes_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
844 unsafe extern "C" fn notify_axes_trampoline<P: IsA<Device>, F: Fn(&P) + 'static>(
845 this: *mut ffi::GdkDevice,
846 _param_spec: glib::ffi::gpointer,
847 f: glib::ffi::gpointer,
848 ) {
849 unsafe {
850 let f: &F = &*(f as *const F);
851 f(Device::from_glib_borrow(this).unsafe_cast_ref())
852 }
853 }
854 unsafe {
855 let f: Box_<F> = Box_::new(f);
856 connect_raw(
857 self.as_ptr() as *mut _,
858 c"notify::axes".as_ptr(),
859 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
860 notify_axes_trampoline::<Self, F> as *const (),
861 )),
862 Box_::into_raw(f),
863 )
864 }
865 }
866
867 #[doc(alias = "input-mode")]
868 fn connect_input_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
869 unsafe extern "C" fn notify_input_mode_trampoline<P: IsA<Device>, F: Fn(&P) + 'static>(
870 this: *mut ffi::GdkDevice,
871 _param_spec: glib::ffi::gpointer,
872 f: glib::ffi::gpointer,
873 ) {
874 unsafe {
875 let f: &F = &*(f as *const F);
876 f(Device::from_glib_borrow(this).unsafe_cast_ref())
877 }
878 }
879 unsafe {
880 let f: Box_<F> = Box_::new(f);
881 connect_raw(
882 self.as_ptr() as *mut _,
883 c"notify::input-mode".as_ptr(),
884 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
885 notify_input_mode_trampoline::<Self, F> as *const (),
886 )),
887 Box_::into_raw(f),
888 )
889 }
890 }
891
892 #[doc(alias = "n-axes")]
893 fn connect_n_axes_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
894 unsafe extern "C" fn notify_n_axes_trampoline<P: IsA<Device>, F: Fn(&P) + 'static>(
895 this: *mut ffi::GdkDevice,
896 _param_spec: glib::ffi::gpointer,
897 f: glib::ffi::gpointer,
898 ) {
899 unsafe {
900 let f: &F = &*(f as *const F);
901 f(Device::from_glib_borrow(this).unsafe_cast_ref())
902 }
903 }
904 unsafe {
905 let f: Box_<F> = Box_::new(f);
906 connect_raw(
907 self.as_ptr() as *mut _,
908 c"notify::n-axes".as_ptr(),
909 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
910 notify_n_axes_trampoline::<Self, F> as *const (),
911 )),
912 Box_::into_raw(f),
913 )
914 }
915 }
916
917 #[doc(alias = "seat")]
918 fn connect_seat_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
919 unsafe extern "C" fn notify_seat_trampoline<P: IsA<Device>, F: Fn(&P) + 'static>(
920 this: *mut ffi::GdkDevice,
921 _param_spec: glib::ffi::gpointer,
922 f: glib::ffi::gpointer,
923 ) {
924 unsafe {
925 let f: &F = &*(f as *const F);
926 f(Device::from_glib_borrow(this).unsafe_cast_ref())
927 }
928 }
929 unsafe {
930 let f: Box_<F> = Box_::new(f);
931 connect_raw(
932 self.as_ptr() as *mut _,
933 c"notify::seat".as_ptr(),
934 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
935 notify_seat_trampoline::<Self, F> as *const (),
936 )),
937 Box_::into_raw(f),
938 )
939 }
940 }
941
942 #[doc(alias = "tool")]
943 fn connect_tool_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
944 unsafe extern "C" fn notify_tool_trampoline<P: IsA<Device>, F: Fn(&P) + 'static>(
945 this: *mut ffi::GdkDevice,
946 _param_spec: glib::ffi::gpointer,
947 f: glib::ffi::gpointer,
948 ) {
949 unsafe {
950 let f: &F = &*(f as *const F);
951 f(Device::from_glib_borrow(this).unsafe_cast_ref())
952 }
953 }
954 unsafe {
955 let f: Box_<F> = Box_::new(f);
956 connect_raw(
957 self.as_ptr() as *mut _,
958 c"notify::tool".as_ptr(),
959 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
960 notify_tool_trampoline::<Self, F> as *const (),
961 )),
962 Box_::into_raw(f),
963 )
964 }
965 }
966
967 #[doc(alias = "type")]
968 fn connect_type_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
969 unsafe extern "C" fn notify_type_trampoline<P: IsA<Device>, F: Fn(&P) + 'static>(
970 this: *mut ffi::GdkDevice,
971 _param_spec: glib::ffi::gpointer,
972 f: glib::ffi::gpointer,
973 ) {
974 unsafe {
975 let f: &F = &*(f as *const F);
976 f(Device::from_glib_borrow(this).unsafe_cast_ref())
977 }
978 }
979 unsafe {
980 let f: Box_<F> = Box_::new(f);
981 connect_raw(
982 self.as_ptr() as *mut _,
983 c"notify::type".as_ptr(),
984 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
985 notify_type_trampoline::<Self, F> as *const (),
986 )),
987 Box_::into_raw(f),
988 )
989 }
990 }
991}
992
993impl<O: IsA<Device>> DeviceExt for O {}