![]() |
![]() |
![]() |
GDK 3 Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy | Properties | Signals |
#include <gdk/gdk.h> GdkDevice; enum GdkInputSource; enum GdkInputMode; enum GdkAxisUse; enum GdkDeviceType; enum GdkGrabOwnership; const gchar * gdk_device_get_name (GdkDevice *device
); GdkInputSource gdk_device_get_source (GdkDevice *device
); gboolean gdk_device_set_mode (GdkDevice *device
,GdkInputMode mode
); GdkInputMode gdk_device_get_mode (GdkDevice *device
); void gdk_device_set_key (GdkDevice *device
,guint index_
,guint keyval
,GdkModifierType modifiers
); gboolean gdk_device_get_key (GdkDevice *device
,guint index_
,guint *keyval
,GdkModifierType *modifiers
); void gdk_device_set_axis_use (GdkDevice *device
,guint index_
,GdkAxisUse use
); GdkAxisUse gdk_device_get_axis_use (GdkDevice *device
,guint index_
); GdkDevice * gdk_device_get_associated_device (GdkDevice *device
); GList * gdk_device_list_slave_devices (GdkDevice *device
); GdkDeviceType gdk_device_get_device_type (GdkDevice *device
); GdkDisplay * gdk_device_get_display (GdkDevice *device
); gboolean gdk_device_get_has_cursor (GdkDevice *device
); gint gdk_device_get_n_axes (GdkDevice *device
); gint gdk_device_get_n_keys (GdkDevice *device
); void gdk_device_warp (GdkDevice *device
,GdkScreen *screen
,gint x
,gint y
); GdkGrabStatus gdk_device_grab (GdkDevice *device
,GdkWindow *window
,GdkGrabOwnership grab_ownership
,gboolean owner_events
,GdkEventMask event_mask
,GdkCursor *cursor
,guint32 time_
); void gdk_device_ungrab (GdkDevice *device
,guint32 time_
); void gdk_device_get_state (GdkDevice *device
,GdkWindow *window
,gdouble *axes
,GdkModifierType *mask
); void gdk_device_get_position (GdkDevice *device
,GdkScreen **screen
,gint *x
,gint *y
); GdkWindow * gdk_device_get_window_at_position (GdkDevice *device
,gint *win_x
,gint *win_y
); gboolean gdk_device_get_history (GdkDevice *device
,GdkWindow *window
,guint32 start
,guint32 stop
,GdkTimeCoord ***events
,gint *n_events
); void gdk_device_free_history (GdkTimeCoord **events
,gint n_events
); struct GdkTimeCoord; gboolean gdk_device_get_axis (GdkDevice *device
,gdouble *axes
,GdkAxisUse use
,gdouble *value
); GList * gdk_device_list_axes (GdkDevice *device
); gboolean gdk_device_get_axis_value (GdkDevice *device
,gdouble *axes
,GdkAtom axis_label
,gdouble *value
);
"associated-device" GdkDevice* : Read "device-manager" GdkDeviceManager* : Read / Write / Construct Only "display" GdkDisplay* : Read / Write / Construct Only "has-cursor" gboolean : Read / Write / Construct Only "input-mode" GdkInputMode : Read / Write "input-source" GdkInputSource : Read / Write / Construct Only "n-axes" guint : Read "name" gchar* : Read / Write / Construct Only "type" GdkDeviceType : Read / Write / Construct Only
The GdkDevice object represents a single input device, such as a keyboard, a mouse, a touchpad, etc.
See the GdkDeviceManager documentation for more information about the various kinds of master and slave devices, and their relationships.
typedef enum { GDK_SOURCE_MOUSE, GDK_SOURCE_PEN, GDK_SOURCE_ERASER, GDK_SOURCE_CURSOR, GDK_SOURCE_KEYBOARD, GDK_SOURCE_TOUCHSCREEN, GDK_SOURCE_TOUCHPAD } GdkInputSource;
An enumeration describing the type of an input device in general terms.
the device is a mouse. (This will be reported for the core pointer, even if it is something else, such as a trackball.) | |
the device is a stylus of a graphics tablet or similar device. | |
the device is an eraser. Typically, this would be the other end of a stylus on a graphics tablet. | |
the device is a graphics tablet "puck" or similar device. | |
the device is a keyboard. | |
the device is a direct-input touch device, such as a touchscreen or tablet. This device type has been added in 3.4. | |
the device is an indirect touch device, such as a touchpad. This device type has been added in 3.4. |
typedef enum { GDK_MODE_DISABLED, GDK_MODE_SCREEN, GDK_MODE_WINDOW } GdkInputMode;
An enumeration that describes the mode of an input device.
the device is disabled and will not report any events. | |
the device is enabled. The device's coordinate space maps to the entire screen. | |
the device is enabled. The device's coordinate space is mapped to a single window. The manner in which this window is chosen is undefined, but it will typically be the same way in which the focus window for key events is determined. |
typedef enum { GDK_AXIS_IGNORE, GDK_AXIS_X, GDK_AXIS_Y, GDK_AXIS_PRESSURE, GDK_AXIS_XTILT, GDK_AXIS_YTILT, GDK_AXIS_WHEEL, GDK_AXIS_LAST } GdkAxisUse;
An enumeration describing the way in which a device axis (valuator) maps onto the predefined valuator types that GTK+ understands.
the axis is ignored. | |
the axis is used as the x axis. | |
the axis is used as the y axis. | |
the axis is used for pressure information. | |
the axis is used for x tilt information. | |
the axis is used for y tilt information. | |
the axis is used for wheel information. | |
a constant equal to the numerically highest axis value. |
typedef enum { GDK_DEVICE_TYPE_MASTER, GDK_DEVICE_TYPE_SLAVE, GDK_DEVICE_TYPE_FLOATING } GdkDeviceType;
Indicates the device type. See above for more information about the meaning of these device types.
typedef enum { GDK_OWNERSHIP_NONE, GDK_OWNERSHIP_WINDOW, GDK_OWNERSHIP_APPLICATION } GdkGrabOwnership;
Defines how device grabs interact with other devices.
const gchar * gdk_device_get_name (GdkDevice *device
);
Determines the name of the device.
|
a GdkDevice |
Returns : |
a name |
Since 2.20
GdkInputSource gdk_device_get_source (GdkDevice *device
);
Determines the type of the device.
|
a GdkDevice |
Returns : |
a GdkInputSource |
Since 2.20
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.
GdkInputMode gdk_device_get_mode (GdkDevice *device
);
Determines the mode of the device.
|
a GdkDevice |
Returns : |
a GdkInputSource |
Since 2.20
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.
|
a GdkDevice |
|
the index of the macro button to set |
|
the keyval to generate |
|
the modifiers to set |
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.
|
a GdkDevice. |
|
the index of the macro button to get. |
|
return value for the keyval. [out] |
|
return value for modifiers. [out] |
Returns : |
TRUE if keyval is set for index . |
Since 2.20
void gdk_device_set_axis_use (GdkDevice *device
,guint index_
,GdkAxisUse use
);
Specifies how an axis of a device is used.
|
a pointer GdkDevice |
|
the index of the axis |
|
specifies how the axis is used |
GdkAxisUse gdk_device_get_axis_use (GdkDevice *device
,guint index_
);
Returns the axis use for index_
.
|
a pointer GdkDevice. |
|
the index of the axis. |
Returns : |
a GdkAxisUse specifying how the axis is used. |
Since 2.20
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.
Since 3.0
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
|
a GdkDevice |
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. [transfer container][element-type GdkDevice]
|
GdkDeviceType gdk_device_get_device_type (GdkDevice *device
);
Returns the device type for device
.
|
a GdkDevice |
Returns : |
the GdkDeviceType for device . |
Since 3.0
GdkDisplay * gdk_device_get_display (GdkDevice *device
);
Returns the GdkDisplay to which device
pertains.
|
a GdkDevice |
Returns : |
a GdkDisplay. This memory is owned by GTK+, and must not be freed or unreffed. [transfer none] |
Since 3.0
gboolean gdk_device_get_has_cursor (GdkDevice *device
);
Determines whether the pointer follows device motion.
Since 2.20
gint gdk_device_get_n_axes (GdkDevice *device
);
Returns the number of axes the device currently has.
|
a pointer GdkDevice |
Returns : |
the number of axes. |
Since 3.0
gint gdk_device_get_n_keys (GdkDevice *device
);
Returns the number of keys the device currently has.
|
a GdkDevice |
Returns : |
the number of keys. |
Since 2.24
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.
|
the device to warp. |
|
the screen to warp device to. |
|
the X coordinate of the destination. |
|
the Y coordinate of the destination. |
Since 3.0
GdkGrabStatus gdk_device_grab (GdkDevice *device
,GdkWindow *window
,GdkGrabOwnership grab_ownership
,gboolean owner_events
,GdkEventMask event_mask
,GdkCursor *cursor
,guint32 time_
);
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.
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.
|
a GdkDevice. To get the device you can use gtk_get_current_event_device()
or gdk_event_get_device() if the grab is in reaction to an event. Also, you can use
gdk_device_manager_get_client_pointer() but only in code that isn't triggered by a
GdkEvent and there aren't other means to get a meaningful GdkDevice to operate on. |
|
the GdkWindow which will own the grab (the grab window) |
|
specifies the grab ownership. |
|
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. |
|
specifies the event mask, which is used in accordance with
owner_events . |
|
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. [allow-none]
|
|
the timestamp of the event which led to this pointer grab. This
usually comes from the GdkEvent struct, though GDK_CURRENT_TIME
can be used if the time isn't known. |
Returns : |
GDK_GRAB_SUCCESS if the grab was successful. |
Since 3.0
void gdk_device_ungrab (GdkDevice *device
,guint32 time_
);
Release any grab on device
.
|
a GdkDevice |
|
a timestap (e.g. GDK_CURRENT_TIME ). |
Since 3.0
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 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()
.
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()
.
|
pointer device to query status about. |
|
location to store the GdkScreen
the device is on, or NULL . [out][transfer none][allow-none]
|
|
location to store root window X coordinate of device , or NULL . [out][allow-none]
|
|
location to store root window Y coordinate of device , or NULL . [out][allow-none]
|
Since 3.0
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()
.
|
pointer GdkDevice to query info to. |
|
return location for the X coordinate of the device location,
relative to the window origin, or NULL . [out][allow-none]
|
|
return location for the Y coordinate of the device location,
relative to the window origin, or NULL . [out][allow-none]
|
Returns : |
the GdkWindow under the device position, or NULL . [transfer none]
|
Since 3.0
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.)
|
a GdkDevice |
|
the window with respect to which which the event coordinates will be reported |
|
starting timestamp for range of events to return |
|
ending timestamp for the range of events to return |
|
location to store a newly-allocated array of GdkTimeCoord, or NULL . [array length=n_events][out][transfer full]
|
|
location to store the length of events , or NULL
|
Returns : |
TRUE if the windowing system supports motion history and
at least one event was found. |
void gdk_device_free_history (GdkTimeCoord **events
,gint n_events
);
Frees an array of GdkTimeCoord that was returned by gdk_device_get_history()
.
|
an array of GdkTimeCoord. |
|
the length of the array. |
struct GdkTimeCoord { guint32 time; gdouble axes[GDK_MAX_TIMECOORD_AXES]; };
The GdkTimeCoord structure stores a single event in a motion history.
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.
GList * gdk_device_list_axes (GdkDevice *device
);
Returns a GList of GdkAtoms, containing the labels for
the axes that device
currently has.
|
a pointer GdkDevice |
Returns : |
A GList of GdkAtoms, free with g_list_free() . [transfer container][element-type GdkAtom]
|
Since 3.0
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()
|
a pointer GdkDevice. |
|
pointer to an array of axes. [array] |
|
GdkAtom with the axis label. |
|
location to store the found value. |
Returns : |
TRUE if the given axis use was found, otherwise FALSE . |
Since 3.0
"associated-device"
property"associated-device" GdkDevice* : Read
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.
Since 3.0
"device-manager"
property"device-manager" GdkDeviceManager* : Read / Write / Construct Only
The GdkDeviceManager the GdkDevice pertains to.
Since 3.0
"display"
property"display" GdkDisplay* : Read / Write / Construct Only
The GdkDisplay the GdkDevice pertains to.
Since 3.0
"has-cursor"
property"has-cursor" gboolean : Read / Write / Construct Only
Whether the device is represented by a cursor on the screen. Devices of type
GDK_DEVICE_TYPE_MASTER
will have TRUE
here.
Default value: FALSE
Since 3.0
"input-mode"
property"input-mode" GdkInputMode : Read / Write
Input mode for the device.
Default value: GDK_MODE_DISABLED
Since 3.0
"input-source"
property"input-source" GdkInputSource : Read / Write / Construct Only
Source type for the device.
Default value: GDK_SOURCE_MOUSE
Since 3.0
"n-axes"
property"n-axes" guint : Read
Number of axes in the device.
Default value: 0
Since 3.0
"name"
property"name" gchar* : Read / Write / Construct Only
The device name.
Default value: NULL
Since 3.0
"type"
property"type" GdkDeviceType : Read / Write / Construct Only
Device role in the device manager.
Default value: GDK_DEVICE_TYPE_MASTER
Since 3.0
"changed"
signalvoid user_function (GdkDevice *device,
gpointer user_data) : Run Last
The ::changed signal is emitted either when the GdkDevice 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.
|
the GdkDevice that changed. |
|
user data set when the signal handler was connected. |