class Gdk::Device

Overview

The Gdk::Device 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:

lib/gi-crystal/src/auto/gdk-4.0/device.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from class GObject::Object

==(other : self) ==, 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) | Nil data, finalize finalize, freeze_notify : Nil freeze_notify, getv(names : Enumerable(String), values : Enumerable(_)) : Nil getv, hash(hasher) hash, 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) | Nil qdata, ref_count : UInt32 ref_count, run_dispose : Nil run_dispose, set_data(key : String, data : Pointer(Void) | Nil) : Nil set_data, set_property(property_name : String, value : _) : Nil set_property, steal_data(key : String) : Pointer(Void) | Nil steal_data, steal_qdata(quark : UInt32) : Pointer(Void) | Nil 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, new(pointer : Pointer(Void), transfer : GICrystal::Transfer)
new
new
, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv

Class methods inherited from class GObject::Object

cast?(obj : GObject::Object) : self | Nil cast?, compat_control(what : UInt64, data : Pointer(Void) | Nil) : 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

Macros inherited from class GObject::Object

previous_vfunc(*args) previous_vfunc, previous_vfunc!(*args) previous_vfunc!, signal(signature) signal

Constructor Detail

def self.new #

Initialize a new Device.


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

[View source]

Class Method Detail

def self.g_type : UInt64 #

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


[View source]

Instance Method Detail

def ==(other : self) #
Description copied from class Reference

Returns true if this reference is the same as other. Invokes same?.


def caps_lock_state : Bool #

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

This is only relevant for keyboard devices.


[View source]
def caps_lock_state? : Bool #

[View source]
def changed_signal #

[View source]
def device_tool : Gdk::DeviceTool | Nil #

Retrieves the current tool for device.


[View source]
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.


[View source]
def display : Gdk::Display #

Returns the Gdk::Display to which device pertains.


[View source]
def display=(value : Gdk::Display | Nil) : Gdk::Display | Nil #

[View source]
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.


[View source]
def has_bidi_layouts? : Bool #

[View source]
def has_cursor : Bool #

Determines whether the pointer follows device motion.

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


[View source]
def has_cursor=(value : Bool) : Bool #

[View source]
def has_cursor? : Bool #

[View source]
def hash(hasher) #
Description copied from class Reference

See Object#hash(hasher)


def modifier_state : Gdk::ModifierType #

Retrieves the current modifier state of the keyboard.

This is only relevant for keyboard devices.


[View source]
def n_axes : UInt32 #

[View source]
def name : String #

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


[View source]
def name=(value : String) : String #

[View source]
def num_lock_state : Bool #

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

This is only relevant for keyboard devices.


[View source]
def num_lock_state? : Bool #

[View source]
def num_touches : UInt32 #

Retrieves the number of touch points associated to device.


[View source]
def num_touches=(value : UInt32) : UInt32 #

[View source]
def product_id : String | Nil #

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.


[View source]
def product_id=(value : String) : String #

[View source]
def scroll_lock_state : Bool #

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

This is only relevant for keyboard devices.


[View source]
def scroll_lock_state? : Bool #

[View source]
def seat : Gdk::Seat #

Returns the Gdk::Seat the device belongs to.


[View source]
def seat=(value : Gdk::Seat | Nil) : Gdk::Seat | Nil #

[View source]
def source : Gdk::InputSource #

Determines the type of the device.


[View source]
def source=(value : Gdk::InputSource) : Gdk::InputSource #

[View source]
def surface_at_position : Gdk::Surface | Nil #

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

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


[View source]
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).


[View source]
def tool : Gdk::DeviceTool | Nil #

[View source]
def tool_changed_signal #

[View source]
def vendor_id : String | Nil #

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 (Gdk::Device *device)
 {
   const char *vendor, *product;
   GSettings *settings;
   Gdk::Device *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;
 }

[View source]
def vendor_id=(value : String) : String #

[View source]