Device#
Superclasses: Object
The GdkDevice object represents an input device, such
as a keyboard, a mouse, or a touchpad.
See the Seat documentation for more information
about the various kinds of devices, and their relationships.
Methods#
- class Device
- get_caps_lock_state() bool#
Retrieves whether the Caps Lock modifier of the keyboard is locked.
This is only relevant for keyboard devices.
- get_device_tool() DeviceTool | None#
Retrieves the current tool for
device.
- get_direction() 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
unichar_direction.
- get_has_cursor() bool#
Determines whether the pointer follows device motion.
This is not meaningful for keyboard devices, which don’t have a pointer.
- get_modifier_state() ModifierType#
Retrieves the current modifier state of the keyboard.
This is only relevant for keyboard devices.
- get_num_lock_state() bool#
Retrieves whether the Num Lock modifier of the keyboard is locked.
This is only relevant for keyboard devices.
- get_product_id() str | None#
Returns the product ID of this device.
This ID is retrieved from the device, and does not change. See
get_vendor_idfor more information.
- get_scroll_lock_state() bool#
Retrieves whether the Scroll Lock modifier of the keyboard is locked.
This is only relevant for keyboard devices.
- get_source() InputSource#
Determines the type of the device.
- get_surface_at_position() tuple[Surface | None, float, float]#
Obtains the surface underneath
device, returning the location of the device inwin_xandwin_y.Returns
Noneif the surface tree underdeviceis not known to GDK (for example, belongs to another application).
- get_timestamp() 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).
Added in version 4.2.
- get_vendor_id() str | None#
Returns the vendor ID of this device.
This ID is retrieved from the device, and does not change.
This function, together with
get_product_id, can be used to eg. composeGSettingspaths 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; }
Properties#
- class Device
-
- props.modifier_state: ModifierType#
The type of the None singleton.
- props.source: InputSource#
The type of the None singleton.
- props.tool: DeviceTool#
The type of the None singleton.
Signals#
- class Device.signals
-
- tool_changed(tool: DeviceTool) None#
The type of the None singleton.
- Parameters:
tool – The new current tool