gtkmm 3.2.0

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Protected Member Functions | Related Functions

# Gdk::Device Class Reference

A Gdk::Device instance contains a detailed description of an extended input device. More...

Inheritance diagram for Gdk::Device:
[legend]

List of all members.

## Public Member Functions
virtual | ~Device ()
GdkDevice* | gobj ()
| Provides access to the underlying C GObject.
const GdkDevice* | gobj () const
| Provides access to the underlying C GObject.
GdkDevice* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
Glib::ustring | get_name () const
| Determines the name of the device.
bool | get_has_cursor () const
| Determines whether the pointer follows device motion.
InputSource | get_source () const
| Determines the type of the device.
InputMode | get_mode () const
| Determines the mode of the device.
bool | set_mode (InputMode mode)
| Sets a the mode of an input device.
int | get_n_keys () const
| Returns the number of keys the device currently has.
bool | get_key (guint index_, guint& keyval, ModifierType& modifiers) const
| If index has a valid keyval, this function will return `true` and fill in keyval and modifiers with the keyval settings.
void | set_key (guint index_, guint keyval, ModifierType modifiers)
| Specifies the X key event to generate when a macro button of a device is pressed.
AxisUse | get_axis_use (guint index_) const
| Returns the axis use for index.
void | set_axis_use (guint index_, AxisUse use)
| Specifies how an axis of a device is used.
void | get_state (const Glib::RefPtr< Window >& window, double& axes, ModifierType& mask)
| Gets the current state of a pointer device relative to window.
std::vector< TimeCoord > | get_history (const Glib::RefPtr< Window >& window, guint32 start, guint32 stop) const
std::vector< Glib::RefPtr < Gdk::Device > > | list_slave_devices ()
| 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 `0`
int | get_n_axes () const
| Returns the number of axes the device currently has.
bool | get_axis_value (double& axes, GdkAtom axis_label, double&value) const
| 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 list_axes()
bool | get_axis (double& axes, AxisUse use, double&value) const
| Interprets an array of double as axis values for a given device, and locates the value in the array for a given axis use.
Glib::RefPtr< Display > | get_display ()
| Returns the Gdk::Display to which device pertains.
Glib::RefPtr< const Display > | get_display () const
| Returns the Gdk::Display to which device pertains.
Glib::RefPtr< Device > | get_associated_device ()
| Returns the associated device to device, if device is of type Gdk::DEVICE_TYPE_MASTER, it will return the paired pointer or keyboard.
Glib::RefPtr< const Device > | get_associated_device () const
| Returns the associated device to device, if device is of type Gdk::DEVICE_TYPE_MASTER, it will return the paired pointer or keyboard.
DeviceType | get_device_type () const
| Returns the device type for device.
GrabStatus | grab (const Glib::RefPtr< Window >& window, GrabOwnership grab_ownership, bool owner_events, EventMask event_mask, const Glib::RefPtr< Cursor >& cursor, guint32 time_)
| 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.
GrabStatus | grab (const Glib::RefPtr< Window >& window, GrabOwnership grab_ownership, bool owner_events, EventMask event_mask, guint32 time_)
void | ungrab (guint32 time_)
| Release any grab on device.
void | warp (const Glib::RefPtr< Screen >& p1, int x, int y)
| 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.
void | get_position (int& x, int& y) const
void | get_position (Glib::RefPtr< Screen >& screen, int& x, int& y) const
Glib::RefPtr< Window > | get_window_at_position (int& win_x, int& win_y)
| Obtains the window underneath device, returning the location of the device in win_x and win_y.
Glib::RefPtr< const Window > | get_window_at_position (int& win_x, int& win_y) const
| Obtains the window underneath device, returning the location of the device in win_x and win_y.
Glib::RefPtr< Window > | get_window_at_position ()
Glib::RefPtr< const Window > | get_window_at_position () const
## Protected Member Functions
| Device ()
## Related Functions
(Note that these are not member functions.)
Glib::RefPtr< Gdk::Device > | wrap (GdkDevice* object, bool take_copy=false)
| A Glib::wrap() method for this object.

## Detailed Description

A Gdk::Device instance contains a detailed description of an extended input device.

## Constructor & Destructor Documentation

virtual Gdk::Device::~Device | ( |  | ) | `[virtual]`

Gdk::Device::Device | ( |  | ) | `[protected]`

## Member Function Documentation

Glib::RefPtr<Device> Gdk::Device::get_associated_device | ( |  | ) |

