Class: Gdk::Device

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Overview

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

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

Instance Method Summary collapse

Instance Method Details

#associated_deviceGdk::Device

Associated pointer or keyboard with this device, if any. Devices of type #GDK_DEVICE_TYPE_MASTER always come in keyboard/pointer pairs. Other device types will have a nil associated device.

Returns:

#associated_device=(associated_device) ⇒ Gdk::Device

Associated pointer or keyboard with this device, if any. Devices of type #GDK_DEVICE_TYPE_MASTER always come in keyboard/pointer pairs. Other device types will have a nil associated device.

Parameters:

Returns:

#axesGdk::AxisFlags

The axes currently available for this device.

Returns:

#axes=(axes) ⇒ Gdk::AxisFlags

The axes currently available for this device.

Parameters:

Returns:

#device_managerGdk::DeviceManager

The Gdk::DeviceManager the #GdkDevice pertains to.

Returns:

#device_manager=(device_manager) ⇒ Gdk::DeviceManager

The Gdk::DeviceManager the #GdkDevice pertains to.

Parameters:

Returns:

#device_typeGdk::DeviceType

Returns the device type for device.

Returns:

#displayGdk::Display

The Gdk::Display the #GdkDevice pertains to.

Returns:

#display=(display) ⇒ Gdk::Display

The Gdk::Display the #GdkDevice pertains to.

Parameters:

Returns:

#get_axis(axes, use, value) ⇒ TrueClass

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

Parameters:

  • axes (Array<Float>)

    pointer to an array of axes

  • use (Gdk::AxisUse)

    the use to look for

  • value (Float)

    location to store the found value.

Returns:

  • (TrueClass)

    true if the given axis use was found, otherwise false

#get_axis_use(index_) ⇒ Gdk::AxisUse

Returns the axis use for index_.

Parameters:

  • index_ (Integer)

    the index of the axis.

Returns:

  • (Gdk::AxisUse)

    a Gdk::AxisUse specifying how the axis is used.

#get_axis_value(axes, axis_label, value) ⇒ TrueClass

Interprets an array of double as axis values for a given device, and locates the value in the array for a given axis label, as returned by gdk_device_list_axes()

Parameters:

  • axes (Array<Float>)

    pointer to an array of axes

  • axis_label (Gdk::Atom)

    Gdk::Atom with the axis label.

  • value (Float)

    location to store the found value.

Returns:

  • (TrueClass)

    true if the given axis use was found, otherwise false.

#get_history(window, start, stop, events, n_events) ⇒ TrueClass

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 gdk_window_set_event_compression() to get more motion events delivered directly, independent of the windowing system.

Parameters:

  • window (Gdk::Window)

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

  • start (Integer)

    starting timestamp for range of events to return

  • stop (Integer)

    ending timestamp for the range of events to return

  • events (Array<Gdk::TimeCoord>)

    location to store a newly-allocated array of Gdk::TimeCoord, or nil

  • n_events (Integer)

    location to store the length of events, or nil

Returns:

  • (TrueClass)

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

#get_key(index_, keyval, modifiers) ⇒ TrueClass

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

Parameters:

  • index_ (Integer)

    the index of the macro button to get.

  • keyval (Integer)

    return value for the keyval.

  • modifiers (Gdk::ModifierType)

    return value for modifiers.

Returns:

  • (TrueClass)

    true if keyval is set for index.

#get_position(screen, x, y) ⇒ nil

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

Parameters:

  • screen (Gdk::Screen)

    location to store the Gdk::Screen the device is on, or nil.

  • x (Integer)

    location to store root window X coordinate of device, or nil.

  • y (Integer)

    location to store root window Y coordinate of device, or nil.

Returns:

  • (nil)

#get_position_double(screen, x, y) ⇒ nil

Gets the current location of device 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 %GDK_DEVICE_TYPE_SLAVE, unless there is an ongoing grab on them. See gdk_device_grab().

Parameters:

  • screen (Gdk::Screen)

    location to store the Gdk::Screen the device is on, or nil.

  • x (Float)

    location to store root window X coordinate of device, or nil.

  • y (Float)

    location to store root window Y coordinate of device, or nil.

Returns:

  • (nil)

#get_state(window, axes, mask) ⇒ nil

Gets the current state of a pointer device relative to window. As a slave device’s coordinates are those of its master pointer, this function may not be called on devices of type %GDK_DEVICE_TYPE_SLAVE, unless there is an ongoing grab on them. See gdk_device_grab(). the axes of device in, or nil.

Parameters:

  • window (Gdk::Window)

    a Gdk::Window.

  • axes (Array<Float>)

    an array of doubles to store the values of

  • mask (Gdk::ModifierType)

    location to store the modifiers, or nil.

Returns:

  • (nil)

#get_window_at_position(win_x, win_y) ⇒ Gdk::Window

Obtains the window underneath device, returning the location of the device in win_x and win_y. Returns nil if the window tree under device 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 %GDK_DEVICE_TYPE_SLAVE, unless there is an ongoing grab on them, see gdk_device_grab(). device position, or nil.

Parameters:

  • win_x (Integer)

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

  • win_y (Integer)

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

Returns:

#get_window_at_position_double(win_x, win_y) ⇒ Gdk::Window

Obtains the window underneath device, returning the location of the device in win_x and win_y in double precision. Returns nil if the window tree under device 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 %GDK_DEVICE_TYPE_SLAVE, unless there is an ongoing grab on them, see gdk_device_grab().

Parameters:

  • win_x (Float)

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

  • win_y (Float)

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

