gdkdevice.h 9.96 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/* GDK - The GIMP Drawing Kit
 * Copyright (C) 2009 Carlos Garnacho <carlosg@gnome.org>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
Javier Jardón's avatar
Javier Jardón committed
15
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16
17
 */

18
19
20
#ifndef __GDK_DEVICE_H__
#define __GDK_DEVICE_H__

21
#if !defined (__GDK_H_INSIDE__) && !defined (GDK_COMPILATION)
22
23
24
#error "Only <gdk/gdk.h> can be included directly."
#endif

25
#include <gdk/gdkversionmacros.h>
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <gdk/gdktypes.h>


G_BEGIN_DECLS

#define GDK_TYPE_DEVICE         (gdk_device_get_type ())
#define GDK_DEVICE(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GDK_TYPE_DEVICE, GdkDevice))
#define GDK_IS_DEVICE(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDK_TYPE_DEVICE))

typedef struct _GdkTimeCoord GdkTimeCoord;

/**
 * GdkInputSource:
 * @GDK_SOURCE_MOUSE: the device is a mouse. (This will be reported for the core
 *                    pointer, even if it is something else, such as a trackball.)
 * @GDK_SOURCE_PEN: the device is a stylus of a graphics tablet or similar device.
 * @GDK_SOURCE_ERASER: the device is an eraser. Typically, this would be the other end
 *                     of a stylus on a graphics tablet.
William Jon McCann's avatar
William Jon McCann committed
44
 * @GDK_SOURCE_CURSOR: the device is a graphics tablet “puck” or similar device.
45
 * @GDK_SOURCE_KEYBOARD: the device is a keyboard.
46
47
48
49
 * @GDK_SOURCE_TOUCHSCREEN: the device is a direct-input touch device, such
 *     as a touchscreen or tablet. This device type has been added in 3.4.
 * @GDK_SOURCE_TOUCHPAD: the device is an indirect touch device, such
 *     as a touchpad. This device type has been added in 3.4.
50
51
 * @GDK_SOURCE_TRACKPOINT: the device is a trackpoint. This device type has been
 *     added in 3.22
52
53
54
 * @GDK_SOURCE_TABLET_PAD: the device is a "pad", a collection of buttons,
 *     rings and strips found in drawing tablets. This device type has been
 *     added in 3.22.
55
56
57
58
59
60
61
62
63
 *
 * An enumeration describing the type of an input device in general terms.
 */
typedef enum
{
  GDK_SOURCE_MOUSE,
  GDK_SOURCE_PEN,
  GDK_SOURCE_ERASER,
  GDK_SOURCE_CURSOR,
64
65
  GDK_SOURCE_KEYBOARD,
  GDK_SOURCE_TOUCHSCREEN,
66
  GDK_SOURCE_TOUCHPAD,
67
68
  GDK_SOURCE_TRACKPOINT,
  GDK_SOURCE_TABLET_PAD
69
70
71
72
73
} GdkInputSource;

/**
 * GdkInputMode:
 * @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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
 *                   is mapped to a single window. The manner in which this window
 *                   is chosen is undefined, but it will typically be the same
 *                   way in which the focus window for key events is determined.
 *
 * An enumeration that describes the mode of an input device.
 */
typedef enum
{
  GDK_MODE_DISABLED,
  GDK_MODE_SCREEN,
  GDK_MODE_WINDOW
} GdkInputMode;

/**
 * GdkDeviceType:
 * @GDK_DEVICE_TYPE_MASTER: Device is a master (or virtual) device. There will
 *                          be an associated focus indicator on the screen.
 * @GDK_DEVICE_TYPE_SLAVE: Device is a slave (or physical) device.
 * @GDK_DEVICE_TYPE_FLOATING: Device is a physical device, currently not attached to
96
 *                            any seat.
97
 *
98
 * Indicates the device type.
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
 */
typedef enum {
  GDK_DEVICE_TYPE_MASTER,
  GDK_DEVICE_TYPE_SLAVE,
  GDK_DEVICE_TYPE_FLOATING
} GdkDeviceType;

/* We don't allocate each coordinate this big, but we use it to
 * be ANSI compliant and avoid accessing past the defined limits.
 */
#define GDK_MAX_TIMECOORD_AXES 128

/**
 * GdkTimeCoord:
 * @time: The timestamp for this event.
114
 * @axes: the values of the device’s axes.
115
 *
116
 * A #GdkTimeCoord stores a single event in a motion history.
117
118
119
120
121
122
123
 */
struct _GdkTimeCoord
{
  guint32 time;
  gdouble axes[GDK_MAX_TIMECOORD_AXES];
};

124
GDK_AVAILABLE_IN_ALL
125
GType                 gdk_device_get_type       (void) G_GNUC_CONST;
126

127
GDK_AVAILABLE_IN_ALL
128
const gchar *         gdk_device_get_name       (GdkDevice *device);
129
GDK_AVAILABLE_IN_ALL
130
131
132
gboolean              gdk_device_get_has_cursor (GdkDevice *device);

/* Functions to configure a device */
133
GDK_AVAILABLE_IN_ALL
134
135
GdkInputSource gdk_device_get_source    (GdkDevice      *device);

136
GDK_AVAILABLE_IN_ALL
137
GdkInputMode   gdk_device_get_mode      (GdkDevice      *device);
138
GDK_AVAILABLE_IN_ALL
139
gboolean       gdk_device_set_mode      (GdkDevice      *device,
Matthias Clasen's avatar
Matthias Clasen committed
140
                                         GdkInputMode    mode);
141