Returns the associated device to device, if device is of type Gdk::DEVICE_TYPE_MASTER, it will return the paired pointer or keyboard.

If device is of type Gdk::DEVICE_TYPE_SLAVE, it will return the master device to which device is attached to.

If device is of type Gdk::DEVICE_TYPE_FLOATING, `0` will be returned, as there is no associated device.

Since gtkmm 3.0:

Returns:
  The associated device, or `0`.

Glib::RefPtr<const Device> Gdk::Device::get_associated_device | ( |  | ) | const

Returns the associated device to device, if device is of type Gdk::DEVICE_TYPE_MASTER, it will return the paired pointer or keyboard.

If device is of type Gdk::DEVICE_TYPE_SLAVE, it will return the master device to which device is attached to.

If device is of type Gdk::DEVICE_TYPE_FLOATING, `0` will be returned, as there is no associated device.

Since gtkmm 3.0:

Returns:
  The associated device, or `0`.

bool Gdk::Device::get_axis | ( | double & | axes,
|  | AxisUse | use,
|  | double & | value
| ) |  | const

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

AxisUse Gdk::Device::get_axis_use | ( | guint | index_ | ) | const

Returns the axis use for index.

Since gtkmm 2.20:

Parameters:

  index | The index of the axis.

Returns:
  A Gdk::AxisUse specifying how the axis is used.

bool Gdk::Device::get_axis_value | ( | double & | axes,
|  | GdkAtom | axis_label,
|  | double & | value
| ) |  | const

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 list_axes()

Since gtkmm 3.0:

Parameters:

  axes | Pointer to an array of axes.
  axis_label | Gdk::Atom with the axis label.
  value | Location to store the found value.

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

DeviceType Gdk::Device::get_device_type | ( |  | ) | const

Returns the device type for device.

Since gtkmm 3.0:

Returns:
  The Gdk::DeviceType for device.

Glib::RefPtr<const Display> Gdk::Device::get_display | ( |  | ) | const

Returns the Gdk::Display to which device pertains.

Since gtkmm 3.0:

Returns:
  A Gdk::Display. This memory is owned by GTK+, and must not be freed or unreffed.

Glib::RefPtr<Display> Gdk::Device::get_display | ( |  | ) |

Returns the Gdk::Display to which device pertains.

Since gtkmm 3.0:

Returns:
  A Gdk::Display. This memory is owned by GTK+, and must not be freed or unreffed.

bool Gdk::Device::get_has_cursor | ( |  | ) | const

Determines whether the pointer follows device motion.

Since gtkmm 2.20:

Returns:
  `true` if the pointer follows device motion.

std::vector<TimeCoord> Gdk::Device::get_history | ( | const Glib::RefPtr< Window >& | window,
|  | guint32 | start,
|  | guint32 | stop
| ) |  | const

bool Gdk::Device::get_key | ( | guint | index_,
|  | guint & | keyval,
|  | ModifierType& | modifiers
| ) |  | const

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

Since gtkmm 2.20:

Parameters:

  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.

InputMode Gdk::Device::get_mode | ( |  | ) | const

Determines the mode of the device.

Since gtkmm 2.20:

Returns:
  A Gdk::InputSource.

int Gdk::Device::get_n_axes | ( |  | ) | const

Returns the number of axes the device currently has.

Since gtkmm 3.0:

Returns:
  The number of axes.

int Gdk::Device::get_n_keys | ( |  | ) | const

Returns the number of keys the device currently has.

Since gtkmm 2.24:

Returns:
  The number of keys.

Glib::ustring Gdk::Device::get_name | ( |  | ) | const

Determines the name of the device.

Since gtkmm 2.20:

Returns:
  A name.

void Gdk::Device::get_position | ( | int & | x,
|  | int & | y
| ) |  | const

void Gdk::Device::get_position | ( | Glib::RefPtr< Screen >& | screen,
|  | int & | x,
|  | int & | y
| ) |  | const

InputSource Gdk::Device::get_source | ( |  | ) | const

Determines the type of the device.

Since gtkmm 2.20:

Returns:
  A Gdk::InputSource.

void Gdk::Device::get_state | ( | const Glib::RefPtr< Window >& | window,
|  | double & | axes,
|  | ModifierType& | mask
| ) |  |

Gets the current state of a pointer device relative to window.

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 grab().

Parameters:

  window | A Gdk::Window.
  axes | An array of doubles to store the values of the axes of device in, or `0`.
  mask | Location to store the modifiers, or `0`.

