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