]> Pileus Git - ~andy/gtk/blob - gdk/gdkdeviceprivate.h
e317b16c1e7e3e43c95f4e3290a27c0fdbc7789c
[~andy/gtk] / gdk / gdkdeviceprivate.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 #ifndef __GDK_DEVICE_PRIVATE_H__
21 #define __GDK_DEVICE_PRIVATE_H__
22
23 #include "gdkdevice.h"
24 #include "gdkdevicemanager.h"
25 #include "gdkevents.h"
26
27 G_BEGIN_DECLS
28
29 #define GDK_DEVICE_CLASS(c)     (G_TYPE_CHECK_CLASS_CAST ((c), GDK_TYPE_DEVICE, GdkDeviceClass))
30 #define GDK_IS_DEVICE_CLASS(c)  (G_TYPE_CHECK_CLASS_TYPE ((c), GDK_TYPE_DEVICE))
31 #define GDK_DEVICE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDK_TYPE_DEVICE, GdkDeviceClass))
32
33 typedef struct _GdkDeviceClass GdkDeviceClass;
34 typedef struct _GdkDeviceKey GdkDeviceKey;
35
36 struct _GdkDeviceKey
37 {
38   guint keyval;
39   GdkModifierType modifiers;
40 };
41
42 struct _GdkDevice
43 {
44   GObject parent_instance;
45
46   gchar *name;
47   GdkInputSource source;
48   GdkInputMode mode;
49   gboolean has_cursor;
50   gint num_keys;
51   GdkDeviceKey *keys;
52   GdkDeviceManager *manager;
53   GdkDisplay *display;
54   /* Paired master for master,
55    * associated master for slaves
56    */
57   GdkDevice *associated;
58   GList *slaves;
59   GdkDeviceType type;
60   GArray *axes;
61 };
62
63 struct _GdkDeviceClass
64 {
65   GObjectClass parent_class;
66
67   gboolean (* get_history)   (GdkDevice      *device,
68                               GdkWindow      *window,
69                               guint32         start,
70                               guint32         stop,
71                               GdkTimeCoord ***events,
72                               gint           *n_events);
73
74   void (* get_state)         (GdkDevice       *device,
75                               GdkWindow       *window,
76                               gdouble         *axes,
77                               GdkModifierType *mask);
78
79   void (* set_window_cursor) (GdkDevice *device,
80                               GdkWindow *window,
81                               GdkCursor *cursor);
82
83   void (* warp)              (GdkDevice  *device,
84                               GdkScreen  *screen,
85                               gint        x,
86                               gint        y);
87   gboolean (* query_state)   (GdkDevice       *device,
88                               GdkWindow       *window,
89                               GdkWindow      **root_window,
90                               GdkWindow      **child_window,
91                               gint             *root_x,
92                               gint             *root_y,
93                               gint             *win_x,
94                               gint             *win_y,
95                               GdkModifierType  *mask);
96   GdkGrabStatus (* grab)     (GdkDevice        *device,
97                               GdkWindow        *window,
98                               gboolean          owner_events,
99                               GdkEventMask      event_mask,
100                               GdkWindow        *confine_to,
101                               GdkCursor        *cursor,
102                               guint32           time_);
103   void          (*ungrab)    (GdkDevice        *device,
104                               guint32           time_);
105
106   GdkWindow * (* window_at_position) (GdkDevice       *device,
107                                       gint            *win_x,
108                                       gint            *win_y,
109                                       GdkModifierType *mask,
110                                       gboolean         get_toplevel);
111   void (* select_window_events)      (GdkDevice       *device,
112                                       GdkWindow       *window,
113                                       GdkEventMask     event_mask);
114 };
115
116 void  _gdk_device_set_associated_device (GdkDevice *device,
117                                          GdkDevice *relative);
118
119 void  _gdk_device_reset_axes (GdkDevice   *device);
120 guint _gdk_device_add_axis   (GdkDevice   *device,
121                               GdkAtom      label_atom,
122                               GdkAxisUse   use,
123                               gdouble      min_value,
124                               gdouble      max_value,
125                               gdouble      resolution);
126
127 void _gdk_device_set_keys    (GdkDevice   *device,
128                               guint        num_keys);
129
130 gboolean   _gdk_device_translate_window_coord (GdkDevice *device,
131                                                GdkWindow *window,
132                                                guint      index,
133                                                gdouble    value,
134                                                gdouble   *axis_value);
135
136 gboolean   _gdk_device_translate_screen_coord (GdkDevice *device,
137                                                GdkWindow *window,
138                                                gint       window_root_x,
139                                                gint       window_root_y,
140                                                guint      index,
141                                                gdouble    value,
142                                                gdouble   *axis_value);
143
144 gboolean   _gdk_device_translate_axis         (GdkDevice *device,
145                                                guint      index,
146                                                gdouble    value,
147                                                gdouble   *axis_value);
148
149 GdkTimeCoord ** _gdk_device_allocate_history  (GdkDevice *device,
150                                                gint       n_events);
151
152 void _gdk_device_add_slave (GdkDevice *device,
153                             GdkDevice *slave);
154 void _gdk_device_remove_slave (GdkDevice *device,
155                                GdkDevice *slave);
156 gboolean   _gdk_device_query_state            (GdkDevice        *device,
157                                                GdkWindow        *window,
158                                                GdkWindow       **root_window,
159                                                GdkWindow       **child_window,
160                                                gint             *root_x,
161                                                gint             *root_y,
162                                                gint             *win_x,
163                                                gint             *win_y,
164                                                GdkModifierType  *mask);
165 GdkWindow * _gdk_device_window_at_position    (GdkDevice        *device,
166                                                gint             *win_x,
167                                                gint             *win_y,
168                                                GdkModifierType  *mask,
169                                                gboolean          get_toplevel);
170
171 G_END_DECLS
172
173 #endif /* __GDK_DEVICE_PRIVATE_H__ */