Glib::RefPtr<const Window> Gdk::Device::get_window_at_position | ( | int & | win_x,
|  | int & | win_y
| ) |  | const

Obtains the window underneath device, returning the location of the device in win_x and win_y.

Returns `0` 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 grab().

Since gtkmm 3.0:

Parameters:

  win_x | Return location for the X coordinate of the device location, relative to the window origin, or `0`.
  win_y | Return location for the Y coordinate of the device location, relative to the window origin, or `0`.

Returns:
  The Gdk::Window under the device position, or `0`.

Glib::RefPtr<const Window> Gdk::Device::get_window_at_position | ( |  | ) | const

Glib::RefPtr<Window> Gdk::Device::get_window_at_position | ( |  | ) |

Glib::RefPtr<Window> Gdk::Device::get_window_at_position | ( | int & | win_x,
|  | int & | win_y
| ) |  |

Obtains the window underneath device, returning the location of the device in win_x and win_y.

Returns `0` 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 grab().

Since gtkmm 3.0:

Parameters:

  win_x | Return location for the X coordinate of the device location, relative to the window origin, or `0`.
  win_y | Return location for the Y coordinate of the device location, relative to the window origin, or `0`.

Returns:
  The Gdk::Window under the device position, or `0`.

const GdkDevice* Gdk::Device::gobj | ( |  | ) | const`[inline]`

Provides access to the underlying C GObject.

Reimplemented from Glib::ObjectBase.

GdkDevice* Gdk::Device::gobj | ( |  | ) | `[inline]`

Provides access to the underlying C GObject.

Reimplemented from Glib::ObjectBase.

GdkDevice* Gdk::Device::gobj_copy | ( |  | ) |

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

GrabStatus Gdk::Device::grab | ( | const Glib::RefPtr< Window >& | window,
|  | GrabOwnership | grab_ownership,
|  | bool | owner_events,
|  | EventMask | event_mask,
|  | const Glib::RefPtr< Cursor >& | cursor,
|  | guint32 | time_
| ) |  |

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.

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.

Since gtkmm 3.0:

Parameters:

  window | The Gdk::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 `0` 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 Gdk::Event struct, though Gdk::CURRENT_TIME can be used if the time isn't known.

Returns:
  Gdk::GRAB_SUCCESS if the grab was successful.

GrabStatus Gdk::Device::grab | ( | const Glib::RefPtr< Window >& | window,
|  | GrabOwnership | grab_ownership,
|  | bool | owner_events,
|  | EventMask | event_mask,
|  | guint32 | time_
| ) |  |

std::vector<Glib::RefPtr<Gdk::Device> > Gdk::Device::list_slave_devices | ( |  | ) |

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

Returns:
  The list of slave devices, or `0`. The list must be freed with Glib::list_free(), the contents of the list are owned by GTK+ and should not be freed.

void Gdk::Device::set_axis_use | ( | guint | index_,
|  | AxisUse | use
| ) |  |

Specifies how an axis of a device is used.

Parameters:

  index | The index of the axis.
  use | Specifies how the axis is used.

void Gdk::Device::set_key | ( | guint | index_,
|  | guint | keyval,
|  | ModifierType | modifiers
| ) |  |

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

Parameters:

  index | The index of the macro button to set.
  keyval | The keyval to generate.
  modifiers | The modifiers to set.

bool Gdk::Device::set_mode | ( | InputMode | mode | ) |

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.

Parameters:

  mode | The input mode.

Returns:
  `true` if the mode was successfully changed.

void Gdk::Device::ungrab | ( | guint32 | time_ | ) |

Release any grab on device.

Since gtkmm 3.0:

Parameters:

  time | A timestap (e.g. Gdk::CURRENT_TIME).

void Gdk::Device::warp | ( | const Glib::RefPtr< Screen >& | p1,
|  | int | x,
|  | int | y
| ) |  |

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.

Since gtkmm 3.0:

Parameters:

  screen | The screen to warp device to.
  x | The X coordinate of the destination.
  y | The Y coordinate of the destination.

## Friends And Related Function Documentation

Glib::RefPtr< Gdk::Device > wrap | ( | GdkDevice * | object,
|  | bool | take_copy = `false`
| ) |  | `[related]`

A Glib::wrap() method for this object.

Parameters:

  object | The C instance.
  take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns:
  A C++ instance that wraps this C instance.

The documentation for this class was generated from the following file:

- gdkmm/device.h