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_PRIVATE_H__
19#define __GDK_DEVICE_PRIVATE_H__
20
21#include "gdkdevice.h"
22#include "gdkdevicetool.h"
23#include "gdkevents.h"
24#include "gdkseat.h"
25
26G_BEGIN_DECLS
27
28typedef enum
29{
30 GDK_GRAB_SUCCESS = 0,
31 GDK_GRAB_ALREADY_GRABBED = 1,
32 GDK_GRAB_INVALID_TIME = 2,
33 GDK_GRAB_NOT_VIEWABLE = 3,
34 GDK_GRAB_FROZEN = 4,
35 GDK_GRAB_FAILED = 5
36} GdkGrabStatus;
37
38typedef enum
39{
40 GDK_EXPOSURE_MASK = 1 << 1,
41 GDK_POINTER_MOTION_MASK = 1 << 2,
42 GDK_BUTTON_MOTION_MASK = 1 << 4,
43 GDK_BUTTON1_MOTION_MASK = 1 << 5,
44 GDK_BUTTON2_MOTION_MASK = 1 << 6,
45 GDK_BUTTON3_MOTION_MASK = 1 << 7,
46 GDK_BUTTON_PRESS_MASK = 1 << 8,
47 GDK_BUTTON_RELEASE_MASK = 1 << 9,
48 GDK_KEY_PRESS_MASK = 1 << 10,
49 GDK_KEY_RELEASE_MASK = 1 << 11,
50 GDK_ENTER_NOTIFY_MASK = 1 << 12,
51 GDK_LEAVE_NOTIFY_MASK = 1 << 13,
52 GDK_FOCUS_CHANGE_MASK = 1 << 14,
53 GDK_STRUCTURE_MASK = 1 << 15,
54 GDK_PROPERTY_CHANGE_MASK = 1 << 16,
55 GDK_PROXIMITY_IN_MASK = 1 << 18,
56 GDK_PROXIMITY_OUT_MASK = 1 << 19,
57 GDK_SCROLL_MASK = 1 << 20,
58 GDK_TOUCH_MASK = 1 << 21,
59 GDK_SMOOTH_SCROLL_MASK = 1 << 22,
60 GDK_TOUCHPAD_GESTURE_MASK = 1 << 23,
61 GDK_TABLET_PAD_MASK = 1 << 24,
62 GDK_ALL_EVENTS_MASK = 0x3FFFFFE
63} GdkEventMask;
64
65#define GDK_DEVICE_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GDK_TYPE_DEVICE, GdkDeviceClass))
66#define GDK_IS_DEVICE_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GDK_TYPE_DEVICE))
67#define GDK_DEVICE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDK_TYPE_DEVICE, GdkDeviceClass))
68
69typedef struct _GdkDeviceClass GdkDeviceClass;
70
71struct _GdkDevice
72{
73 GObject parent_instance;
74
75 char *name;
76 GdkInputSource source;
77 gboolean has_cursor;
78 GdkDisplay *display;
79 /* The paired logical device for logical devices,
80 * or the associated logical device for physical ones
81 */
82 GdkDevice *associated;
83 GList *physical_devices;
84 GArray *axes;
85 guint num_touches;
86
87 char *vendor_id;
88 char *product_id;
89
90 GdkSeat *seat;
91 GdkDeviceTool *last_tool;
92
93 guint32 timestamp;
94};
95
96struct _GdkDeviceClass
97{
98 GObjectClass parent_class;
99
100 void (* set_surface_cursor)(GdkDevice *device,
101 GdkSurface *surface,
102 GdkCursor *cursor);
103
104 GdkGrabStatus (* grab) (GdkDevice *device,
105 GdkSurface *surface,
106 gboolean owner_events,
107 GdkEventMask event_mask,
108 GdkSurface *confine_to,
109 GdkCursor *cursor,
110 guint32 time_);
111 void (*ungrab) (GdkDevice *device,
112 guint32 time_);
113
114 GdkSurface * (* surface_at_position) (GdkDevice *device,
115 double *win_x,
116 double *win_y,
117 GdkModifierType *mask);
118};
119
120void _gdk_device_set_associated_device (GdkDevice *device,
121 GdkDevice *relative);
122
123void _gdk_device_reset_axes (GdkDevice *device);
124guint _gdk_device_add_axis (GdkDevice *device,
125 GdkAxisUse use,
126 double min_value,
127 double max_value,
128 double resolution);
129void _gdk_device_get_axis_info (GdkDevice *device,
130 guint index,
131 GdkAxisUse *use,
132 double *min_value,
133 double *max_value,
134 double *resolution);
135
136gboolean _gdk_device_translate_surface_coord (GdkDevice *device,
137 GdkSurface *surface,
138 guint index,
139 double value,
140 double *axis_value);
141
142gboolean _gdk_device_translate_screen_coord (GdkDevice *device,
143 GdkSurface *surface,
144 double surface_root_x,
145 double surface_root_y,
146 double screen_width,
147 double screen_height,
148 guint index,
149 double value,
150 double *axis_value);
151
152gboolean _gdk_device_translate_axis (GdkDevice *device,
153 guint index,
154 double value,
155 double *axis_value);
156
157GdkTimeCoord ** _gdk_device_allocate_history (GdkDevice *device,
158 int n_events);
159
160GList * gdk_device_list_physical_devices (GdkDevice *device);
161
162void _gdk_device_add_physical_device (GdkDevice *device,
163 GdkDevice *physical);
164void _gdk_device_remove_physical_device (GdkDevice *device,
165 GdkDevice *physical);
166
167GdkSurface * _gdk_device_surface_at_position (GdkDevice *device,
168 double *win_x,
169 double *win_y,
170 GdkModifierType *mask);
171
172void gdk_device_set_seat (GdkDevice *device,
173 GdkSeat *seat);
174
175void gdk_device_update_tool (GdkDevice *device,
176 GdkDeviceTool *tool);
177
178GdkGrabStatus gdk_device_grab (GdkDevice *device,
179 GdkSurface *surface,
180 gboolean owner_events,
181 GdkEventMask event_mask,
182 GdkCursor *cursor,
183 guint32 time_);
184void gdk_device_ungrab (GdkDevice *device,
185 guint32 time_);
186int gdk_device_get_n_axes (GdkDevice *device);
187gboolean gdk_device_get_axis (GdkDevice *device,
188 double *axes,
189 GdkAxisUse use,
190 double *value);
191GdkAxisUse gdk_device_get_axis_use (GdkDevice *device,
192 guint index_);
193
194void gdk_device_set_timestamp (GdkDevice *device,
195 guint32 timestamp);
196
197
198G_END_DECLS
199
200#endif /* __GDK_DEVICE_PRIVATE_H__ */
201

source code of gtk/gdk/gdkdeviceprivate.h