:right-sidebar: True Device =================================================================== .. currentmodule:: gi.repository.Gdk .. class:: Device(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` The ``GdkDevice`` object represents an input device, such as a keyboard, a mouse, or a touchpad. See the :obj:`~gi.repository.Gdk.Seat` documentation for more information about the various kinds of devices, and their relationships. Methods ------- .. rst-class:: interim-class .. class:: Device :no-index: .. method:: get_caps_lock_state() -> bool Retrieves whether the Caps Lock modifier of the keyboard is locked. This is only relevant for keyboard devices. .. method:: get_device_tool() -> ~gi.repository.Gdk.DeviceTool | None Retrieves the current tool for ``device``\. .. method:: get_direction() -> ~gi.repository.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 :obj:`~gi.repository.Pango.unichar_direction`\. .. method:: get_display() -> ~gi.repository.Gdk.Display Returns the ``GdkDisplay`` to which ``device`` pertains. .. method:: get_has_cursor() -> bool Determines whether the pointer follows device motion. This is not meaningful for keyboard devices, which don't have a pointer. .. method:: get_modifier_state() -> ~gi.repository.Gdk.ModifierType Retrieves the current modifier state of the keyboard. This is only relevant for keyboard devices. .. method:: get_name() -> str The name of the device, suitable for showing in a user interface. .. method:: get_num_lock_state() -> bool Retrieves whether the Num Lock modifier of the keyboard is locked. This is only relevant for keyboard devices. .. method:: get_num_touches() -> int Retrieves the number of touch points associated to ``device``\. .. method:: get_product_id() -> str | None Returns the product ID of this device. This ID is retrieved from the device, and does not change. See :obj:`~gi.repository.Gdk.Device.get_vendor_id` for more information. .. method:: get_scroll_lock_state() -> bool Retrieves whether the Scroll Lock modifier of the keyboard is locked. This is only relevant for keyboard devices. .. method:: get_seat() -> ~gi.repository.Gdk.Seat Returns the ``GdkSeat`` the device belongs to. .. method:: get_source() -> ~gi.repository.Gdk.InputSource Determines the type of the device. .. method:: get_surface_at_position() -> ~typing.Tuple[~gi.repository.Gdk.Surface | None, float, float] Obtains the surface underneath ``device``\, returning the location of the device in ``win_x`` and ``win_y``\. Returns :const:`None` if the surface tree under ``device`` is not known to GDK (for example, belongs to another application). .. method:: 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). .. versionadded:: 4.2 .. method:: 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 :obj:`~gi.repository.Gdk.Device.get_product_id`\, can be used to eg. compose ``GSettings`` paths to store settings for this device. .. code-block:: c :dedent: 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; } .. method:: has_bidi_layouts() -> 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. Properties ---------- .. rst-class:: interim-class .. class:: Device :no-index: .. attribute:: props.caps_lock_state :type: bool The type of the None singleton. .. attribute:: props.direction :type: ~gi.repository.Pango.Direction The type of the None singleton. .. attribute:: props.display :type: ~gi.repository.Gdk.Display The type of the None singleton. .. attribute:: props.has_bidi_layouts :type: bool The type of the None singleton. .. attribute:: props.has_cursor :type: bool The type of the None singleton. .. attribute:: props.modifier_state :type: ~gi.repository.Gdk.ModifierType The type of the None singleton. .. attribute:: props.n_axes :type: int The type of the None singleton. .. attribute:: props.name :type: str The type of the None singleton. .. attribute:: props.num_lock_state :type: bool The type of the None singleton. .. attribute:: props.num_touches :type: int The type of the None singleton. .. attribute:: props.product_id :type: str The type of the None singleton. .. attribute:: props.scroll_lock_state :type: bool The type of the None singleton. .. attribute:: props.seat :type: ~gi.repository.Gdk.Seat The type of the None singleton. .. attribute:: props.source :type: ~gi.repository.Gdk.InputSource The type of the None singleton. .. attribute:: props.tool :type: ~gi.repository.Gdk.DeviceTool The type of the None singleton. .. attribute:: props.vendor_id :type: str The type of the None singleton. Signals ------- .. rst-class:: interim-class .. class:: Device.signals :no-index: .. method:: changed() -> None The type of the None singleton. .. method:: tool_changed(tool: ~gi.repository.Gdk.DeviceTool) -> None The type of the None singleton. :param tool: The new current tool