1/* GDK - The GIMP Drawing Kit
2 * Copyright (C) 2009 Carlos Garnacho <carlosg@gnome.org>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef __GDK_DEVICE_H__
19#define __GDK_DEVICE_H__
20
21#if !defined (__GDK_H_INSIDE__) && !defined (GDK_COMPILATION)
22#error "Only <gdk/gdk.h> can be included directly."
23#endif
24
25#include <gdk/gdkversionmacros.h>
26#include <gdk/gdktypes.h>
27
28
29G_BEGIN_DECLS
30
31#define GDK_TYPE_DEVICE (gdk_device_get_type ())
32#define GDK_DEVICE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDK_TYPE_DEVICE, GdkDevice))
33#define GDK_IS_DEVICE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDK_TYPE_DEVICE))
34
35typedef struct _GdkTimeCoord GdkTimeCoord;
36
37/**
38 * GdkInputSource:
39 * @GDK_SOURCE_MOUSE: the device is a mouse. (This will be reported for the core
40 * pointer, even if it is something else, such as a trackball.)
41 * @GDK_SOURCE_PEN: the device is a stylus of a graphics tablet or similar device.
42 * @GDK_SOURCE_ERASER: the device is an eraser. Typically, this would be the other end
43 * of a stylus on a graphics tablet.
44 * @GDK_SOURCE_CURSOR: the device is a graphics tablet “puck” or similar device.
45 * @GDK_SOURCE_KEYBOARD: the device is a keyboard.
46 * @GDK_SOURCE_TOUCHSCREEN: the device is a direct-input touch device, such
47 * as a touchscreen or tablet. This device type has been added in 3.4.
48 * @GDK_SOURCE_TOUCHPAD: the device is an indirect touch device, such
49 * as a touchpad. This device type has been added in 3.4.
50 * @GDK_SOURCE_TRACKPOINT: the device is a trackpoint. This device type has been
51 * added in 3.22
52 *
53 * An enumeration describing the type of an input device in general terms.
54 */
55typedef enum
56{
57 GDK_SOURCE_MOUSE,
58 GDK_SOURCE_PEN,
59 GDK_SOURCE_ERASER,
60 GDK_SOURCE_CURSOR,
61 GDK_SOURCE_KEYBOARD,
62 GDK_SOURCE_TOUCHSCREEN,
63 GDK_SOURCE_TOUCHPAD,
64 GDK_SOURCE_TRACKPOINT
65} GdkInputSource;
66
67/**
68 * GdkInputMode:
69 * @GDK_MODE_DISABLED: the device is disabled and will not report any events.
70 * @GDK_MODE_SCREEN: the device is enabled. The device’s coordinate space
71 * maps to the entire screen.
72 * @GDK_MODE_WINDOW: the device is enabled. The device’s coordinate space
73 * is mapped to a single window. The manner in which this window
74 * is chosen is undefined, but it will typically be the same
75 * way in which the focus window for key events is determined.
76 *
77 * An enumeration that describes the mode of an input device.
78 */
79typedef enum
80{
81 GDK_MODE_DISABLED,
82 GDK_MODE_SCREEN,
83 GDK_MODE_WINDOW
84} GdkInputMode;
85
86/**
87 * GdkDeviceType:
88 * @GDK_DEVICE_TYPE_MASTER: Device is a master (or virtual) device. There will
89 * be an associated focus indicator on the screen.
90 * @GDK_DEVICE_TYPE_SLAVE: Device is a slave (or physical) device.
91 * @GDK_DEVICE_TYPE_FLOATING: Device is a physical device, currently not attached to
92 * any virtual device.
93 *
94 * Indicates the device type. See [above][GdkDeviceManager.description]
95 * for more information about the meaning of these device types.
96 */
97typedef enum {
98 GDK_DEVICE_TYPE_MASTER,
99 GDK_DEVICE_TYPE_SLAVE,
100 GDK_DEVICE_TYPE_FLOATING
101} GdkDeviceType;
102
103/* We don't allocate each coordinate this big, but we use it to
104 * be ANSI compliant and avoid accessing past the defined limits.
105 */
106#define GDK_MAX_TIMECOORD_AXES 128
107
108/**
109 * GdkTimeCoord:
110 * @time: The timestamp for this event.
111 * @axes: the values of the device’s axes.
112 *
113 * A #GdkTimeCoord stores a single event in a motion history.
114 */
115struct _GdkTimeCoord
116{
117 guint32 time;
118 gdouble axes[GDK_MAX_TIMECOORD_AXES];
119};
120
121GDK_AVAILABLE_IN_ALL
122GType gdk_device_get_type (void) G_GNUC_CONST;
123
124GDK_AVAILABLE_IN_ALL
125const gchar * gdk_device_get_name (GdkDevice *device);
126GDK_AVAILABLE_IN_ALL
127gboolean gdk_device_get_has_cursor (GdkDevice *device);
128
129/* Functions to configure a device */
130GDK_AVAILABLE_IN_ALL
131GdkInputSource gdk_device_get_source (GdkDevice *device);
132
133GDK_AVAILABLE_IN_ALL
134GdkInputMode gdk_device_get_mode (GdkDevice *device);
135GDK_AVAILABLE_IN_ALL
136gboolean gdk_device_set_mode (GdkDevice *device,
137 GdkInputMode mode);
138
139GDK_AVAILABLE_IN_ALL
140gint gdk_device_get_n_keys (GdkDevice *device);
141GDK_AVAILABLE_IN_ALL
142gboolean gdk_device_get_key (GdkDevice *device,
143 guint index_,
144 guint *keyval,
145 GdkModifierType *modifiers);
146GDK_AVAILABLE_IN_ALL
147void gdk_device_set_key (GdkDevice *device,
148 guint index_,
149 guint keyval,
150 GdkModifierType modifiers);
151
152GDK_AVAILABLE_IN_ALL
153GdkAxisUse gdk_device_get_axis_use (GdkDevice *device,
154 guint index_);
155GDK_AVAILABLE_IN_ALL
156void gdk_device_set_axis_use (GdkDevice *device,
157 guint index_,
158 GdkAxisUse use);
159
160
161GDK_AVAILABLE_IN_ALL
162void gdk_device_get_state (GdkDevice *device,
163 GdkWindow *window,
164 gdouble *axes,
165 GdkModifierType *mask);
166GDK_AVAILABLE_IN_ALL
167void gdk_device_get_position (GdkDevice *device,
168 GdkScreen **screen,
169 gint *x,
170 gint *y);
171GDK_AVAILABLE_IN_ALL
172GdkWindow *
173 gdk_device_get_window_at_position
174 (GdkDevice *device,
175 gint *win_x,
176 gint *win_y);
177GDK_AVAILABLE_IN_3_10
178void gdk_device_get_position_double (GdkDevice *device,
179 GdkScreen **screen,
180 gdouble *x,
181 gdouble *y);
182GDK_AVAILABLE_IN_3_10
183GdkWindow *
184 gdk_device_get_window_at_position_double
185 (GdkDevice *device,
186 gdouble *win_x,
187 gdouble *win_y);
188GDK_AVAILABLE_IN_ALL
189gboolean gdk_device_get_history (GdkDevice *device,
190 GdkWindow *window,
191 guint32 start,
192 guint32 stop,
193 GdkTimeCoord ***events,
194 gint *n_events);
195GDK_AVAILABLE_IN_ALL
196void gdk_device_free_history (GdkTimeCoord **events,
197 gint n_events);
198
199GDK_AVAILABLE_IN_ALL
200gint gdk_device_get_n_axes (GdkDevice *device);
201GDK_AVAILABLE_IN_ALL
202GList * gdk_device_list_axes (GdkDevice *device);
203GDK_AVAILABLE_IN_ALL
204gboolean gdk_device_get_axis_value (GdkDevice *device,
205 gdouble *axes,
206 GdkAtom axis_label,
207 gdouble *value);
208
209GDK_AVAILABLE_IN_ALL
210gboolean gdk_device_get_axis (GdkDevice *device,
211 gdouble *axes,
212 GdkAxisUse use,
213 gdouble *value);
214GDK_AVAILABLE_IN_ALL
215GdkDisplay * gdk_device_get_display (GdkDevice *device);
216
217GDK_AVAILABLE_IN_ALL
218GdkDevice * gdk_device_get_associated_device (GdkDevice *device);
219GDK_AVAILABLE_IN_ALL
220GList * gdk_device_list_slave_devices (GdkDevice *device);
221
222GDK_AVAILABLE_IN_ALL
223GdkDeviceType gdk_device_get_device_type (GdkDevice *device);
224
225GDK_DEPRECATED_IN_3_20_FOR(gdk_seat_grab)
226GdkGrabStatus gdk_device_grab (GdkDevice *device,
227 GdkWindow *window,
228 GdkGrabOwnership grab_ownership,
229 gboolean owner_events,
230 GdkEventMask event_mask,
231 GdkCursor *cursor,
232 guint32 time_);
233
234GDK_DEPRECATED_IN_3_20_FOR(gdk_seat_ungrab)
235void gdk_device_ungrab (GdkDevice *device,
236 guint32 time_);
237
238GDK_AVAILABLE_IN_ALL
239void gdk_device_warp (GdkDevice *device,
240 GdkScreen *screen,
241 gint x,
242 gint y);
243
244GDK_DEPRECATED_IN_3_16
245gboolean gdk_device_grab_info_libgtk_only (GdkDisplay *display,
246 GdkDevice *device,
247 GdkWindow **grab_window,
248 gboolean *owner_events);
249
250GDK_AVAILABLE_IN_3_12
251GdkWindow *gdk_device_get_last_event_window (GdkDevice *device);
252
253GDK_AVAILABLE_IN_3_16
254const gchar *gdk_device_get_vendor_id (GdkDevice *device);
255GDK_AVAILABLE_IN_3_16
256const gchar *gdk_device_get_product_id (GdkDevice *device);
257
258GDK_AVAILABLE_IN_3_20
259GdkSeat *gdk_device_get_seat (GdkDevice *device);
260
261GDK_AVAILABLE_IN_3_22
262GdkAxisFlags gdk_device_get_axes (GdkDevice *device);
263
264G_END_DECLS
265
266#endif /* __GDK_DEVICE_H__ */
267