class Gdk::Device

Overview

Represents an input device, such as a keyboard, mouse or 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.


def self.new(*, active_layout_index : Int32 | Nil = nil, 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, layout_names : Enumerable(String) | 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) #

Class Method Detail

def self.g_type : UInt64 #

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


Instance Method Detail

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

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


def active_layout_index : Int32 #

Retrieves the index of the active layout of the keyboard.

If there is no valid active layout for the Gdk::Device, this function will return -1;

This is only relevant for keyboard devices.


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 | Nil #

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 Gdk::Display to which device pertains.


def display=(value : Gdk::Display | Nil) : Gdk::Display | Nil #

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 hash(hasher) #
Description copied from class Reference

See Object#hash(hasher)


def layout_names : Enumerable(String) | Nil #

Retrieves the names of the layouts of the keyboard.

This is only relevant for keyboard devices.


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 name=(value : Nil) : Nil #

Set #name property to nil.


def name? : String | Nil #

Same as #name, but can return nil.


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


def product_id=(value : String) : String #

def product_id=(value : Nil) : Nil #

Set #product_id property to nil.


def product_id? : String | Nil #

Same as #product_id, but can return nil.


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 Gdk::Seat the device belongs to.


def seat=(value : Gdk::Seat | Nil) : Gdk::Seat | Nil #

def source : Gdk::InputSource #

Determines the type of the device.


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

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


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 | Nil #

def tool_changed_signal #

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

def vendor_id=(value : String) : String #

def vendor_id=(value : Nil) : Nil #

Set #vendor_id property to nil.


def vendor_id? : String | Nil #

Same as #vendor_id, but can return nil.