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 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 /*
21  * Modified by the GTK+ Team and others 1997-2000.  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 
42 typedef struct _GdkAxisInfo    GdkAxisInfo;
43 typedef struct _GdkDevicePrivate GdkDevicePrivate;
44 
45 /* information about a device axis */
46 struct _GdkAxisInfo
47 {
48   /* reported x resolution */
49   gint xresolution;
50 
51   /* reported x minimum/maximum values */
52   gint xmin_value, xmax_value;
53 
54   /* calibrated resolution (for aspect ration) - only relative values
55      between axes used */
56   gint resolution;
57 
58   /* calibrated minimum/maximum values */
59   gint min_value, max_value;
60 };
61 
62 #define GDK_INPUT_NUM_EVENTC 6
63 
64 struct _GdkDevicePrivate
65 {
66   GdkDevice info;
67 
68   guint32 deviceid;
69 
70   GdkDisplay *display;
71 
72 
73 #ifndef XINPUT_NONE
74   /* information about the axes */
75   GdkAxisInfo *axes;
76   gint *axis_data;
77 
78   /* Information about XInput device */
79   XDevice       *xdevice;
80 
81   /* minimum key code for device */
82   gint min_keycode;
83 
84   int buttonpress_type, buttonrelease_type, keypress_type,
85       keyrelease_type, motionnotify_type, proximityin_type,
86       proximityout_type, changenotify_type, devicestatenotify_type;
87 
88   /* true if we need to select a different set of events, but
89      can't because this is the core pointer */
90   gint needs_update;
91 
92   /* Mask of buttons (used for button grabs) */
93   char button_state[32];
94   gint button_count;
95 
96   /* true if we've claimed the device as active. (used only for XINPUT_GXI) */
97   gint claimed;
98 #endif /* !XINPUT_NONE */
99 };
100 
101 struct _GdkDeviceClass
102 {
103   GObjectClass parent_class;
104 };
105 
106 /* Addition used for extension_events mask */
107 #define GDK_ALL_DEVICES_MASK (1<<30)
108 
109 struct _GdkInputWindow
110 {
111   GList *windows; /* GdkWindow:s with extension_events set */
112 
113   /* gdk window */
114   GdkWindow *impl_window; /* an impl window */
115   GdkWindow *button_down_window;
116 
117   /* position relative to root window */
118   gint root_x;
119   gint root_y;
120 
121   /* Is there a pointer grab for this window ? */
122   gint grabbed;
123 };
124 
125 /* Global data */
126 
127 #define GDK_IS_CORE(d) (((GdkDevice *)(d)) == ((GdkDevicePrivate *)(d))->display->core_pointer)
128 
129 /* Function declarations */
130 
131 GdkInputWindow *_gdk_input_window_find       (GdkWindow *window);
132 void            _gdk_input_window_destroy    (GdkWindow *window);
133 GdkTimeCoord ** _gdk_device_allocate_history (GdkDevice *device,
134 					      gint       n_events);
135 void            _gdk_init_input_core         (GdkDisplay *display);
136 
137 /* The following functions are provided by each implementation
138  * (xfree, gxi, and none)
139  */
140 void             _gdk_input_configure_event  (XConfigureEvent  *xevent,
141 					      GdkWindow        *window);
142 void             _gdk_input_crossing_event   (GdkWindow        *window,
143 					      gboolean          enter);
144 gboolean         _gdk_input_other_event      (GdkEvent         *event,
145 					      XEvent           *xevent,
146 					      GdkWindow        *window);
147 gint             _gdk_input_grab_pointer     (GdkWindow        *window,
148 					      GdkWindow        *native_window,
149 					      gint              owner_events,
150 					      GdkEventMask      event_mask,
151 					      GdkWindow        *confine_to,
152 					      guint32           time);
153 void             _gdk_input_ungrab_pointer   (GdkDisplay       *display,
154 					      guint32           time);
155 gboolean         _gdk_device_get_history     (GdkDevice         *device,
156 					      GdkWindow         *window,
157 					      guint32            start,
158 					      guint32            stop,
159 					      GdkTimeCoord    ***events,
160 					      gint              *n_events);
161 
162 #ifndef XINPUT_NONE
163 
164 #define GDK_MAX_DEVICE_CLASSES 13
165 
166 gint               _gdk_input_common_init               (GdkDisplay	  *display,
167 							 gint              include_core);
168 GdkDevicePrivate * _gdk_input_find_device               (GdkDisplay	  *display,
169 							 guint32           id);
170 void               _gdk_input_get_root_relative_geometry(GdkWindow        *window,
171 							 int              *x_ret,
172 							 int              *y_ret);
173 void               _gdk_input_common_find_events        (GdkDevicePrivate *gdkdev,
174 							 gint              mask,
175 							 XEventClass      *classes,
176 							 int              *num_classes);
177 void               _gdk_input_select_events             (GdkWindow        *impl_window,
178 							 GdkDevicePrivate *gdkdev);
179 gint               _gdk_input_common_other_event        (GdkEvent         *event,
180 							 XEvent           *xevent,
181 							 GdkWindow        *window,
182 							 GdkDevicePrivate *gdkdev);
183 gboolean	   _gdk_input_common_event_selected     (GdkEvent         *event,
184 							 GdkWindow        *window,
185 							 GdkDevicePrivate *gdkdev);
186 
187 #endif /* !XINPUT_NONE */
188 
189 #endif /* __GDK_INPUTPRIVATE_H__ */
190