142
GDK_AVAILABLE_IN_ALL
143
gint           gdk_device_get_n_keys    (GdkDevice       *device);
144
GDK_AVAILABLE_IN_ALL
145
146
147
148
gboolean       gdk_device_get_key       (GdkDevice       *device,
                                         guint            index_,
                                         guint           *keyval,
                                         GdkModifierType *modifiers);
149
GDK_AVAILABLE_IN_ALL
150
void           gdk_device_set_key       (GdkDevice      *device,
Matthias Clasen's avatar
Matthias Clasen committed
151
152
153
                                         guint           index_,
                                         guint           keyval,
                                         GdkModifierType modifiers);
154

155
GDK_AVAILABLE_IN_ALL
156
157
GdkAxisUse     gdk_device_get_axis_use  (GdkDevice         *device,
                                         guint              index_);
158
GDK_AVAILABLE_IN_ALL
159
160
161
162
163
void           gdk_device_set_axis_use  (GdkDevice         *device,
                                         guint              index_,
                                         GdkAxisUse         use);


164
GDK_AVAILABLE_IN_ALL
165
void     gdk_device_get_state    (GdkDevice         *device,
Matthias Clasen's avatar
Matthias Clasen committed
166
167
168
                                  GdkWindow         *window,
                                  gdouble           *axes,
                                  GdkModifierType   *mask);
169
GDK_AVAILABLE_IN_ALL
170
171
172
void     gdk_device_get_position (GdkDevice         *device,
                                  gint              *x,
                                  gint              *y);
173
GDK_AVAILABLE_IN_ALL
174
175
176
177
178
GdkWindow *
         gdk_device_get_window_at_position
                                 (GdkDevice         *device,
                                  gint              *win_x,
                                  gint              *win_y);
179
180
181
182
183
184
185
186
187
188
GDK_AVAILABLE_IN_3_10
void     gdk_device_get_position_double (GdkDevice         *device,
                                         gdouble           *x,
                                         gdouble           *y);
GDK_AVAILABLE_IN_3_10
GdkWindow *
         gdk_device_get_window_at_position_double
                                 (GdkDevice         *device,
                                  gdouble           *win_x,
                                  gdouble           *win_y);
189
GDK_AVAILABLE_IN_ALL
190
gboolean gdk_device_get_history  (GdkDevice         *device,
Matthias Clasen's avatar
Matthias Clasen committed
191
192
193
194
195
                                  GdkWindow         *window,
                                  guint32            start,
                                  guint32            stop,
                                  GdkTimeCoord    ***events,
                                  gint              *n_events);
196
GDK_AVAILABLE_IN_ALL
197
void     gdk_device_free_history (GdkTimeCoord     **events,
Matthias Clasen's avatar
Matthias Clasen committed
198
                                  gint               n_events);
199

200
GDK_AVAILABLE_IN_ALL
201
gint     gdk_device_get_n_axes     (GdkDevice       *device);
202
GDK_AVAILABLE_IN_ALL
203
GList *  gdk_device_list_axes      (GdkDevice       *device);
204
GDK_AVAILABLE_IN_ALL
205
206
207
208
209
gboolean gdk_device_get_axis_value (GdkDevice       *device,
                                    gdouble         *axes,
                                    GdkAtom          axis_label,
                                    gdouble         *value);

210
GDK_AVAILABLE_IN_ALL
211
gboolean gdk_device_get_axis     (GdkDevice         *device,
Matthias Clasen's avatar
Matthias Clasen committed
212
213
214
                                  gdouble           *axes,
                                  GdkAxisUse         use,
                                  gdouble           *value);
215
GDK_AVAILABLE_IN_ALL
216
217
GdkDisplay * gdk_device_get_display (GdkDevice      *device);

218
GDK_AVAILABLE_IN_ALL
219
GdkDevice  * gdk_device_get_associated_device (GdkDevice     *device);
220
GDK_AVAILABLE_IN_ALL
221
GList *      gdk_device_list_slave_devices    (GdkDevice     *device);
222

223
GDK_AVAILABLE_IN_ALL
224
225
GdkDeviceType gdk_device_get_device_type (GdkDevice *device);

226
227
228
229
230
231
232
233
234
235
236
237
238
GDK_DEPRECATED_IN_3_20_FOR(gdk_seat_grab)
GdkGrabStatus gdk_device_grab        (GdkDevice        *device,
                                      GdkWindow        *window,
                                      GdkGrabOwnership  grab_ownership,
                                      gboolean          owner_events,
                                      GdkEventMask      event_mask,
                                      GdkCursor        *cursor,
                                      guint32           time_);

GDK_DEPRECATED_IN_3_20_FOR(gdk_seat_ungrab)
void          gdk_device_ungrab      (GdkDevice        *device,
                                      guint32           time_);

239
GDK_AVAILABLE_IN_ALL
240
241
242
243
void          gdk_device_warp        (GdkDevice        *device,
                                      gint              x,
                                      gint              y);

244
245
GDK_AVAILABLE_IN_3_12
GdkWindow *gdk_device_get_last_event_window (GdkDevice *device);
246

247
248
249
250
251
GDK_AVAILABLE_IN_3_16
const gchar *gdk_device_get_vendor_id       (GdkDevice *device);
GDK_AVAILABLE_IN_3_16
const gchar *gdk_device_get_product_id      (GdkDevice *device);

252
253
254
GDK_AVAILABLE_IN_3_20
GdkSeat     *gdk_device_get_seat            (GdkDevice *device);

255
256
257
GDK_AVAILABLE_IN_3_22
GdkAxisFlags gdk_device_get_axes            (GdkDevice *device);

258
259
260
G_END_DECLS

#endif /* __GDK_DEVICE_H__ */