class Gdk::Device

Overview

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

See the Gdk#Seat documentation for more information about the various kinds of devices, and their relationships.

Defined in:

auto/gdk-4.0/device.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from class GObject::Object

bind_property(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags) : GObject::Binding bind_property, bind_property_full(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags, transform_to : GObject::Closure, transform_from : GObject::Closure) : GObject::Binding bind_property_full, data(key : String) : Pointer(Void)? data, finalize finalize, freeze_notify : Nil freeze_notify, getv(names : Enumerable(String), values : Enumerable(_)) : Nil getv, notify(property_name : String) : Nil notify, notify_by_pspec(pspec : GObject::ParamSpec) : Nil notify_by_pspec, notify_signal notify_signal, property(property_name : String, value : _) : Nil property, qdata(quark : UInt32) : Pointer(Void)? qdata, ref_count ref_count, run_dispose : Nil run_dispose, set_data(key : String, data : Pointer(Void)?) : Nil set_data, set_property(property_name : String, value : _) : Nil set_property, steal_data(key : String) : Pointer(Void)? steal_data, steal_qdata(quark : UInt32) : Pointer(Void)? steal_qdata, thaw_notify : Nil thaw_notify, to_unsafe : Pointer(Void) to_unsafe, watch_closure(closure : GObject::Closure) : Nil watch_closure

Constructor methods inherited from class GObject::Object

cast(obj : GObject::Object) : self cast, cast?(obj : GObject::Object) : self? cast?, new new, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv

Class methods inherited from class GObject::Object

compat_control(what : UInt64, data : Pointer(Void)?) : UInt64 compat_control, g_type : UInt64 g_type, interface_find_property(g_iface : GObject::TypeInterface, property_name : String) : GObject::ParamSpec interface_find_property, interface_list_properties(g_iface : GObject::TypeInterface) : Enumerable(GObject::ParamSpec) interface_list_properties

Constructor Detail

def self.new #

Initialize a new Device.


def self.new(*, caps_lock_state : Bool? = nil, direction : Pango::Direction? = nil, display : Gdk::Display? = nil, has_bidi_layouts : Bool? = nil, has_cursor : Bool? = nil, modifier_state : Gdk::ModifierType? = nil, n_axes : UInt32? = nil, name : String? = nil, num_lock_state : Bool? = nil, num_touches : UInt32? = nil, product_id : String? = nil, scroll_lock_state : Bool? = nil, seat : Gdk::Seat? = nil, source : Gdk::InputSource? = nil, tool : Gdk::DeviceTool? = nil, vendor_id : String? = nil) #

Class Method Detail

def self.g_type : UInt64 #

Returns the type id (GType) registered in GLib type system.


Instance Method Detail

def caps_lock_state : Bool #

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

This is only relevant for keyboard devices.


def caps_lock_state? : Bool #

def changed_signal #

def device_tool : Gdk::DeviceTool? #

Retrieves the current tool for @device.


def direction : 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 Pango#unichar_direction.


def display : Gdk::Display #

Returns the GdkDisplay to which @device pertains.


def display=(value : Gdk::Display?) : Gdk::Display? #

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


def has_bidi_layouts? : Bool #

def has_cursor : Bool #

Determines whether the pointer follows device motion.

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


def has_cursor=(value : Bool) : Bool #

def has_cursor? : Bool #

def modifier_state : Gdk::ModifierType #

Retrieves the current modifier state of the keyboard.

This is only relevant for keyboard devices.


def n_axes : UInt32 #

def name : String #

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


def name=(value : String) : String #

def num_lock_state : Bool #

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

This is only relevant for keyboard devices.


def num_lock_state? : Bool #

def num_touches : UInt32 #

Retrieves the number of touch points associated to @device.


def num_touches=(value : UInt32) : UInt32 #

def product_id : String? #

Returns the product ID of this device.

This ID is retrieved from the device, and does not change. See Gdk::Device#vendor_id for more information.


def product_id=(value : String) : String #

def scroll_lock_state : Bool #

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

This is only relevant for keyboard devices.


def scroll_lock_state? : Bool #

def seat : Gdk::Seat #

Returns the GdkSeat the device belongs to.


def seat=(value : Gdk::Seat?) : Gdk::Seat? #

def source : Gdk::InputSource #

Determines the type of the device.


def source=(value : Gdk::InputSource) : Gdk::InputSource #

def surface_at_position : Gdk::Surface? #

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

Returns %NULL if the surface tree under @device is not known to GDK (for example, belongs to another application).


def timestamp : UInt32 #

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


def tool : Gdk::DeviceTool? #

def tool_changed_signal #

def vendor_id : String? #

Returns the vendor ID of this device.

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

This function, together with Gdk::Device#product_id, can be used to eg. compose GSettings paths to store settings for this device.

WARNING ⚠️ The following code is in c ⚠️

 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;
 }

def vendor_id=(value : String) : String #