]> Pileus Git - ~andy/gtk/blob - gdk/x11/gdkinputprivate.h
Merges from gtk-1-2
[~andy/gtk] / gdk / x11 / gdkinputprivate.h
1 /* GDK - The GIMP Drawing Kit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library 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  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library 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 /*
21  * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
22  * file for a list of people on the GTK+ Team.  See the ChangeLog
23  * files for a list of changes.  These files are distributed with
24  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
25  */
26
27 #ifndef __GDK_INPUTPRIVATE_H__
28 #define __GDK_INPUTPRIVATE_H__
29
30 #include "config.h"
31 #include "gdkinput.h"
32 #include "gdkevents.h"
33 #include "gdkx.h"
34
35 #include <X11/Xlib.h>
36
37 #ifndef XINPUT_NONE
38 #include <X11/extensions/XInput.h>
39 #endif
40
41 typedef struct _GdkAxisInfo    GdkAxisInfo;
42 typedef struct _GdkInputVTable GdkInputVTable;
43 typedef struct _GdkDevicePrivate GdkDevicePrivate;
44 typedef struct _GdkInputWindow GdkInputWindow;
45
46 struct _GdkInputVTable {
47   gint (*set_mode) (guint32 deviceid, GdkInputMode mode);
48   void (*set_axes) (guint32 deviceid, GdkAxisUse *axes);
49   void (*set_key)  (guint32 deviceid,
50                     guint   index,
51                     guint   keyval,
52                     GdkModifierType modifiers);
53         
54   GdkTimeCoord* (*motion_events) (GdkWindow *window,
55                                   guint32 deviceid,
56                                   guint32 start,
57                                   guint32 stop,
58                                   gint *nevents_return);
59   void (*get_pointer)   (GdkWindow       *window,
60                          guint32          deviceid,
61                          gdouble         *x,
62                          gdouble         *y,
63                          gdouble         *pressure,
64                          gdouble         *xtilt,
65                          gdouble         *ytilt,
66                          GdkModifierType *mask);
67   gint (*grab_pointer) (GdkWindow *     window,
68                         gint            owner_events,
69                         GdkEventMask    event_mask,
70                         GdkWindow *     confine_to,
71                         guint32         time);
72   void (*ungrab_pointer) (guint32 time);
73
74   void (*configure_event) (XConfigureEvent *xevent, GdkWindow *window);
75   void (*enter_event) (XCrossingEvent *xevent, GdkWindow *window);
76   gint (*other_event) (GdkEvent *event, XEvent *xevent, GdkWindow *window);
77   /* Handle an unidentified event. Returns TRUE if handled, FALSE
78      otherwise */
79   gint (*window_none_event) (GdkEvent *event, XEvent *xevent);
80   gint (*enable_window) (GdkWindow *window, GdkDevicePrivate *gdkdev);
81   gint (*disable_window) (GdkWindow *window, GdkDevicePrivate *gdkdev);
82 };
83
84 /* information about a device axis */
85 struct _GdkAxisInfo
86 {
87   /* reported x resolution */
88   gint xresolution;
89
90   /* reported x minimum/maximum values */
91   gint xmin_value, xmax_value;
92
93   /* calibrated resolution (for aspect ration) - only relative values
94      between axes used */
95   gint resolution;
96   
97   /* calibrated minimum/maximum values */
98   gint min_value, max_value;
99 };
100
101 #define GDK_INPUT_NUM_EVENTC 6
102
103 struct _GdkDevicePrivate {
104   GdkDeviceInfo  info;
105
106 #ifndef XINPUT_NONE
107   /* information about the axes */
108   GdkAxisInfo *axes;
109
110   /* reverse lookup on axis use type */
111   gint axis_for_use[GDK_AXIS_LAST];
112   
113   /* Information about XInput device */
114   XDevice       *xdevice;
115
116   /* minimum key code for device */
117   gint min_keycode;            
118
119   int buttonpress_type, buttonrelease_type, keypress_type,
120       keyrelease_type, motionnotify_type, proximityin_type, 
121       proximityout_type, changenotify_type;
122
123   /* true if we need to select a different set of events, but
124      can't because this is the core pointer */
125   gint needs_update;
126
127   /* Mask of buttons (used for button grabs) */
128   gint button_state;
129
130   /* true if we've claimed the device as active. (used only for XINPUT_GXI) */
131   gint claimed;
132 #endif /* !XINPUT_NONE */
133 };
134
135 struct _GdkInputWindow
136 {
137   /* gdk window */
138   GdkWindow *window;
139
140   /* Extension mode (GDK_EXTENSION_EVENTS_ALL/CURSOR) */
141   GdkExtensionMode mode;
142
143   /* position relative to root window */
144   gint16 root_x;
145   gint16 root_y;
146
147   /* rectangles relative to window of windows obscuring this one */
148   GdkRectangle *obscuring;
149   gint num_obscuring;
150
151   /* Is there a pointer grab for this window ? */
152   gint grabbed;
153 };
154
155 /* Global data */
156
157 extern const GdkDeviceInfo gdk_input_core_info;
158 extern GList *gdk_input_devices;
159 extern GList *gdk_input_windows;
160
161 extern GdkInputVTable gdk_input_vtable;
162 /* information about network port and host for gxid daemon */
163 extern gchar           *gdk_input_gxid_host;
164 extern gint             gdk_input_gxid_port;
165 extern gint             gdk_input_ignore_core;
166
167 /* Function declarations */
168
169 GdkDevicePrivate * gdk_input_find_device    (guint32           id);
170 GdkInputWindow *   gdk_input_window_find    (GdkWindow        *window);
171 void               gdk_input_window_destroy (GdkWindow        *window);
172 void               gdk_input_init           (void);
173 void               gdk_input_exit           (void);
174 gint               gdk_input_enable_window  (GdkWindow        *window,
175                                              GdkDevicePrivate *gdkdev);
176 gint               gdk_input_disable_window (GdkWindow        *window,
177                                              GdkDevicePrivate *gdkdev);
178
179 #ifndef XINPUT_NONE
180
181 #define GDK_MAX_DEVICE_CLASSES 13
182
183 gint           gdk_input_common_init                (gint              include_core);
184 void           gdk_input_get_root_relative_geometry (Display          *dpy,
185                                                      Window            w,
186                                                      int              *x_ret,
187                                                      int              *y_ret,
188                                                      int              *width_ret,
189                                                      int              *height_ret);
190 void           gdk_input_common_find_events         (GdkWindow        *window,
191                                                      GdkDevicePrivate *gdkdev,
192                                                      gint              mask,
193                                                      XEventClass      *classes,
194                                                      int              *num_classes);
195 void           gdk_input_common_select_events       (GdkWindow        *window,
196                                                      GdkDevicePrivate *gdkdev);
197 gint           gdk_input_common_other_event         (GdkEvent         *event,
198                                                      XEvent           *xevent,
199                                                      GdkInputWindow   *input_window,
200                                                      GdkDevicePrivate *gdkdev);
201 void           gdk_input_common_get_pointer         (GdkWindow        *window,
202                                                      guint32           deviceid,
203                                                      gdouble          *x,
204                                                      gdouble          *y,
205                                                      gdouble          *pressure,
206                                                      gdouble          *xtilt,
207                                                      gdouble          *ytilt,
208                                                      GdkModifierType  *mask);
209 void           gdk_input_common_set_key             (guint32           deviceid,
210                                                      guint             index,
211                                                      guint             keyval,
212                                                      GdkModifierType   modifiers);
213 void           gdk_input_common_set_axes            (guint32           deviceid,
214                                                      GdkAxisUse       *axes);
215 GdkTimeCoord * gdk_input_common_motion_events       (GdkWindow        *window,
216                                                      guint32           deviceid,
217                                                      guint32           start,
218                                                      guint32           stop,
219                                                      gint             *nevents_return);
220
221 #endif /* !XINPUT_NONE */
222
223 GdkDevicePrivate *gdk_input_find_device (guint32 id);
224 GdkInputWindow *gdk_input_window_find (GdkWindow *window);
225 void gdk_input_window_destroy (GdkWindow *window);
226 void gdk_input_exit           (void);
227
228 #endif /* __GDK_INPUTPRIVATE_H__ */