]> Pileus Git - ~andy/gtk/blob - gdk/gdkdevice.h
gdk: Add device types for touch-capable devices
[~andy/gtk] / gdk / gdkdevice.h
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 #if !defined (__GDK_H_INSIDE__) && !defined (GDK_COMPILATION)
19 #error "Only <gdk/gdk.h> can be included directly."
20 #endif
21
22 #ifndef __GDK_DEVICE_H__
23 #define __GDK_DEVICE_H__
24
25 #include <gdk/gdktypes.h>
26
27
28 G_BEGIN_DECLS
29
30 #define GDK_TYPE_DEVICE         (gdk_device_get_type ())
31 #define GDK_DEVICE(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GDK_TYPE_DEVICE, GdkDevice))
32 #define GDK_IS_DEVICE(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDK_TYPE_DEVICE))
33
34 typedef struct _GdkTimeCoord GdkTimeCoord;
35
36 /**
37  * GdkExtensionMode:
38  * @GDK_EXTENSION_EVENTS_NONE: no extension events are desired.
39  * @GDK_EXTENSION_EVENTS_ALL: all extension events are desired.
40  * @GDK_EXTENSION_EVENTS_CURSOR: extension events are desired only if a cursor
41  *                               will be displayed for the device.
42  *
43  * An enumeration used to specify which extension events
44  * are desired for a particular widget.
45  */
46 typedef enum
47 {
48   GDK_EXTENSION_EVENTS_NONE,
49   GDK_EXTENSION_EVENTS_ALL,
50   GDK_EXTENSION_EVENTS_CURSOR
51 } GdkExtensionMode;
52
53 /**
54  * GdkInputSource:
55  * @GDK_SOURCE_MOUSE: the device is a mouse. (This will be reported for the core
56  *                    pointer, even if it is something else, such as a trackball.)
57  * @GDK_SOURCE_PEN: the device is a stylus of a graphics tablet or similar device.
58  * @GDK_SOURCE_ERASER: the device is an eraser. Typically, this would be the other end
59  *                     of a stylus on a graphics tablet.
60  * @GDK_SOURCE_CURSOR: the device is a graphics tablet "puck" or similar device.
61  * @GDK_SOURCE_KEYBOARD: the device is a keyboard.
62  * @GDK_SOURCE_TOUCHSCREEN: the device is a direct-input touch device, such
63  *     as a touchscreen or tablet. This device type has been added in 3.4.
64  * @GDK_SOURCE_TOUCHPAD: the device is an indirect touch device, such
65  *     as a touchpad. This device type has been added in 3.4.
66  *
67  * An enumeration describing the type of an input device in general terms.
68  */
69 typedef enum
70 {
71   GDK_SOURCE_MOUSE,
72   GDK_SOURCE_PEN,
73   GDK_SOURCE_ERASER,
74   GDK_SOURCE_CURSOR,
75   GDK_SOURCE_KEYBOARD,
76   GDK_SOURCE_TOUCHSCREEN,
77   GDK_SOURCE_TOUCHPAD
78 } GdkInputSource;
79
80 /**
81  * GdkInputMode:
82  * @GDK_MODE_DISABLED: the device is disabled and will not report any events.
83  * @GDK_MODE_SCREEN: the device is enabled. The device's coordinate space
84  *                   maps to the entire screen.
85  * @GDK_MODE_WINDOW: the device is enabled. The device's coordinate space
86  *                   is mapped to a single window. The manner in which this window
87  *                   is chosen is undefined, but it will typically be the same
88  *                   way in which the focus window for key events is determined.
89  *
90  * An enumeration that describes the mode of an input device.
91  */
92 typedef enum
93 {
94   GDK_MODE_DISABLED,
95   GDK_MODE_SCREEN,
96   GDK_MODE_WINDOW
97 } GdkInputMode;
98
99 /**
100  * GdkAxisUse:
101  * @GDK_AXIS_IGNORE: the axis is ignored.
102  * @GDK_AXIS_X: the axis is used as the x axis.
103  * @GDK_AXIS_Y: the axis is used as the y axis.
104  * @GDK_AXIS_PRESSURE: the axis is used for pressure information.
105  * @GDK_AXIS_XTILT: the axis is used for x tilt information.
106  * @GDK_AXIS_YTILT: the axis is used for y tilt information.
107  * @GDK_AXIS_WHEEL: the axis is used for wheel information.
108  * @GDK_AXIS_LAST: a constant equal to the numerically highest axis value.
109  *
110  * An enumeration describing the way in which a device
111  * axis (valuator) maps onto the predefined valuator
112  * types that GTK+ understands.
113  */
114 typedef enum
115 {
116   GDK_AXIS_IGNORE,
117   GDK_AXIS_X,
118   GDK_AXIS_Y,
119   GDK_AXIS_PRESSURE,
120   GDK_AXIS_XTILT,
121   GDK_AXIS_YTILT,
122   GDK_AXIS_WHEEL,
123   GDK_AXIS_LAST
124 } GdkAxisUse;
125
126 /**
127  * GdkDeviceType:
128  * @GDK_DEVICE_TYPE_MASTER: Device is a master (or virtual) device. There will
129  *                          be an associated focus indicator on the screen.
130  * @GDK_DEVICE_TYPE_SLAVE: Device is a slave (or physical) device.
131  * @GDK_DEVICE_TYPE_FLOATING: Device is a physical device, currently not attached to
132  *                            any virtual device.
133  *
134  * Indicates the device type. See <link linkend="GdkDeviceManager.description">above</link>
135  * for more information about the meaning of these device types.
136  */
137 typedef enum {
138   GDK_DEVICE_TYPE_MASTER,
139   GDK_DEVICE_TYPE_SLAVE,
140   GDK_DEVICE_TYPE_FLOATING
141 } GdkDeviceType;
142
143 /* We don't allocate each coordinate this big, but we use it to
144  * be ANSI compliant and avoid accessing past the defined limits.
145  */
146 #define GDK_MAX_TIMECOORD_AXES 128
147
148 /**
149  * GdkTimeCoord:
150  * @time: The timestamp for this event.
151  * @axes: the values of the device's axes.
152  *
153  * The #GdkTimeCoord structure stores a single event in a motion history.
154  */
155 struct _GdkTimeCoord
156 {
157   guint32 time;
158   gdouble axes[GDK_MAX_TIMECOORD_AXES];
159 };
160
161 GType                 gdk_device_get_type       (void) G_GNUC_CONST;
162
163 const gchar *         gdk_device_get_name       (GdkDevice *device);
164 gboolean              gdk_device_get_has_cursor (GdkDevice *device);
165
166 /* Functions to configure a device */
167 GdkInputSource gdk_device_get_source    (GdkDevice      *device);
168
169 GdkInputMode   gdk_device_get_mode      (GdkDevice      *device);
170 gboolean       gdk_device_set_mode      (GdkDevice      *device,
171                                          GdkInputMode    mode);
172
173 gint           gdk_device_get_n_keys    (GdkDevice       *device);
174 gboolean       gdk_device_get_key       (GdkDevice       *device,
175                                          guint            index_,
176                                          guint           *keyval,
177                                          GdkModifierType *modifiers);
178 void           gdk_device_set_key       (GdkDevice      *device,
179                                          guint           index_,
180                                          guint           keyval,
181                                          GdkModifierType modifiers);
182
183 GdkAxisUse     gdk_device_get_axis_use  (GdkDevice         *device,
184                                          guint              index_);
185 void           gdk_device_set_axis_use  (GdkDevice         *device,
186                                          guint              index_,
187                                          GdkAxisUse         use);
188
189
190 void     gdk_device_get_state    (GdkDevice         *device,
191                                   GdkWindow         *window,
192                                   gdouble           *axes,
193                                   GdkModifierType   *mask);
194 void     gdk_device_get_position (GdkDevice         *device,
195                                   GdkScreen        **screen,
196                                   gint              *x,
197                                   gint              *y);
198 GdkWindow *
199          gdk_device_get_window_at_position
200                                  (GdkDevice         *device,
201                                   gint              *win_x,
202                                   gint              *win_y);
203 gboolean gdk_device_get_history  (GdkDevice         *device,
204                                   GdkWindow         *window,
205                                   guint32            start,
206                                   guint32            stop,
207                                   GdkTimeCoord    ***events,
208                                   gint              *n_events);
209 void     gdk_device_free_history (GdkTimeCoord     **events,
210                                   gint               n_events);
211
212 gint     gdk_device_get_n_axes     (GdkDevice       *device);
213 GList *  gdk_device_list_axes      (GdkDevice       *device);
214 gboolean gdk_device_get_axis_value (GdkDevice       *device,
215                                     gdouble         *axes,
216                                     GdkAtom          axis_label,
217                                     gdouble         *value);
218
219 gboolean gdk_device_get_axis     (GdkDevice         *device,
220                                   gdouble           *axes,
221                                   GdkAxisUse         use,
222                                   gdouble           *value);
223 GdkDisplay * gdk_device_get_display (GdkDevice      *device);
224
225 GdkDevice  * gdk_device_get_associated_device (GdkDevice     *device);
226 GList *      gdk_device_list_slave_devices    (GdkDevice     *device);
227
228 GdkDeviceType gdk_device_get_device_type (GdkDevice *device);
229
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 void          gdk_device_ungrab      (GdkDevice        *device,
239                                       guint32           time_);
240
241 void          gdk_device_warp        (GdkDevice        *device,
242                                       GdkScreen        *screen,
243                                       gint              x,
244                                       gint              y);
245
246 gboolean gdk_device_grab_info_libgtk_only (GdkDisplay  *display,
247                                            GdkDevice   *device,
248                                            GdkWindow  **grab_window,
249                                            gboolean    *owner_events);
250
251
252 G_END_DECLS
253
254 #endif /* __GDK_DEVICE_H__ */