#[repr(transparent)]
pub struct Device { /* private fields */ }
Expand description

The Device object represents a single input device, such as a keyboard, a mouse, a touchpad, etc.

See the DeviceManager documentation for more information about the various kinds of master and slave devices, and their relationships.

This is an Abstract Base Class, you cannot instantiate it.

Implementations

Returns the associated device to self, if self is of type DeviceType::Master, it will return the paired pointer or keyboard.

If self is of type DeviceType::Slave, it will return the master device to which self is attached to.

If self is of type DeviceType::Floating, None will be returned, as there is no associated device.

Returns

The associated device, or None

Returns the axes currently available on the device.

Returns the axis use for index_.

index_

the index of the axis.

Returns

a AxisUse specifying how the axis is used.

Returns the device type for self.

Returns

the DeviceType for self.

Returns the Display to which self pertains.

Returns

a Display. This memory is owned by GTK+, and must not be freed or unreffed.

Determines whether the pointer follows device motion. This is not meaningful for keyboard devices, which don’t have a pointer.

Returns

true if the pointer follows device motion

If index_ has a valid keyval, this function will return true and fill in keyval and modifiers with the keyval settings.

index_

the index of the macro button to get.

Returns

true if keyval is set for index.

keyval

return value for the keyval.

modifiers

return value for modifiers.

Gets information about which window the given pointer device is in, based on events that have been received so far from the display server. If another application has a pointer grab, or this application has a grab with owner_events = false, None may be returned even if the pointer is physically over one of this application’s windows.

Returns

the last window the device

Determines the mode of the device.

Returns

a InputSource

Returns the number of axes the device currently has.

Returns

the number of axes.

Returns the number of keys the device currently has.

Returns

the number of keys.

Determines the name of the device.

Returns

a name

Gets the current location of self. As a slave device coordinates are those of its master pointer, This function may not be called on devices of type DeviceType::Slave, unless there is an ongoing grab on them, see gdk_device_grab().

Returns
screen

location to store the Screen the self is on, or None.

x

location to store root window X coordinate of self, or None.

y

location to store root window Y coordinate of self, or None.

Gets the current location of self in double precision. As a slave device’s coordinates are those of its master pointer, this function may not be called on devices of type DeviceType::Slave, unless there is an ongoing grab on them. See gdk_device_grab().

Returns
screen

location to store the Screen the self is on, or None.

x

location to store root window X coordinate of self, or None.

y

location to store root window Y coordinate of self, or None.

Returns the product ID of this device, or None if this information couldn’t be obtained. This ID is retrieved from the device, and is thus constant for it. See vendor_id() for more information.

Returns

the product ID, or None

Returns the Seat the device belongs to.

Returns

A Seat. This memory is owned by GTK+ and must not be freed.

Determines the type of the device.

Returns

a InputSource

Returns the vendor ID of this device, or None if this information couldn’t be obtained. This ID is retrieved from the device, and is thus constant for it.

This function, together with product_id(), can be used to eg. compose GSettings paths to store settings for this device.

⚠️ The following code is in C ⚠️

 static GSettings *
 get_device_settings (GdkDevice *device)
 {
   const gchar *vendor, *product;
   GSettings *settings;
   GdkDevice *device;
   gchar *path;

   vendor = gdk_device_get_vendor_id (device);
   product = gdk_device_get_product_id (device);

   path = g_strdup_printf ("/org/example/app/devices/%s:%s/", vendor, product);
   settings = g_settings_new_with_path (DEVICE_SCHEMA, path);
   g_free (path);

   return settings;
 }
Returns

the vendor ID, or None

Obtains the window underneath self, returning the location of the device in win_x and win_y. Returns None if the window tree under self is not known to GDK (for example, belongs to another application).

As a slave device coordinates are those of its master pointer, This function may not be called on devices of type DeviceType::Slave, unless there is an ongoing grab on them, see gdk_device_grab().

Returns

the Window under the device position, or None.

win_x

return location for the X coordinate of the device location, relative to the window origin, or None.

win_y

return location for the Y coordinate of the device location, relative to the window origin, or None.

Obtains the window underneath self, returning the location of the device in win_x and win_y in double precision. Returns None if the window tree under self is not known to GDK (for example, belongs to another application).

As a slave device coordinates are those of its master pointer, This function may not be called on devices of type DeviceType::Slave, unless there is an ongoing grab on them, see gdk_device_grab().

Returns

the Window under the device position, or None.

win_x

return location for the X coordinate of the device location, relative to the window origin, or None.

win_y

return location for the Y coordinate of the device location, relative to the window origin, or None.

Returns a GList of GdkAtoms, containing the labels for the axes that self currently has.

Returns

A GList of GdkAtoms, free with g_list_free().

If the device if of type DeviceType::Master, it will return the list of slave devices attached to it, otherwise it will return None

Returns

the list of slave devices, or None. The list must be freed with g_list_free(), the contents of the list are owned by GTK+ and should not be freed.

Specifies how an axis of a device is used.

index_

the index of the axis

use_

specifies how the axis is used

Specifies the X key event to generate when a macro button of a device is pressed.

index_

the index of the macro button to set

keyval

the keyval to generate

modifiers

the modifiers to set

Sets a the mode of an input device. The mode controls if the device is active and whether the device’s range is mapped to the entire screen or to a single window.

