[]Struct gdk::Device

pub struct Device(_, _);

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.

Implementations

impl Device[src]

pub fn get_associated_device(&self) -> Option<Device>[src]

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

pub fn get_axes(&self) -> AxisFlags[src]

Returns the axes currently available on the device.

Feature: v3_22

pub fn get_axis_use(&self, index_: u32) -> AxisUse[src]

Returns the axis use for index_.

index_

the index of the axis.

Returns

a AxisUse specifying how the axis is used.

pub fn get_device_type(&self) -> DeviceType[src]

Returns the device type for self.

Returns

the DeviceType for self.

pub fn get_display(&self) -> Display[src]

Returns the Display to which self pertains.

Returns

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

pub fn get_has_cursor(&self) -> bool[src]

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

pub fn get_key(&self, index_: u32) -> Option<(u32, ModifierType)>[src]

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.

keyval

return value for the keyval.

modifiers

return value for modifiers.

Returns

true if keyval is set for index.

pub fn get_last_event_window(&self) -> Option<Window>[src]

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

pub fn get_mode(&self) -> InputMode[src]

Determines the mode of the device.

Returns

a InputSource

pub fn get_n_axes(&self) -> i32[src]

Returns the number of axes the device currently has.

Returns

the number of axes.

pub fn get_n_keys(&self) -> i32[src]

Returns the number of keys the device currently has.

Returns

the number of keys.

pub fn get_name(&self) -> Option<GString>[src]

Determines the name of the device.

Returns

a name

pub fn get_position(&self) -> (Screen, i32, i32)[src]

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 Device::grab.

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.

pub fn get_position_double(&self) -> (Screen, f64, f64)[src]

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 Device::grab.

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.

pub fn get_product_id(&self) -> Option<GString>[src]

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 Device::get_vendor_id for more information.

Feature: v3_16

Returns

the product ID, or None

pub fn get_seat(&self) -> Option<Seat>[src]

Returns the Seat the device belongs to.

Feature: v3_20

Returns

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

pub fn get_source(&self) -> InputSource[src]

Determines the type of the device.

Returns

a InputSource

pub fn get_vendor_id(&self) -> Option<GString>[src]

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 Device::get_product_id, can be used to eg. compose gio::Settings paths to store settings for this device.

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

Feature: v3_16

Returns

the vendor ID, or None

pub fn get_window_at_position(&self) -> (Option<Window>, i32, i32)[src]

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 Device::grab.

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

the Window under the device position, or None.

pub fn get_window_at_position_double(&self) -> (Option<Window>, f64, f64)[src]

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 Device::grab.

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

the Window under the device position, or None.

pub fn grab<P: IsA<Window>>(
    &self,
    window: &P,
    grab_ownership: GrabOwnership,
    owner_events: bool,
    event_mask: EventMask,
    cursor: Option<&Cursor>,
    time_: u32
) -> GrabStatus
[src]

Grabs the device so that all events coming from this device are passed to this application until the device is ungrabbed with Device::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.

pub fn list_axes(&self) -> Vec<Atom>[src]

Returns a glib::List of GdkAtoms, containing the labels for the axes that self currently has.

Returns

A glib::List of GdkAtoms, free with glib::List::free.

pub fn list_slave_devices(&self) -> Vec<Device>[src]

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 glib::List::free, the contents of the list are owned by GTK+ and should not be freed.

pub fn set_axis_use(&self, index_: u32, use_: AxisUse)[src]

Specifies how an axis of a device is used.

index_

the index of the axis

use_

specifies how the axis is used

pub fn set_key(&self, index_: u32, keyval: u32, modifiers: ModifierType)[src]

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

pub fn set_mode(&self, mode: InputMode) -> bool[src]

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.

pub fn ungrab(&self, time_: u32)[src]

Release any grab on self.

Deprecated since 3.20

Use Seat::ungrab instead.

time_

a timestap (e.g. GDK_CURRENT_TIME).

pub fn warp(&self, screen: &Screen, x: i32, y: i32)[src]

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.

pub fn get_property_device_manager(&self) -> Option<DeviceManager>[src]

The DeviceManager the Device pertains to.

pub fn get_property_input_mode(&self) -> InputMode[src]

pub fn set_property_input_mode(&self, input_mode: InputMode)[src]

pub fn get_property_input_source(&self) -> InputSource[src]

