Struct gdk::Device[][src]

pub struct Device(_);
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

This is supported on crate feature v3_22 only.

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 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 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

This is supported on crate feature v3_20 only.

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 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 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.

Grabs the device so that all events coming from this device are passed to this application until the device is ungrabbed with ungrab(), or the window becomes unviewable. This overrides any previous grab on the device by this client.

Note that self and window need to be on the same display.

Device grabs are used for operations which need complete control over the given device events (either pointer or keyboard). For example in GTK+ this is used for Drag and Drop operations, popup menus and such.

Note that if the event mask of an X window has selected both button press and button release events, then a button press event will cause an automatic pointer grab until the button is released. X does this automatically since most applications expect to receive button press and release events in pairs. It is equivalent to a pointer grab on the window with owner_events set to true.

If you set up anything at the time you take the grab that needs to be cleaned up when the grab ends, you should handle the EventGrabBroken events that are emitted when the grab ends unvoluntarily.

Deprecated since 3.20

Use Seat::grab() instead.

window

the Window which will own the grab (the grab window)

grab_ownership

specifies the grab ownership.

owner_events

if false then all device events are reported with respect to window and are only reported if selected by event_mask. If true then pointer events for this application are reported as normal, but pointer events outside this application are reported with respect to window and only if selected by event_mask. In either mode, unreported events are discarded.

event_mask

specifies the event mask, which is used in accordance with owner_events.

cursor

the cursor to display while the grab is active if the device is a pointer. If this is None then the normal cursors are used for window and its descendants, and the cursor for window is used elsewhere.

time_

the timestamp of the event which led to this pointer grab. This usually comes from the GdkEvent struct, though GDK_CURRENT_TIME can be used if the time isn’t known.

Returns

GrabStatus::Success if the grab was successful.

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.

Release any grab on self.

Deprecated since 3.20

Use Seat::ungrab() instead.

time_

a timestap (e.g. GDK_CURRENT_TIME).

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.

This is supported on crate feature v3_20 only.

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.

This is supported on crate feature v3_20 only.

Seat of this device.

This is supported on crate feature v3_22 only.

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.

This is supported on crate feature v3_22 only.

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

tool

The new current tool

This is supported on crate feature v3_22 only.
This is supported on crate feature v3_20 only.
This is supported on crate feature v3_22 only.

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 !=.

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

Performs the conversion.

Performs the conversion.

Returns true if the object is an instance of (can be cast to) T.

Safety Read more

Safety Read more

Safety Read more

Safety Read more

Safety Read more

Safety Read more

Same as connect but takes a SignalId instead of a signal name.

Same as connect_local but takes a SignalId instead of a signal name.

Same as connect_unsafe but takes a SignalId instead of a signal name.

Emit signal by signal id.

Emit signal with details by signal id.

Emit signal by it’s name.

Same as emit but takes Value for the arguments.

Same as emit_by_name but takes Value for the arguments.

Same as emit_with_details but takes Value for the arguments.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Returns a SendValue clone of self.

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.