Gdk.Device

g GObject.Object GObject.Object Gdk.Device Gdk.Device GObject.Object->Gdk.Device

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

get_caps_lock_state ()

get_device_tool ()

get_direction ()

get_display ()

get_has_cursor ()

get_modifier_state ()

get_name ()

get_num_lock_state ()

get_num_touches ()

get_product_id ()

get_scroll_lock_state ()

get_seat ()

get_source ()

get_surface_at_position ()

get_timestamp ()

get_vendor_id ()

has_bidi_layouts ()

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

caps-lock-state

bool

r

direction

Pango.Direction

r

display

Gdk.Display

r/w/co

has-bidi-layouts

bool

r

has-cursor

bool

r/w/co

modifier-state

Gdk.ModifierType

r

n-axes

int

r

name

str

r/w/co

num-lock-state

bool

r

num-touches

int

r/w/co

product-id

str

r/w/co

scroll-lock-state

bool

r

seat

Gdk.Seat

r/w

source

Gdk.InputSource

r/w/co/en

tool

Gdk.DeviceTool

r

vendor-id

str

r/w/co

Signals

Inherited:

GObject.Object (1)

Name

Short Description

changed

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

tool-changed

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

Fields

Inherited:

GObject.Object (1)

Class Details

class Gdk.Device(**kwargs)
Bases:

GObject.Object

Abstract:

Yes

The GdkDevice object represents an input device, such as a keyboard, a mouse, or a touchpad.

See the [class`Gdk`.Seat] documentation for more information about the various kinds of devices, and their relationships.

get_caps_lock_state()[source]
Returns:

True if Caps Lock is on for self

Return type:

bool

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

This is only relevant for keyboard devices.

get_device_tool()[source]
Returns:

the GdkDeviceTool

Return type:

Gdk.DeviceTool or None

Retrieves the current tool for self.

get_direction()[source]
Returns:

Pango.Direction.LTR or Pango.Direction.RTL if it can determine the direction. Pango.Direction.NEUTRAL otherwise

Return type:

Pango.Direction

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 [func`Pango`.unichar_direction].

get_display()[source]
Returns:

a GdkDisplay

Return type:

Gdk.Display

Returns the GdkDisplay to which self pertains.

get_has_cursor()[source]
Returns:

True if the pointer follows device motion

Return type:

bool

Determines whether the pointer follows device motion.

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

get_modifier_state()[source]
Returns:

the current modifier state

Return type:

Gdk.ModifierType

Retrieves the current modifier state of the keyboard.

This is only relevant for keyboard devices.

get_name()[source]
Returns:

a name

Return type:

str

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

get_num_lock_state()[source]
Returns:

True if Num Lock is on for self

Return type:

bool

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

This is only relevant for keyboard devices.

get_num_touches()[source]
Returns:

the number of touch points

Return type:

int

Retrieves the number of touch points associated to self.

get_product_id()[source]
Returns:

the product ID

Return type:

str or None

Returns the product ID of this device.

This ID is retrieved from the device, and does not change. See [method`Gdk`.Device.get_vendor_id] for more information.

get_scroll_lock_state()[source]
Returns:

True if Scroll Lock is on for self

Return type:

bool

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

This is only relevant for keyboard devices.

get_seat()[source]
Returns:

a GdkSeat

Return type:

Gdk.Seat

Returns the GdkSeat the device belongs to.

get_source()[source]
Returns:

a GdkInputSource

Return type:

Gdk.InputSource

Determines the type of the device.

get_surface_at_position()[source]
Returns:

the GdkSurface under the device position

win_x:

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

win_y:

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

Return type:

(Gdk.Surface or None, win_x: float, win_y: float)

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

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

get_timestamp()[source]
Returns:

the timestamp of the last activity for this device

Return type:

int

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

New in version 4.2.

get_vendor_id()[source]
Returns:

the vendor ID

Return type:

str or None

Returns the vendor ID of this device.

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

This function, together with [method`Gdk`.Device.get_product_id], can be used to eg. compose GSettings paths to store settings for this device.

```c static Gio.Settings * get_device_settings (Gdk.Device *device) { const str *vendor, *product; Gio.Settings *settings; Gdk.Device *device; str *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 = Gio.Settings.new_with_path (DEVICE_SCHEMA, path); GLib.free (path);

return settings; } ```

has_bidi_layouts()[source]
Returns:

True if there are layouts with both directions, False otherwise

Return type:

bool

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.

Signal Details

Gdk.Device.signals.changed(device)
Signal Name:

changed

Flags:

RUN_LAST

Parameters:

device (Gdk.Device) – The object which received the signal

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.

Gdk.Device.signals.tool_changed(device, tool)
Signal Name:

tool-changed

Flags:

RUN_LAST

Parameters:

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

Property Details

Gdk.Device.props.caps_lock_state
Name:

caps-lock-state

Type:

bool

Default Value:

False

Flags:

READABLE

Whether Caps Lock is on.

This is only relevant for keyboard devices.

Gdk.Device.props.direction
Name:

direction

Type:

Pango.Direction

Default Value:

Pango.Direction.NEUTRAL

Flags:

READABLE

The direction of the current layout.

This is only relevant for keyboard devices.

Gdk.Device.props.display
Name:

display

Type:

Gdk.Display

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The GdkDisplay the GdkDevice pertains to.

Gdk.Device.props.has_bidi_layouts
Name:

has-bidi-layouts

Type:

bool

Default Value:

False

Flags:

READABLE

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

This is only relevant for keyboard devices.

Gdk.Device.props.has_cursor
Name:

has-cursor

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

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

Gdk.Device.props.modifier_state
Name:

modifier-state

Type:

Gdk.ModifierType

Default Value:

0

Flags:

READABLE

The current modifier state of the device.

This is only relevant for keyboard devices.

Gdk.Device.props.n_axes
Name:

n-axes

Type:

int

Default Value:

0

Flags:

READABLE

Number of axes in the device.

Gdk.Device.props.name
Name:

name

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The device name.

Gdk.Device.props.num_lock_state
Name:

num-lock-state

Type:

bool

Default Value:

False

Flags:

READABLE

Whether Num Lock is on.

This is only relevant for keyboard devices.

Gdk.Device.props.num_touches
Name:

num-touches

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE, CONSTRUCT_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.

Gdk.Device.props.product_id
Name:

product-id

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

Product ID of this device.

See [method`Gdk`.Device.get_product_id].

Gdk.Device.props.scroll_lock_state
Name:

scroll-lock-state

Type:

bool

Default Value:

False

Flags:

READABLE

Whether Scroll Lock is on.

This is only relevant for keyboard devices.

Gdk.Device.props.seat
Name:

seat

Type:

Gdk.Seat

Default Value:

None

Flags:

READABLE, WRITABLE

GdkSeat of this device.

Gdk.Device.props.source
Name:

source

Type:

Gdk.InputSource

Default Value:

Gdk.InputSource.MOUSE

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY, EXPLICIT_NOTIFY

Source type for the device.

Gdk.Device.props.tool
Name:

tool

Type:

Gdk.DeviceTool

Default Value:

None

Flags:

READABLE

The GdkDeviceTool that is currently used with this device.

Gdk.Device.props.vendor_id
Name:

vendor-id

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

Vendor ID of this device.

See [method`Gdk`.Device.get_vendor_id].