Source type for the device.

pub fn get_property_num_touches(&self) -> u32[src]

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.

Feature: v3_20

pub fn set_property_seat(&self, seat: Option<&Seat>)[src]

Seat of this device.

Feature: v3_20

pub fn get_property_tool(&self) -> Option<DeviceTool>[src]

pub fn get_property_type(&self) -> DeviceType[src]

Device role in the device manager.

pub fn grab_info_libgtk_only(
    display: &Display,
    device: &Device
) -> Option<(Window, bool)>
[src]

Determines information about the current keyboard grab. This is not public API and must not be used by applications.

Deprecated since 3.16

The symbol was never meant to be used outside of GTK+

display

the display for which to get the grab information

device

device to get the grab information from

grab_window

location to store current grab window

owner_events

location to store boolean indicating whether the owner_events flag to gdk_keyboard_grab or gdk_pointer_grab was true.

Returns

true if this application currently has the keyboard grabbed.

pub fn connect_changed<F: Fn(&Device) + 'static>(&self, f: F) -> SignalHandlerId[src]

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.

pub fn connect_tool_changed<F: Fn(&Device, &DeviceTool) + 'static>(
    &self,
    f: F
) -> SignalHandlerId
[src]

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

Feature: v3_22

tool

The new current tool

pub fn connect_property_associated_device_notify<F: Fn(&Device) + 'static>(
    &self,
    f: F
) -> SignalHandlerId
[src]

pub fn connect_property_axes_notify<F: Fn(&Device) + 'static>(
    &self,
    f: F
) -> SignalHandlerId
[src]

pub fn connect_property_input_mode_notify<F: Fn(&Device) + 'static>(
    &self,
    f: F
) -> SignalHandlerId
[src]

pub fn connect_property_n_axes_notify<F: Fn(&Device) + 'static>(
    &self,
    f: F
) -> SignalHandlerId
[src]

pub fn connect_property_seat_notify<F: Fn(&Device) + 'static>(
    &self,
    f: F
) -> SignalHandlerId
[src]

pub fn connect_property_tool_notify<F: Fn(&Device) + 'static>(
    &self,
    f: F
) -> SignalHandlerId
[src]

pub fn connect_property_type_notify<F: Fn(&Device) + 'static>(
    &self,
    f: F
) -> SignalHandlerId
[src]

impl Device[src]

pub fn get_axis(&self, axes: &mut [f64], use_: AxisUse, value: &mut f64) -> bool[src]

Interprets an array of double as axis values for a given device, and locates the value in the array for a given axis use.

axes

pointer to an array of axes

use_

the use to look for

value

location to store the found value.

Returns

true if the given axis use was found, otherwise false

pub fn get_history<P: IsA<Window>>(
    &self,
    window: &P,
    start: u32,
    stop: u32
) -> Vec<TimeCoord>
[src]

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

events

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

n_events

location to store the length of events, or None

Returns

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

Trait Implementations

impl Clone for Device

impl Debug for Device

impl Display for Device[src]

impl Eq for Device

impl Hash for Device

impl IsA<Device> for DevicePad

impl Ord for Device

impl<T: ObjectType> PartialEq<T> for Device

impl<T: ObjectType> PartialOrd<T> for Device

impl StaticType for Device

Auto Trait Implementations

impl RefUnwindSafe for Device

impl !Send for Device

impl !Sync for Device

impl Unpin for Device

impl UnwindSafe for Device

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<Super, Sub> CanDowncast<Sub> for Super where
    Sub: IsA<Super>,
    Super: IsA<Super>, 

impl<T> Cast for T where
    T: ObjectType, 

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ObjectExt for T where
    T: ObjectType, 

impl<'a, T> ToGlibContainerFromSlice<'a, *const GList> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<List>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<'a, T> ToGlibContainerFromSlice<'a, *const GPtrArray> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<PtrArray>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<'a, T> ToGlibContainerFromSlice<'a, *mut GArray> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<Array>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<'a, T> ToGlibContainerFromSlice<'a, *mut GList> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<List>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<'a, T> ToGlibContainerFromSlice<'a, *mut GPtrArray> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<PtrArray>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToSendValue for T where
    T: ToValue + SetValue + Send + ?Sized

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> ToValue for T where
    T: SetValue + ?Sized

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.