1 | /* GDK - The GIMP Drawing Kit |
2 | * Copyright (C) 2009 Carlos Garnacho <[email protected]> |
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 | |
29 | G_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 | |
35 | typedef 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 | * @GDK_SOURCE_TABLET_PAD: the device is a "pad", a collection of buttons, |
53 | * rings and strips found in drawing tablets. This device type has been |
54 | * added in 3.22. |
55 | * |
56 | * An enumeration describing the type of an input device in general terms. |
57 | */ |
58 | typedef enum |
59 | { |
60 | GDK_SOURCE_MOUSE, |
61 | GDK_SOURCE_PEN, |
62 | GDK_SOURCE_ERASER, |
63 | GDK_SOURCE_CURSOR, |
64 | GDK_SOURCE_KEYBOARD, |
65 | GDK_SOURCE_TOUCHSCREEN, |
66 | GDK_SOURCE_TOUCHPAD, |
67 | GDK_SOURCE_TRACKPOINT, |
68 | GDK_SOURCE_TABLET_PAD |
69 | } GdkInputSource; |
70 | |
71 | /** |
72 | * GdkInputMode: |
73 | * @GDK_MODE_DISABLED: the device is disabled and will not report any events. |
74 | * @GDK_MODE_SCREEN: the device is enabled. The device’s coordinate space |
75 | * maps to the entire screen. |
76 | * @GDK_MODE_WINDOW: the device is enabled. The device’s coordinate space |
77 | * is mapped to a single window. The manner in which this window |
78 | * is chosen is undefined, but it will typically be the same |
79 | * way in which the focus window for key events is determined. |
80 | * |
81 | * An enumeration that describes the mode of an input device. |
82 | */ |
83 | typedef enum |
84 | { |
85 | GDK_MODE_DISABLED, |
86 | GDK_MODE_SCREEN, |
87 | GDK_MODE_WINDOW |
88 | } GdkInputMode; |
89 | |
90 | /** |
91 | * GdkDeviceType: |
92 | * @GDK_DEVICE_TYPE_MASTER: Device is a master (or virtual) device. There will |
93 | * be an associated focus indicator on the screen. |
94 | * @GDK_DEVICE_TYPE_SLAVE: Device is a slave (or physical) device. |
95 | * @GDK_DEVICE_TYPE_FLOATING: Device is a physical device, currently not attached to |
96 | * any virtual device. |
97 | * |
98 | * Indicates the device type. See [above][GdkDeviceManager.description] |
99 | * for more information about the meaning of these device types. |
100 | */ |
101 | typedef enum { |
102 | GDK_DEVICE_TYPE_MASTER, |
103 | GDK_DEVICE_TYPE_SLAVE, |
104 | GDK_DEVICE_TYPE_FLOATING |
105 | } GdkDeviceType; |
106 | |
107 | /* We don't allocate each coordinate this big, but we use it to |
108 | * be ANSI compliant and avoid accessing past the defined limits. |
109 | */ |
110 | #define GDK_MAX_TIMECOORD_AXES 128 |
111 | |
112 | /** |
113 | * GdkTimeCoord: |
114 | * @time: The timestamp for this event. |
115 | * @axes: the values of the device’s axes. |
116 | * |
117 | * A #GdkTimeCoord stores a single event in a motion history. |
118 | */ |
119 | struct _GdkTimeCoord |
120 | { |
121 | guint32 time; |
122 | gdouble axes[GDK_MAX_TIMECOORD_AXES]; |
123 | }; |
124 | |
125 | GDK_AVAILABLE_IN_ALL |
126 | GType gdk_device_get_type (void) G_GNUC_CONST; |
127 | |
128 | GDK_AVAILABLE_IN_ALL |
129 | const gchar * gdk_device_get_name (GdkDevice *device); |
130 | GDK_AVAILABLE_IN_ALL |
131 | gboolean gdk_device_get_has_cursor (GdkDevice *device); |
132 | |
133 | /* Functions to configure a device */ |
134 | GDK_AVAILABLE_IN_ALL |
135 | GdkInputSource gdk_device_get_source (GdkDevice *device); |
136 | |
137 | GDK_AVAILABLE_IN_ALL |
138 | GdkInputMode gdk_device_get_mode (GdkDevice *device); |
139 | GDK_AVAILABLE_IN_ALL |
140 | gboolean gdk_device_set_mode (GdkDevice *device, |
141 | GdkInputMode mode); |
142 | |
143 | GDK_AVAILABLE_IN_ALL |
144 | gint gdk_device_get_n_keys (GdkDevice *device); |
145 | GDK_AVAILABLE_IN_ALL |
146 | gboolean gdk_device_get_key (GdkDevice *device, |
147 | guint index_, |
148 | guint *keyval, |
149 | GdkModifierType *modifiers); |
150 | GDK_AVAILABLE_IN_ALL |
151 | void gdk_device_set_key (GdkDevice *device, |
152 | guint index_, |
153 | guint keyval, |
154 | GdkModifierType modifiers); |
155 | |
156 | GDK_AVAILABLE_IN_ALL |
157 | GdkAxisUse gdk_device_get_axis_use (GdkDevice *device, |
158 | guint index_); |
159 | GDK_AVAILABLE_IN_ALL |
160 | void gdk_device_set_axis_use (GdkDevice *device, |
161 | guint index_, |
162 | GdkAxisUse use); |
163 | |
164 | |
165 | GDK_AVAILABLE_IN_ALL |
166 | void gdk_device_get_state (GdkDevice *device, |
167 | GdkWindow *window, |
168 | gdouble *axes, |
169 | GdkModifierType *mask); |
170 | GDK_AVAILABLE_IN_ALL |
171 | void gdk_device_get_position (GdkDevice *device, |
172 | GdkScreen **screen, |
173 | gint *x, |
174 | gint *y); |
175 | GDK_AVAILABLE_IN_ALL |
176 | GdkWindow * |
177 | gdk_device_get_window_at_position |
178 | (GdkDevice *device, |
179 | gint *win_x, |
180 | gint *win_y); |
181 | GDK_AVAILABLE_IN_3_10 |
182 | void gdk_device_get_position_double (GdkDevice *device, |
183 | GdkScreen **screen, |
184 | gdouble *x, |
185 | gdouble *y); |
186 | GDK_AVAILABLE_IN_3_10 |
187 | GdkWindow * |
188 | gdk_device_get_window_at_position_double |
189 | (GdkDevice *device, |
190 | gdouble *win_x, |
191 | gdouble *win_y); |
192 | GDK_AVAILABLE_IN_ALL |
193 | gboolean gdk_device_get_history (GdkDevice *device, |
194 | GdkWindow *window, |
195 | guint32 start, |
196 | guint32 stop, |
197 | GdkTimeCoord ***events, |
198 | gint *n_events); |
199 | GDK_AVAILABLE_IN_ALL |
200 | void gdk_device_free_history (GdkTimeCoord **events, |
201 | gint n_events); |
202 | |
203 | GDK_AVAILABLE_IN_ALL |
204 | gint gdk_device_get_n_axes (GdkDevice *device); |
205 | GDK_AVAILABLE_IN_ALL |
206 | GList * gdk_device_list_axes (GdkDevice *device); |
207 | GDK_AVAILABLE_IN_ALL |
208 | gboolean gdk_device_get_axis_value (GdkDevice *device, |
209 | gdouble *axes, |
210 | GdkAtom axis_label, |
211 | gdouble *value); |
212 | |
213 | GDK_AVAILABLE_IN_ALL |
214 | gboolean gdk_device_get_axis (GdkDevice *device, |
215 | gdouble *axes, |
216 | GdkAxisUse use, |
217 | gdouble *value); |
218 | GDK_AVAILABLE_IN_ALL |
219 | GdkDisplay * gdk_device_get_display (GdkDevice *device); |
220 | |
221 | GDK_AVAILABLE_IN_ALL |
222 | GdkDevice * gdk_device_get_associated_device (GdkDevice *device); |
223 | GDK_AVAILABLE_IN_ALL |
224 | GList * gdk_device_list_slave_devices (GdkDevice *device); |
225 | |
226 | GDK_AVAILABLE_IN_ALL |
227 | GdkDeviceType gdk_device_get_device_type (GdkDevice *device); |
228 | |
229 | GDK_DEPRECATED_IN_3_20_FOR(gdk_seat_grab) |
230 | GdkGrabStatus gdk_device_grab (GdkDevice *device, |
231 | GdkWindow *window, |
232 | GdkGrabOwnership grab_ownership, |
233 | gboolean owner_events, |
234 | GdkEventMask event_mask, |
235 | GdkCursor *cursor, |
236 | guint32 time_); |
237 | |
238 | GDK_DEPRECATED_IN_3_20_FOR(gdk_seat_ungrab) |
239 | void gdk_device_ungrab (GdkDevice *device, |
240 | guint32 time_); |
241 | |
242 | GDK_AVAILABLE_IN_ALL |
243 | void gdk_device_warp (GdkDevice *device, |
244 | GdkScreen *screen, |
245 | gint x, |
246 | gint y); |
247 | |
248 | GDK_DEPRECATED_IN_3_16 |
249 | gboolean gdk_device_grab_info_libgtk_only (GdkDisplay *display, |
250 | GdkDevice *device, |
251 | GdkWindow **grab_window, |
252 | gboolean *owner_events); |
253 | |
254 | GDK_AVAILABLE_IN_3_12 |
255 | GdkWindow *gdk_device_get_last_event_window (GdkDevice *device); |
256 | |
257 | GDK_AVAILABLE_IN_3_16 |
258 | const gchar *gdk_device_get_vendor_id (GdkDevice *device); |
259 | GDK_AVAILABLE_IN_3_16 |
260 | const gchar *gdk_device_get_product_id (GdkDevice *device); |
261 | |
262 | GDK_AVAILABLE_IN_3_20 |
263 | GdkSeat *gdk_device_get_seat (GdkDevice *device); |
264 | |
265 | GDK_AVAILABLE_IN_3_22 |
266 | GdkAxisFlags gdk_device_get_axes (GdkDevice *device); |
267 | |
268 | G_END_DECLS |
269 | |
270 | #endif /* __GDK_DEVICE_H__ */ |
271 | |