Functions
gdk_device_get_name ()
const gchar *
gdk_device_get_name (GdkDevice *device);
Determines the name of the device.
Since: 2.20
gdk_device_get_vendor_id ()
const gchar *
gdk_device_get_vendor_id (GdkDevice *device);
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 paths to store settings for this device.
Returns
the vendor ID, or NULL.
[nullable]
Since: 3.16
gdk_device_get_product_id ()
const gchar *
gdk_device_get_product_id (GdkDevice *device);
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.
Returns
the product ID, or NULL.
[nullable]
Since: 3.16
gdk_device_get_source ()
GdkInputSource
gdk_device_get_source (GdkDevice *device);
Determines the type of the device.
Since: 2.20
gdk_device_set_mode ()
gboolean
gdk_device_set_mode (GdkDevice *device,
GdkInputMode mode);
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.
Returns
TRUE if the mode was successfully changed.
gdk_device_get_mode ()
GdkInputMode
gdk_device_get_mode (GdkDevice *device);
Determines the mode of the device.
Since: 2.20
gdk_device_set_key ()
void
gdk_device_set_key (GdkDevice *device,
guint index_,
guint keyval,
GdkModifierType modifiers);
Specifies the X key event to generate when a macro button of a device
is pressed.
gdk_device_get_key ()
gboolean
gdk_device_get_key (GdkDevice *device,
guint index_,
guint *keyval,
GdkModifierType *modifiers);
If index_
has a valid keyval, this function will return TRUE
and fill in keyval
and modifiers
with the keyval settings.
Returns
TRUE if keyval is set for index
.
Since: 2.20
gdk_device_set_axis_use ()
void
gdk_device_set_axis_use (GdkDevice *device,
guint index_,
GdkAxisUse use);
Specifies how an axis of a device is used.
gdk_device_get_axis_use ()
GdkAxisUse
gdk_device_get_axis_use (GdkDevice *device,
guint index_);
Returns the axis use for index_
.
Returns
a GdkAxisUse specifying how the axis is used.
Since: 2.20
gdk_device_get_associated_device ()
GdkDevice *
gdk_device_get_associated_device (GdkDevice *device);
Returns the associated device to device
, if device
is of type
GDK_DEVICE_TYPE_MASTER, it will return the paired pointer or
keyboard.
If device
is of type GDK_DEVICE_TYPE_SLAVE, it will return
the master device to which device
is attached to.
If device
is of type GDK_DEVICE_TYPE_FLOATING, NULL will be
returned, as there is no associated device.
Returns
The associated device, or
NULL.
[nullable][transfer none]
Since: 3.0
gdk_device_list_slave_devices ()
GList *
gdk_device_list_slave_devices (GdkDevice *device);
If the device if of type GDK_DEVICE_TYPE_MASTER, it will return
the list of slave devices attached to it, otherwise it will return
NULL
Returns
the list of slave devices, or NULL. The list must be
freed with g_list_free(), the contents of the list are
owned by GTK+ and should not be freed.
[nullable][transfer container][element-type GdkDevice]
gdk_device_get_device_type ()
GdkDeviceType
gdk_device_get_device_type (GdkDevice *device);
Returns the device type for device
.
Since: 3.0
gdk_device_get_display ()
GdkDisplay *
gdk_device_get_display (GdkDevice *device);
Returns the GdkDisplay to which device
pertains.
Returns
a GdkDisplay. This memory is owned
by GTK+, and must not be freed or unreffed.
[transfer none]
Since: 3.0
gdk_device_get_has_cursor ()
gboolean
gdk_device_get_has_cursor (GdkDevice *device);
Determines whether the pointer follows device motion.
This is not meaningful for keyboard devices, which don't have a pointer.
Returns
TRUE if the pointer follows device motion
Since: 2.20
gdk_device_get_n_axes ()
gint
gdk_device_get_n_axes (GdkDevice *device);
Returns the number of axes the device currently has.
Returns
the number of axes.
Since: 3.0
gdk_device_get_n_keys ()
gint
gdk_device_get_n_keys (GdkDevice *device);
Returns the number of keys the device currently has.
Returns
the number of keys.
Since: 2.24
gdk_device_get_axes ()
GdkAxisFlags
gdk_device_get_axes (GdkDevice *device);
Returns the axes currently available on the device.
Since: 3.22
gdk_device_warp ()
void
gdk_device_warp (GdkDevice *device,
GdkScreen *screen,
gint x,
gint y);
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 GtkColorSelectionDialog.
Since: 3.0
gdk_device_get_seat ()
GdkSeat *
gdk_device_get_seat (GdkDevice *device);
Returns the GdkSeat the device belongs to.
Returns
A GdkSeat. This memory is owned by GTK+ and
must not be freed.
[transfer none]
Since: 3.20
gdk_device_grab ()
GdkGrabStatus
gdk_device_grab (GdkDevice *device,
GdkWindow *window,
GdkGrabOwnership grab_ownership,
gboolean owner_events,
GdkEventMask event_mask,
GdkCursor *cursor,
guint32 time_);
gdk_device_grab has been deprecated since version 3.20. and should not be used in newly-written code.
Use gdk_seat_grab() instead.
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 GdkEventGrabBroken
events that are emitted when the grab ends unvoluntarily.
Since: 3.0
gdk_device_ungrab ()
void
gdk_device_ungrab (GdkDevice *device,
guint32 time_);
gdk_device_ungrab has been deprecated since version 3.20. and should not be used in newly-written code.
Use gdk_seat_ungrab() instead.
Release any grab on device
.
Since: 3.0
gdk_device_get_state ()
void
gdk_device_get_state (GdkDevice *device,
GdkWindow *window,
gdouble *axes,
GdkModifierType *mask);
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_TYPE_SLAVE,
unless there is an ongoing grab on them. See gdk_device_grab().
[skip]
gdk_device_get_position ()
void
gdk_device_get_position (GdkDevice *device,
GdkScreen **screen,
gint *x,
gint *y);
Gets the current location of device
. As a slave device
coordinates are those of its master pointer, This function
may not be called on devices of type GDK_DEVICE_TYPE_SLAVE,
unless there is an ongoing grab on them, see gdk_device_grab().
Since: 3.0
gdk_device_get_position_double ()
void
gdk_device_get_position_double (GdkDevice *device,
GdkScreen **screen,
gdouble *x,
gdouble *y);
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_TYPE_SLAVE,
unless there is an ongoing grab on them. See gdk_device_grab().
Since: 3.10
gdk_device_get_window_at_position ()
GdkWindow *
gdk_device_get_window_at_position (GdkDevice *device,
gint *win_x,
gint *win_y);
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_TYPE_SLAVE,
unless there is an ongoing grab on them, see gdk_device_grab().
Returns
the GdkWindow under the
device position, or NULL.
[nullable][transfer none]
Since: 3.0
gdk_device_get_window_at_position_double ()
GdkWindow *
gdk_device_get_window_at_position_double
(GdkDevice *device,
gdouble *win_x,
gdouble *win_y);
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_TYPE_SLAVE,
unless there is an ongoing grab on them, see gdk_device_grab().
Returns
the GdkWindow under the
device position, or NULL.
[nullable][transfer none]
Since: 3.0
gdk_device_get_history ()
gboolean
gdk_device_get_history (GdkDevice *device,
GdkWindow *window,
guint32 start,
guint32 stop,
GdkTimeCoord ***events,
gint *n_events);
Obtains the motion history for a pointer device; given a starting and
ending timestamp, return all events in the motion history for
the device in the given range of time. Some windowing systems
do not support motion history, in which case, FALSE will
be returned. (This is not distinguishable from the case where
motion history is supported and no events were found.)
Note that there is also gdk_window_set_event_compression() to get
more motion events delivered directly, independent of the windowing
system.
[skip]
Returns
TRUE if the windowing system supports motion history and
at least one event was found.
gdk_device_get_axis ()
gboolean
gdk_device_get_axis (GdkDevice *device,
gdouble *axes,
GdkAxisUse use,
gdouble *value);
Interprets an array of double as axis values for a given device,
and locates the value in the array for a given axis use.
[skip]
Returns
TRUE if the given axis use was found, otherwise FALSE
gdk_device_list_axes ()
GList *
gdk_device_list_axes (GdkDevice *device);
Returns a GList of GdkAtoms, containing the labels for
the axes that device
currently has.
Since: 3.0
gdk_device_get_axis_value ()
gboolean
gdk_device_get_axis_value (GdkDevice *device,
gdouble *axes,
GdkAtom axis_label,
gdouble *value);
Interprets an array of double as axis values for a given device,
and locates the value in the array for a given axis label, as returned
by gdk_device_list_axes()
[skip]
Returns
TRUE if the given axis use was found, otherwise FALSE.
Since: 3.0
gdk_device_get_last_event_window ()
GdkWindow *
gdk_device_get_last_event_window (GdkDevice *device);
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.
Returns
the last window the device.
[transfer none][allow-none]
Since: 3.12
gdk_device_tool_get_serial ()
guint64
gdk_device_tool_get_serial (GdkDeviceTool *tool);
Gets the serial of this tool, this value can be used to identify a
physical tool (eg. a tablet pen) across program executions.
Returns
The serial ID for this tool
Since: 3.22
gdk_device_tool_get_tool_type ()
GdkDeviceToolType
gdk_device_tool_get_tool_type (GdkDeviceTool *tool);
Gets the GdkDeviceToolType of the tool.
Returns
The physical type for this tool. This can be used to figure out what
sort of pen is being used, such as an airbrush or a pencil.
Since: 3.22
Property Details
The “associated-device” property
“associated-device” GdkDevice *
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.
Owner: GdkDevice
Flags: Read
Since: 3.0
The “axes” property
“axes” GdkAxisFlags
The axes currently available for this device.
Owner: GdkDevice
Flags: Read
Since: 3.22
The “has-cursor” property
“has-cursor” gboolean
Whether the device is represented by a cursor on the screen. Devices of type
GDK_DEVICE_TYPE_MASTER will have TRUE here.
Owner: GdkDevice
Flags: Read / Write / Construct Only
Default value: FALSE
Since: 3.0
The “input-mode” property
“input-mode” GdkInputMode
Input mode for the device.
Owner: GdkDevice
Flags: Read / Write
Default value: GDK_MODE_DISABLED
The “input-source” property
“input-source” GdkInputSource
Source type for the device.
Owner: GdkDevice
Flags: Read / Write / Construct Only
Default value: GDK_SOURCE_MOUSE
Since: 3.0
The “n-axes” property
“n-axes” guint
Number of axes in the device.
Owner: GdkDevice
Flags: Read
Default value: 0
Since: 3.0
The “name” property
“name” gchar *
The device name.
Owner: GdkDevice
Flags: Read / Write / Construct Only
Default value: NULL
Since: 3.0
The “num-touches” property
“num-touches” guint
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.
Owner: GdkDevice
Flags: Read / Write / Construct Only
Default value: 0
Since: 3.20
The “product-id” property
“product-id” gchar *
Product ID of this device, see gdk_device_get_product_id().
Owner: GdkDevice
Flags: Read / Write / Construct Only
Default value: NULL
Since: 3.16
The “seat” property
“seat” GdkSeat *
GdkSeat of this device.
Owner: GdkDevice
Flags: Read / Write
Since: 3.20
The “tool” property
“tool” GdkDeviceTool *
The tool that is currently used with this device.
Owner: GdkDevice
Flags: Read
The “type” property
“type” GdkDeviceType
Device role in the device manager.
Owner: GdkDevice
Flags: Read / Write / Construct Only
Default value: GDK_DEVICE_TYPE_MASTER
Since: 3.0
The “vendor-id” property
“vendor-id” gchar *
Vendor ID of this device, see gdk_device_get_vendor_id().
Owner: GdkDevice
Flags: Read / Write / Construct Only
Default value: NULL
Since: 3.16