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