Returns:

  • (Gdk::Window)

    the Gdk::Window under the device position, or nil.

#grab(window, grab_ownership, owner_events, event_mask, cursor, time_) ⇒ Gdk::GrabStatus

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

Note that device 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 Gdk::EventGrabBroken events that are emitted when the grab ends unvoluntarily.

Parameters:

  • window (Gdk::Window)

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

  • grab_ownership (Gdk::GrabOwnership)

    specifies the grab ownership.

  • owner_events (TrueClass)

    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 (Gdk::EventMask)

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

  • cursor (Gdk::Cursor)

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

  • time_ (Integer)

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

Returns:

#has_cursorTrueClass

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

Returns:

  • (TrueClass)

    true if the pointer follows device motion

#has_cursor=(has_cursor) ⇒ TrueClass

Whether the device is represented by a cursor on the screen. Devices of type %GDK_DEVICE_TYPE_MASTER will have true here.

Parameters:

  • has_cursor (TrueClass)

Returns:

  • (TrueClass)

    has-cursor

  • (TrueClass)

    has-cursor

#has_cursor?TrueClass

Whether the device is represented by a cursor on the screen. Devices of type %GDK_DEVICE_TYPE_MASTER will have true here.

Returns:

  • (TrueClass)

    has-cursor

#input_modeGdk::InputMode

Returns input-mode.

Returns:

#input_mode=(input_mode) ⇒ Gdk::InputMode

Parameters:

Returns:

#input_sourceGdk::InputSource

Source type for the device.

Returns:

#input_source=(input_source) ⇒ Gdk::InputSource

Source type for the device.

Parameters:

Returns:

#last_event_windowGdk::Window

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, nil may be returned even if the pointer is physically over one of this application’s windows.

Returns:

#list_axesGLib::List

Returns a #GList of Gdk::Atoms, containing the labels for the axes that device currently has.

Returns:

  • (GLib::List)

    A #GList of Gdk::Atoms, free with g_list_free().

#list_slave_devicesGLib::List

If the device if of type %GDK_DEVICE_TYPE_MASTER, it will return the list of slave devices attached to it, otherwise it will return nil

Returns:

  • (GLib::List)

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

#modeGdk::InputMode

Determines the mode of the device.

Returns:

#mode=(mode) ⇒ TrueClass

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.

Parameters:

Returns:

  • (TrueClass)

    true if the mode was successfully changed.

#n_axesInteger

Number of axes in the device.

Returns:

  • (Integer)

    n-axes

#n_axes=(n_axes) ⇒ Integer

Number of axes in the device.

Parameters:

  • n_axes (Integer)

Returns:

  • (Integer)

    n-axes

  • (Integer)

    n-axes

#n_keysInteger

Returns the number of keys the device currently has.

Returns:

  • (Integer)

    the number of keys.

#nameString

The device name.

Returns:

  • (String)

    name

#name=(name) ⇒ String

The device name.

Parameters:

  • name (String)

Returns:

  • (String)

    name

  • (String)

    name

#num_touchesInteger

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.

Returns:

  • (Integer)

    num-touches

#num_touches=(num_touches) ⇒ Integer

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.

Parameters:

  • num_touches (Integer)

Returns:

  • (Integer)

    num-touches

  • (Integer)

    num-touches

#product_idString

Product ID of this device, see gdk_device_get_product_id().

Returns:

  • (String)

    product-id

#product_id=(product_id) ⇒ String

Product ID of this device, see gdk_device_get_product_id().

Parameters:

  • product_id (String)

Returns:

  • (String)

    product-id

  • (String)

    product-id

#seatGdk::Seat

Gdk::Seat of this device.

Returns:

#seat=(seat) ⇒ Gdk::Seat

Gdk::Seat of this device.

Parameters:

Returns:

#set_axis_use(index_, use) ⇒ nil

Specifies how an axis of a device is used.

Parameters:

  • index_ (Integer)

    the index of the axis

  • use (Gdk::AxisUse)

    specifies how the axis is used

Returns:

  • (nil)

#set_key(index_, keyval, modifiers) ⇒ nil

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

Parameters:

  • index_ (Integer)

    the index of the macro button to set

  • keyval (Integer)

    the keyval to generate

  • modifiers (Gdk::ModifierType)

    the modifiers to set

Returns:

  • (nil)

#sourceGdk::InputSource

Determines the type of the device.

Returns:

#toolGdk::DeviceTool

Returns tool.

Returns:

#tool=(tool) ⇒ Gdk::DeviceTool

Parameters:

Returns:

#typeGdk::DeviceType

Device role in the device manager.

Returns:

#type=(type) ⇒ Gdk::DeviceType

Device role in the device manager.

Parameters:

Returns:

#ungrab(time_) ⇒ nil

Release any grab on device.

Parameters:

  • time_ (Integer)

    a timestap (e.g. %GDK_CURRENT_TIME).

Returns:

  • (nil)

#vendor_idString

Vendor ID of this device, see gdk_device_get_vendor_id().

Returns:

  • (String)

    vendor-id

#vendor_id=(vendor_id) ⇒ String

Vendor ID of this device, see gdk_device_get_vendor_id().

Parameters:

  • vendor_id (String)

Returns:

  • (String)

    vendor-id

  • (String)

    vendor-id

#warp(screen, x, y) ⇒ nil

Warps device 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 Gtk::ColorSelectionDialog.

Parameters:

  • screen (Gdk::Screen)

    the screen to warp device to.

  • x (Integer)

    the X coordinate of the destination.

  • y (Integer)

    the Y coordinate of the destination.

Returns:

  • (nil)