1.13 <GdkDevice>

Class: <GdkDevice>

It derives from <GObject>.

Represents an input device, such as a keyboard, mouse or touchpad.

See the <GdkSeat> documentation for more information about the various kinds of devices, and their relationships.

Properties

Property: device:active-layout-index self

The index of the keyboard active layout of a <GdkDevice>.

Will be -1 if there is no valid active layout.

This is only relevant for keyboard devices.

Its value is a 32-bit integer.

It is read only.

Property: device:caps-lock-state self

Whether Caps Lock is on.

This is only relevant for keyboard devices.

Its value is a boolean.

It is read only.

Property: device:direction self

The direction of the current layout.

This is only relevant for keyboard devices.

Its value is a <PangoDirection>.

It is read only.

Property: device:display self

The <GdkDisplay> the <GdkDevice> pertains to.

Its value is a <GdkDisplay>, or #f.

It can only be set when the object is made, with #:display.

Property: device:has-bidi-layouts self

Whether the device has both right-to-left and left-to-right layouts.

This is only relevant for keyboard devices.

Its value is a boolean.

It is read only.

Property: device:has-cursor self

Whether the device is represented by a cursor on the screen.

Its value is a boolean.

It can only be set when the object is made, with #:has-cursor.

Property: device:layout-names self

The names of the keyboard layouts of a <GdkDevice>.

This is only relevant for keyboard devices.

Its value is a vector, each a string, or #f.

It is read only.

Property: device:modifier-state self

The current modifier state of the device.

This is only relevant for keyboard devices.

Its value is a <GdkModifierType>.

It is read only.

Property: device:n-axes self

Number of axes in the device.

Its value is an unsigned 32-bit integer.

It is read only.

Property: device:name self

The device name.

Its value is a string, or #f.

It can only be set when the object is made, with #:name.

Property: device:num-lock-state self

Whether Num Lock is on.

This is only relevant for keyboard devices.

Its value is a boolean.

It is read only.

Property: device:num-touches self

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.

Its value is an unsigned 32-bit integer.

It can only be set when the object is made, with #:num-touches.

Property: device:product-id self

Product ID of this device.

See device:get-product-id.

Its value is a string, or #f.

It can only be set when the object is made, with #:product-id.

Property: device:scroll-lock-state self

Whether Scroll Lock is on.

This is only relevant for keyboard devices.

Its value is a boolean.

It is read only.

Property: device:seat self

<GdkSeat> of this device.

Its value is a <GdkSeat>, or #f.

Set it with (set! (device:seat self) value).

Property: device:source self

Source type for the device.

Its value is a <GdkInputSource> (or, to set it, one of its symbols).

It can only be set when the object is made, with #:source.

Property: device:tool self

The <GdkDeviceTool> that is currently used with this device.

Its value is a <GdkDeviceTool>, or #f.

It is read only.

Property: device:vendor-id self

Vendor ID of this device.

See device:get-vendor-id.

Its value is a string, or #f.

It can only be set when the object is made, with #:vendor-id.

Procedures

Method: device:get-active-layout-index self ⇒ %return
Method: get-active-layout-index self ⇒ %return

Retrieves the index of the active layout of the keyboard.

If there is no valid active layout for the <GdkDevice>, this function will return -1;

This is only relevant for keyboard devices.

self

Passed: a <GdkDevice>.

a <GdkDevice>

%return

Returned: a 32-bit integer.

The layout index of the active layout or -1.

Method: device:get-caps-lock-state? self ⇒ %return
Method: get-caps-lock-state? self ⇒ %return

Retrieves whether the Caps Lock modifier of the keyboard is locked.

This is only relevant for keyboard devices.

self

Passed: a <GdkDevice>.

a <GdkDevice>

%return

Returned: a boolean.

#t if Caps Lock is on for self

Method: device:get-device-tool self ⇒ %return
Method: get-device-tool self ⇒ %return

Retrieves the current tool for self.

self

Passed: a <GdkDevice>.

a <GdkDevice>

%return

Returned: a <GdkDeviceTool>, or #f.

the <GdkDeviceTool>

Method: device:get-direction self ⇒ %return
Method: get-direction self ⇒ %return

Returns the direction of effective layout of the keyboard.

This is only relevant for keyboard devices.

The direction of a layout is the direction of the majority of its symbols. See unichar-direction.

self

Passed: a <GdkDevice>.

a <GdkDevice>

%return

Returned: a <PangoDirection>.

ltr or rtl if it can determine the direction. neutral otherwise

Method: device:get-display self ⇒ %return
Method: get-display self ⇒ %return

Returns the <GdkDisplay> to which self pertains.

self

Passed: a <GdkDevice>.

a <GdkDevice>

%return

Returned: a <GdkDisplay>.

a <GdkDisplay>

Method: device:get-has-cursor? self ⇒ %return
Method: get-has-cursor? self ⇒ %return

Determines whether the pointer follows device motion.

This is not meaningful for keyboard devices, which don’t have a pointer.

self

Passed: a <GdkDevice>.

a <GdkDevice>

%return

Returned: a boolean.

#t if the pointer follows device motion

Method: device:get-layout-names self ⇒ %return
Method: get-layout-names self ⇒ %return

Retrieves the names of the layouts of the keyboard.

This is only relevant for keyboard devices.

