Gdk.Device

Entities

Simple Types

Tagged Types

Access Types

Constants

Subprograms

Generic Instantiations

Description

The Gdk.Device.Gdk_Device object represents a single input device, such as a keyboard, a mouse, a touchpad, etc.

See the Gdk.Device_Manager.Gdk_Device_Manager documentation for more information about the various kinds of master and slave devices, and their relationships.

Associated_Device_Property

Associated_Device_Property : constant Glib.Properties.Property_Boxed;

Type: Device Associated pointer or keyboard with this device, if any. Devices of type GDK_DEVICE_TYPE_MASTER always come in keyboard/pointer pairs. Other device types will have a null associated device.

Axes_Property

Axes_Property : constant Glib.Properties.Property_Boxed;

Type: Axis_Flags The axes currently available for this device.

Cb_Gdk_Device_GObject_Void

type Cb_Gdk_Device_GObject_Void is not null access procedure
  (Self : access Gdk_Device_Record'Class;
   Tool : not null access Glib.Object.GObject_Record'Class);
Parameters
Self
Tool

Cb_GObject_GObject_Void

type Cb_GObject_GObject_Void is not null access procedure
  (Self : access Glib.Object.GObject_Record'Class;
   Tool : not null access Glib.Object.GObject_Record'Class);
Parameters
Self
Tool

Convert

function Convert (R : Gdk.Device.Gdk_Device) return System.Address
Parameters
R
Return Value

Convert

function Convert (R : System.Address) return Gdk.Device.Gdk_Device
Parameters
R
Return Value

Device_List

package Device_List is new Generic_List (Gdk.Device.Gdk_Device);

Device_Manager_Property

Device_Manager_Property : constant Glib.Properties.Property_Boxed;

Type: Device_Manager The Gdk.Device_Manager.Gdk_Device_Manager the Gdk.Device.Gdk_Device pertains to.

Display_Property

Display_Property : constant Glib.Properties.Property_Boxed;

Type: Display The Gdk.Display.Gdk_Display the Gdk.Device.Gdk_Device pertains to.

Gdk_Axis_Flag_Distance

Gdk_Axis_Flag_Distance : constant Gdk_Axis_Flags := 128;

Gdk_Axis_Flag_Pressure

Gdk_Axis_Flag_Pressure : constant Gdk_Axis_Flags := 8;

Gdk_Axis_Flag_Rotation

Gdk_Axis_Flag_Rotation : constant Gdk_Axis_Flags := 256;

Gdk_Axis_Flag_Slider

Gdk_Axis_Flag_Slider : constant Gdk_Axis_Flags := 512;

Gdk_Axis_Flag_Wheel

Gdk_Axis_Flag_Wheel : constant Gdk_Axis_Flags := 64;

Gdk_Axis_Flag_X

Gdk_Axis_Flag_X : constant Gdk_Axis_Flags := 2;

Gdk_Axis_Flag_Xtilt

Gdk_Axis_Flag_Xtilt : constant Gdk_Axis_Flags := 16;

Gdk_Axis_Flag_Y

Gdk_Axis_Flag_Y : constant Gdk_Axis_Flags := 4;

Gdk_Axis_Flag_Ytilt

Gdk_Axis_Flag_Ytilt : constant Gdk_Axis_Flags := 32;

Gdk_Axis_Flags

type Gdk_Axis_Flags is mod 2 ** Integer'Size;

Flags describing the current capabilities of a device/tool.

Gdk_Axis_Flags_Properties

package Gdk_Axis_Flags_Properties is
   new Generic_Internal_Discrete_Property (Gdk_Axis_Flags);

Gdk_Device

type Gdk_Device is access all Gdk_Device_Record'Class;

Gdk_Device_Record

type Gdk_Device_Record is new GObject_Record with null record;

Gdk_Device_Type

type Gdk_Device_Type is (
   Gdk_Device_Type_Master,
   Gdk_Device_Type_Slave,
   Gdk_Device_Type_Floating);

Indicates the device type. See [above][GdkDeviceManager.description] for more information about the meaning of these device types.

Enumeration Literal
Gdk_Device_Type_Master
Gdk_Device_Type_Slave
Gdk_Device_Type_Floating

Gdk_Device_Type_Properties

package Gdk_Device_Type_Properties is
   new Generic_Internal_Discrete_Property (Gdk_Device_Type);

Get_Associated_Device

function Get_Associated_Device
   (Self : not null access Gdk_Device_Record) return Gdk_Device

Returns the associated device to Device, if Device is of type Gdk.Device.Gdk_Device_Type_Master, it will return the paired pointer or keyboard. If Device is of type Gdk.Device.Gdk_Device_Type_Slave, it will return the master device to which Device is attached to. If Device is of type Gdk.Device.Gdk_Device_Type_Floating, null will be returned, as there is no associated device. Since: gtk+ 3.0

Parameters
Self
Return Value

The associated device, or null

Get_Axes

function Get_Axes
   (Self : not null access Gdk_Device_Record) return Gdk_Axis_Flags

Returns the axes currently available on the device. Since: gtk+ 3.22

Parameters
Self
Return Value

Get_Axis_Use

function Get_Axis_Use
   (Self  : not null access Gdk_Device_Record;
    Index : Guint) return Gdk_Axis_Use

Returns the axis use for Index_. Since: gtk+ 2.20

Parameters
Self
Index

the index of the axis.

Return Value

a Gdk_Axis_Use specifying how the axis is used.

Get_Device_Type

function Get_Device_Type
   (Self : not null access Gdk_Device_Record) return Gdk_Device_Type

Returns the device type for Device. Since: gtk+ 3.0

Parameters
Self
Return Value

the Gdk.Device.Gdk_Device_Type for Device.

Get_Display

function Get_Display
   (Self : not null access Gdk_Device_Record)
    return Gdk.Display.Gdk_Display

Returns the Gdk.Display.Gdk_Display to which Device pertains. Since: gtk+ 3.0

Parameters
Self
Return Value

a Gdk.Display.Gdk_Display. This memory is owned by GTK+, and must not be freed or unreffed.

Get_Has_Cursor

function Get_Has_Cursor
   (Self : not null access Gdk_Device_Record) return Boolean

Determines whether the pointer follows device motion. This is not meaningful for keyboard devices, which don't have a pointer. Since: gtk+ 2.20

Parameters
Self
Return Value

True if the pointer follows device motion

Get_Last_Event_Window

function Get_Last_Event_Window
   (Self : not null access Gdk_Device_Record) return Gdk.Gdk_Window

Gets information about which window the given pointer device is in, based on events that have been received so far from the display server. If another application has a pointer grab, or this application has a grab with owner_events = False, null may be returned even if the pointer is physically over one of this application's windows. Since: gtk+ 3.12

Parameters
Self
Return Value

the last window the device

Get_Mode

function Get_Mode
   (Self : not null access Gdk_Device_Record) return Gdk_Input_Mode

Determines the mode of the device. Since: gtk+ 2.20

Parameters
Self
Return Value

a Gdk_Input_Source

Get_N_Axes

function Get_N_Axes
   (Self : not null access Gdk_Device_Record) return Glib.Gint

Returns the number of axes the device currently has. Since: gtk+ 3.0

Parameters
Self
Return Value

the number of axes.

Get_N_Keys

function Get_N_Keys
   (Self : not null access Gdk_Device_Record) return Glib.Gint

Returns the number of keys the device currently has. Since: gtk+ 2.24

Parameters
Self
Return Value

the number of keys.

Get_Name

function Get_Name
   (Self : not null access Gdk_Device_Record) return UTF8_String

Determines the name of the device. Since: gtk+ 2.20

Parameters
Self
Return Value

a name

Get_Position_Double

procedure Get_Position_Double
   (Self   : not null access Gdk_Device_Record;
    Screen : out Gdk.Screen.Gdk_Screen;
    X      : out Gdouble;
    Y      : out Gdouble)

Gets the current location of Device in double precision. As a slave device's coordinates are those of its master pointer, this function may not be called on devices of type Gdk.Device.Gdk_Device_Type_Slave, unless there is an ongoing grab on them. See Gdk.Device.Grab. Since: gtk+ 3.10

Parameters
Self
Screen

location to store the Gdk.Screen.Gdk_Screen the Device is on, or null.

X

location to store root window X coordinate of Device, or null.

Y

location to store root window Y coordinate of Device, or null.

Get_Product_Id

function Get_Product_Id
   (Self : not null access Gdk_Device_Record) return UTF8_String

Returns the product ID of this device, or null if this information couldn't be obtained. This ID is retrieved from the device, and is thus constant for it. See Gdk.Device.Get_Vendor_Id for more information. Since: gtk+ 3.16

Parameters
Self
Return Value

the product ID, or null

Get_Seat

function Get_Seat
   (Self : not null access Gdk_Device_Record) return Glib.Object.GObject

Returns the Gdk.Seat.Gdk_Seat the device belongs to. Since: gtk+ 3.20

Parameters
Self
Return Value

Get_Source

function Get_Source
   (Self : not null access Gdk_Device_Record) return Gdk_Input_Source

Determines the type of the device. Since: gtk+ 2.20

Parameters
Self
Return Value

a Gdk_Input_Source

Get_State

procedure Get_State
   (Self   : not null access Gdk_Device_Record;
    Window : Gdk.Gdk_Window;
    Axes   : Gdouble_Array;
    Mask   : out Gdk.Types.Gdk_Modifier_Type)

Gets the current state of a pointer device relative to Window. As a slave device's coordinates are those of its master pointer, this function may not be called on devices of type Gdk.Device.Gdk_Device_Type_Slave, unless there is an ongoing grab on them. See Gdk.Device.Grab.

Parameters
Self
Window

a Gdk.Gdk_Window.

Axes

an array of doubles to store the values of the axes of Device in, or null.

Mask

location to store the modifiers, or null.

Get_Type

function Get_Type return Glib.GType
Return Value

Get_Vendor_Id

function Get_Vendor_Id
   (Self : not null access Gdk_Device_Record) return UTF8_String

Returns the vendor ID of this device, or null if this information couldn't be obtained. This ID is retrieved from the device, and is thus constant for it. This function, together with Gdk.Device.Get_Product_Id, can be used to eg. compose Gsettings.Gsettings paths to store settings for this device.

static GSettings *
get_device_settings (GdkDevice *device)
{
  const gchar *vendor, *product;
  GSettings *settings;
  GdkDevice *device;
  gchar *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;
}

Since: gtk+ 3.16

Parameters
Self
Return Value

the vendor ID, or null

Get_Window_At_Position

procedure Get_Window_At_Position
  (Self   : not null access Gdk_Device_Record;
   Win_X  : out Gint;
   Win_Y  : out Gint;
   Window : out Gdk.Gdk_Window)

Obtains the window underneath Device, returning the location of the device in Win_X and Win_Y. Returns null if the window tree under Device is not known to GDK (for example, belongs to another application). As a slave device coordinates are those of its master pointer, This function may not be called on devices of type Gdk.Device.Gdk_Device_Type_Slave, unless there is an ongoing grab on them, see Gdk.Device.Grab. Since: gtk+ 3.0 "win_x": return location for the X coordinate of the device location, relative to the window origin, or null. "win_y": return location for the Y coordinate of the device location, relative to the window origin, or null.

Parameters
Self
Win_X
Win_Y
Window

Get_Window_At_Position_Double

function Get_Window_At_Position_Double
   (Self  : not null access Gdk_Device_Record;
    Win_X : access Gdouble;
    Win_Y : access Gdouble) return Gdk.Gdk_Window

Obtains the window underneath Device, returning the location of the device in Win_X and Win_Y in double precision. Returns null if the window tree under Device is not known to GDK (for example, belongs to another application). As a slave device coordinates are those of its master pointer, This function may not be called on devices of type Gdk.Device.Gdk_Device_Type_Slave, unless there is an ongoing grab on them, see Gdk.Device.Grab. Since: gtk+ 3.0

Parameters
Self
Win_X

return location for the X coordinate of the device location, relative to the window origin, or null.

Win_Y

return location for the Y coordinate of the device location, relative to the window origin, or null.

Return Value

the Gdk.Gdk_Window under the device position, or null.

Grab

function Grab
   (Self           : not null access Gdk_Device_Record;
    Window         : Gdk.Gdk_Window;
    Grab_Ownership : Gdk_Grab_Ownership;
    Owner_Events   : Boolean;
    Event_Mask     : Gdk.Event.Gdk_Event_Mask;
    Cursor         : Gdk.Gdk_Cursor;
    Time           : Guint32) return Gdk_Grab_Status

Grabs the device so that all events coming from this device are passed to this application until the device is ungrabbed with Gdk.Device.Ungrab, or the window becomes unviewable. This overrides any previous grab on the device by this client. Note that Device and Window need to be on the same display. Device grabs are used for operations which need complete control over the given device events (either pointer or keyboard). For example in GTK+ this is used for Drag and Drop operations, popup menus and such. Note that if the event mask of an X window has selected both button press and button release events, then a button press event will cause an automatic pointer grab until the button is released. X does this automatically since most applications expect to receive button press and release events in pairs. It is equivalent to a pointer grab on the window with Owner_Events set to True. If you set up anything at the time you take the grab that needs to be cleaned up when the grab ends, you should handle the Gdk.Event.Gdk_Event_Grab_Broken events that are emitted when the grab ends unvoluntarily. Since: gtk+ 3.0 Deprecated since 3.20., 1

Parameters
Self
Window

the Gdk.Gdk_Window which will own the grab (the grab window)

Grab_Ownership

specifies the grab ownership.

Owner_Events

if False then all device events are reported with respect to Window and are only reported if selected by Event_Mask. If True then pointer events for this application are reported as normal, but pointer events outside this application are reported with respect to Window and only if selected by Event_Mask. In either mode, unreported events are discarded.

Event_Mask

specifies the event mask, which is used in accordance with Owner_Events.

Cursor

the cursor to display while the grab is active if the device is a pointer. If this is null then the normal cursors are used for Window and its descendants, and the cursor for Window is used elsewhere.

Time

the timestamp of the event which led to this pointer grab. This usually comes from the Gdk.Event.Gdk_Event struct, though GDK_CURRENT_TIME can be used if the time isn't known.

Return Value

GDK_GRAB_SUCCESS if the grab was successful.

Has_Cursor_Property

Has_Cursor_Property : constant Glib.Properties.Property_Boolean;

Whether the device is represented by a cursor on the screen. Devices of type Gdk.Device.Gdk_Device_Type_Master will have True here.

Input_Mode_Property

Input_Mode_Property : constant Glib.Properties.Property_Boxed;

Type: Input_Mode

Input_Source_Property

Input_Source_Property : constant Glib.Properties.Property_Boxed;

Type: Input_Source Source type for the device.

N_Axes_Property

N_Axes_Property : constant Glib.Properties.Property_Uint;

Number of axes in the device.

Name_Property

Name_Property : constant Glib.Properties.Property_String;

The device name.

Num_Touches_Property

Num_Touches_Property : constant Glib.Properties.Property_Uint;

The maximal number of concurrent touches on a touch device. Will be 0 if the device is not a touch device or if the number of touches is unknown.

On_Tool_Changed

procedure On_Tool_Changed
   (Self  : not null access Gdk_Device_Record;
    Call  : Cb_Gdk_Device_GObject_Void;
    After : Boolean := False)

The ::tool-changed signal is emitted on pen/eraser Gdk_Devices whenever tools enter or leave proximity.

Parameters
Self
Call
After

On_Tool_Changed

procedure On_Tool_Changed
   (Self  : not null access Gdk_Device_Record;
    Call  : Cb_GObject_GObject_Void;
    Slot  : not null access Glib.Object.GObject_Record'Class;
    After : Boolean := False)

The ::tool-changed signal is emitted on pen/eraser Gdk_Devices whenever tools enter or leave proximity.

Parameters
Self
Call
Slot
After

Product_Id_Property

Product_Id_Property : constant Glib.Properties.Property_String;

Product ID of this device, see Gdk.Device.Get_Product_Id.

Property_Gdk_Axis_Flags

type Property_Gdk_Axis_Flags is new Gdk_Axis_Flags_Properties.Property;

Property_Gdk_Device_Type

type Property_Gdk_Device_Type is new Gdk_Device_Type_Properties.Property;

Seat_Property

Seat_Property : constant Glib.Properties.Property_Boxed;

Type: Seat Gdk.Seat.Gdk_Seat of this device.

Set_Axis_Use

procedure Set_Axis_Use
   (Self  : not null access Gdk_Device_Record;
    Index : Guint;
    GUse  : Gdk_Axis_Use)

Specifies how an axis of a device is used.

Parameters
Self
Index

the index of the axis

GUse

specifies how the axis is used

Set_Device

procedure Set_Device
  (Event   : Gdk.Event.Gdk_Event;
   Device  : not null access Gdk_Device_Record)

Sets the device for Event to Device. The event must have been allocated by GTK+, for instance, by gdk_event_copy().

Parameters
Event
Device

Set_Key

procedure Set_Key
   (Self      : not null access Gdk_Device_Record;
    Index     : Guint;
    Keyval    : Guint;
    Modifiers : Gdk.Types.Gdk_Modifier_Type)

Specifies the X key event to generate when a macro button of a device is pressed.

Parameters
Self
Index

the index of the macro button to set

Keyval

the keyval to generate

Modifiers

the modifiers to set

Set_Mode

function Set_Mode
   (Self : not null access Gdk_Device_Record;
    Mode : Gdk_Input_Mode) return Boolean

Sets a the mode of an input device. The mode controls if the device is active and whether the device's range is mapped to the entire screen or to a single window. Note: This is only meaningful for floating devices, master devices (and slaves connected to these) drive the pointer cursor, which is not limited by the input mode.

Parameters
Self
Mode

the input mode.

Return Value

True if the mode was successfully changed.

Set_Source_Device

procedure Set_Source_Device
  (Event   : Gdk.Event.Gdk_Event;
   Device  : not null access Gdk_Device_Record)

Sets the slave device for Event to Device. The event must have been allocated by GTK+, for instance by gdk_event_copy().

Parameters
Event
Device

Signal_Changed

Signal_Changed : constant Glib.Signal_Name := "changed";

The ::changed signal is emitted either when the Gdk.Device.Gdk_Device has changed the number of either axes or keys. For example In X this will normally happen when the slave device routing events through the master device changes (for example, user switches from the USB mouse to a tablet), in that case the master device will change to reflect the new slave device axes and keys. procedure Handler (Self : access Gdk_Device_Record'Class)

Signal_Tool_Changed

Signal_Tool_Changed : constant Glib.Signal_Name := "tool-changed";

The ::tool-changed signal is emitted on pen/eraser Gdk_Devices whenever tools enter or leave proximity.

The_Type_Property

The_Type_Property : constant Glib.Properties.Property_Boxed;

Type: Device_Type Device role in the device manager.

Tool_Property

Tool_Property : constant Glib.Properties.Property_Boxed;

Type: Device_Tool

Ungrab

procedure Ungrab
   (Self : not null access Gdk_Device_Record;
    Time : Guint32)

Release any grab on Device. Since: gtk+ 3.0 Deprecated since 3.20., 1

Parameters
Self
Time

a timestap (e.g. GDK_CURRENT_TIME).

Vendor_Id_Property

Vendor_Id_Property : constant Glib.Properties.Property_String;

Vendor ID of this device, see Gdk.Device.Get_Vendor_Id.

Warp

procedure Warp
   (Self   : not null access Gdk_Device_Record;
    Screen : not null access Gdk.Screen.Gdk_Screen_Record'Class;
    X      : Glib.Gint;
    Y      : Glib.Gint)

Warps Device in Display to the point X,Y on the screen Screen, unless the device is confined to a window by a grab, in which case it will be moved as far as allowed by the grab. Warping the pointer creates events as if the user had moved the mouse instantaneously to the destination. Note that the pointer should normally be under the control of the user. This function was added to cover some rare use cases like keyboard navigation support for the color picker in the Gtk.Color_Selection_Dialog.Gtk_Color_Selection_Dialog. Since: gtk+ 3.0

Parameters
Self
Screen

the screen to warp Device to.

X

the X coordinate of the destination.

Y

the Y coordinate of the destination.