Note: This is only meaningful for floating devices, master devices (and slaves connected to these) drive the pointer cursor, which is not limited by the input mode.

mode

the input mode.

Returns

true if the mode was successfully changed.

Warps self in display to the point x,y on the screen screen, unless the device is confined to a window by a grab, in which case it will be moved as far as allowed by the grab. Warping the pointer creates events as if the user had moved the mouse instantaneously to the destination.

Note that the pointer should normally be under the control of the user. This function was added to cover some rare use cases like keyboard navigation support for the color picker in the GtkColorSelectionDialog.

screen

the screen to warp self to.

x

the X coordinate of the destination.

y

the Y coordinate of the destination.

The DeviceManager the Device pertains to.

Source type for the device.

The maximal number of concurrent touches on a touch device. Will be 0 if the device is not a touch device or if the number of touches is unknown.

Seat of this device.

Device role in the device manager.

The ::changed signal is emitted either when the Device has changed the number of either axes or keys. For example In X this will normally happen when the slave device routing events through the master device changes (for example, user switches from the USB mouse to a tablet), in that case the master device will change to reflect the new slave device axes and keys.

The ::tool-changed signal is emitted on pen/eraser GdkDevices whenever tools enter or leave proximity.

tool

The new current tool

Obtains the motion history for a pointer device; given a starting and ending timestamp, return all events in the motion history for the device in the given range of time. Some windowing systems do not support motion history, in which case, false will be returned. (This is not distinguishable from the case where motion history is supported and no events were found.)

Note that there is also Window::set_event_compression() to get more motion events delivered directly, independent of the windowing system.

window

the window with respect to which which the event coordinates will be reported

start

starting timestamp for range of events to return

stop

ending timestamp for the range of events to return

Returns

true if the windowing system supports motion history and at least one event was found.

events

location to store a newly-allocated array of TimeCoord, or None

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Formats the value using the given formatter. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Returns the type identifier of Self.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Upcasts an object to a superclass or interface T. Read more
Upcasts an object to a reference of its superclass or interface T. Read more
Tries to downcast to a subclass or interface implementor T. Read more
Tries to downcast to a reference of its subclass or interface implementor T. Read more
Tries to cast to an object of type T. This handles upcasting, downcasting and casting between interface and interface implementors. All checks are performed at runtime, while downcast and upcast will do many checks at compile-time already. Read more
Tries to cast to reference to an object of type T. This handles upcasting, downcasting and casting between interface and interface implementors. All checks are performed at runtime, while downcast and upcast will do many checks at compile-time already. Read more
Casts to T unconditionally. Read more
Casts to &T unconditionally. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Returns true if the object is an instance of (can be cast to) T.
Returns the type of the object.
Returns the ObjectClass of the object. Read more
Returns the class of the object.
Returns the class of the object in the given type T. Read more
Returns the interface T of the object. Read more
Sets the property property_name of the object to value value. Read more
Sets the property property_name of the object to value value. Read more
Sets multiple properties of the object at once. Read more
Sets multiple properties of the object at once. Read more
Gets the property property_name of the object and cast it to the type V. Read more
Gets the property property_name of the object. Read more
Check if the object has a property property_name of the given type_. Read more
Get the type of the property property_name of this object. Read more
Get the ParamSpec of the property property_name of this object.
Return all ParamSpec of the properties of this object.
Freeze all property notifications until the return guard object is dropped. Read more
Set arbitrary data on this object with the given key. Read more
Return previously set arbitrary data of this object with the given key. Read more
Retrieve previously set arbitrary data of this object with the given key. Read more
Set arbitrary data on this object with the given key. Read more
Return previously set arbitrary data of this object with the given key. Read more
Retrieve previously set arbitrary data of this object with the given key. Read more
Block a given signal handler. Read more
Unblock a given signal handler.
Stop emission of the currently emitted signal.
Stop emission of the currently emitted signal by the (possibly detailed) signal name.
Connect to the signal signal_name on this object. Read more
Connect to the signal signal_id on this object. Read more
Connect to the signal signal_name on this object. Read more
Connect to the signal signal_id on this object. Read more
Connect to the signal signal_name on this object. Read more
Connect to the signal signal_id on this object. Read more
Connect a closure to the signal signal_name on this object. Read more
Connect a closure to the signal signal_id on this object. Read more
Limits the lifetime of closure to the lifetime of the object. When the object’s reference count drops to zero, the closure will be invalidated. An invalidated closure will ignore any calls to invoke_with_values, or invoke when using Rust closures. Read more
Emit signal by signal id. Read more
Same as Self::emit but takes Value for the arguments.
Emit signal by its name. Read more
Emit signal by its name. Read more
Emit signal by its name with details. Read more
Emit signal by its name with details. Read more
Emit signal by signal id with details. Read more
Emit signal by signal id with details. Read more
Disconnect a previously connected signal handler.
Connect to the notify signal of the object. Read more
Connect to the notify signal of the object. Read more
Connect to the notify signal of the object. Read more
Notify that the given property has changed its value. Read more
Notify that the given property has changed its value. Read more
Downgrade this object to a weak reference.
Add a callback to be notified when the Object is disposed.
Add a callback to be notified when the Object is disposed. Read more
Bind property source_property on this object to the target_property on the target object. Read more
Returns the strong reference count of this object.
Ensures that the type has been registered with the type system.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.