self

Passed: a <GdkDevice>.

a <GdkDevice>

%return

Returned: a vector, each a string, or #f.

#f-terminated array of strings of layouts,

Method: device:get-modifier-state self ⇒ %return
Method: get-modifier-state self ⇒ %return

Retrieves the current modifier state of the keyboard.

This is only relevant for keyboard devices.

self

Passed: a <GdkDevice>.

a <GdkDevice>

%return

Returned: a <GdkModifierType>.

the current modifier state

Method: device:get-name self ⇒ %return
Method: get-name self ⇒ %return

The name of the device, suitable for showing in a user interface.

self

Passed: a <GdkDevice>.

a GdkDevice‘

%return

Returned: a string.

a name

Method: device:get-num-lock-state? self ⇒ %return
Method: get-num-lock-state? self ⇒ %return

Retrieves whether the Num Lock modifier of the keyboard is locked.

This is only relevant for keyboard devices.

self

Passed: a <GdkDevice>.

a “GdkDevice‘

%return

Returned: a boolean.

#t if Num Lock is on for self

Method: device:get-num-touches self ⇒ %return
Method: get-num-touches self ⇒ %return

Retrieves the number of touch points associated to self.

self

Passed: a <GdkDevice>.

a <GdkDevice>

%return

Returned: an unsigned 32-bit integer.

the number of touch points

Method: device:get-product-id self ⇒ %return
Method: get-product-id self ⇒ %return

Returns the product ID of this device.

This ID is retrieved from the device, and does not change. See device:get-vendor-id for more information.

self

Passed: a <GdkDevice>.

a physical <GdkDevice>

%return

Returned: a string, or #f.

the product ID

Method: device:get-scroll-lock-state? self ⇒ %return
Method: get-scroll-lock-state? self ⇒ %return

Retrieves whether the Scroll Lock modifier of the keyboard is locked.

This is only relevant for keyboard devices.

self

Passed: a <GdkDevice>.

a <GdkDevice>

%return

Returned: a boolean.

#t if Scroll Lock is on for self

Method: device:get-seat self ⇒ %return
Method: get-seat self ⇒ %return

Returns the <GdkSeat> the device belongs to.

self

Passed: a <GdkDevice>.

A <GdkDevice>

%return

Returned: a <GdkSeat>.

a <GdkSeat>

Method: device:get-source self ⇒ %return
Method: get-source self ⇒ %return

Determines the type of the device.

self

Passed: a <GdkDevice>.

a <GdkDevice>

%return

Returned: a <GdkInputSource>.

a <GdkInputSource>

Method: device:get-surface-at-position self ⇒ %return win-x win-y
Method: get-surface-at-position self ⇒ %return win-x win-y

Obtains the surface underneath self, returning the location of the device in win-x and win-y.

Returns #f if the surface tree under self is not known to GDK (for example, belongs to another application).

self

Passed: a <GdkDevice>.

pointer <GdkDevice> to query info to

%return

Returned: a <GdkSurface>, or #f.

the <GdkSurface> under the device position

win-x

Returned: a real number.

return location for the X coordinate of the device location relative to the surface origin

win-y

Returned: a real number.

return location for the Y coordinate of the device location relative to the surface origin

Method: device:get-timestamp self ⇒ %return
Method: get-timestamp self ⇒ %return

Returns the timestamp of the last activity for this device.

In practice, this means the timestamp of the last event that was received from the OS for this device. (GTK may occasionally produce events for a device that are not received from the OS, and will not update the timestamp).

self

Passed: a <GdkDevice>.

a <GdkDevice>

%return

Returned: an unsigned 32-bit integer.

the timestamp of the last activity for this device

Method: device:get-vendor-id self ⇒ %return
Method: get-vendor-id self ⇒ %return

Returns the vendor ID of this device.

This ID is retrieved from the device, and does not change.

This function, together with device:get-product-id, can be used to eg. compose <GSettings> paths to store settings for this device.

 static GSettings *
 get_device_settings (GdkDevice *device)
 {
   const char *vendor, *product;
   GSettings *settings;
   GdkDevice *device;
   char *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;
 }
self

Passed: a <GdkDevice>.

a physical <GdkDevice>

%return

Returned: a string, or #f.

the vendor ID

Method: device:has-bidi-layouts? self ⇒ %return
Method: has-bidi-layouts? self ⇒ %return

Determines if layouts for both right-to-left and left-to-right languages are in use on the keyboard.

This is only relevant for keyboard devices.

self

Passed: a <GdkDevice>.

a <GdkDevice>

%return

Returned: a boolean.

#t if there are layouts with both directions, #f otherwise

Signals

Signal: device:changed

Connect a handler with (connect object device:changed handler). It is called as (handler self).

Emitted either when the number of either axes or keys changes.

On X11 this will normally happen when the physical device routing events through the logical device changes (for example, user switches from the USB mouse to a tablet); in that case the logical device will change to reflect the axes and keys on the new physical device.

self

Passed: a <GdkDevice>.

Signal: device:tool-changed

Connect a handler with (connect object device:tool-changed handler). It is called as (handler self tool).

Emitted on pen/eraser devices whenever tools enter or leave proximity.

self

Passed: a <GdkDevice>.

tool

Passed: a <GdkDeviceTool>.

The new current tool