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