]> Pileus Git - ~andy/gtk/blob - gdk/gdkinput.h
Initial revision
[~andy/gtk] / gdk / gdkinput.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 Free
16  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17  */
18
19 #ifndef __GDK_INPUT_H__
20 #define __GDK_INPUT_H__
21
22 #ifndef XINPUT_NONE
23 #include <X11/extensions/XInput.h>
24 #endif
25
26 typedef struct _GdkAxisInfo    GdkAxisInfo;
27 typedef struct _GdkInputVTable GdkInputVTable;
28 typedef struct _GdkDevicePrivate GdkDevicePrivate;
29 typedef struct _GdkInputWindow GdkInputWindow;
30
31 struct _GdkInputVTable {
32   gint (*set_mode) (guint32 deviceid, GdkInputMode mode);
33   void (*set_axes) (guint32 deviceid, GdkAxisUse *axes);
34   GdkTimeCoord* (*motion_events) (GdkWindow *window,
35                                   guint32 deviceid,
36                                   guint32 start,
37                                   guint32 stop,
38                                   gint *nevents_return);
39   void (*get_pointer)   (GdkWindow       *window,
40                          guint32          deviceid,
41                          gdouble         *x,
42                          gdouble         *y,
43                          gdouble         *pressure,
44                          gdouble         *xtilt,
45                          gdouble         *ytilt,
46                          GdkModifierType *mask);
47   gint (*grab_pointer) (GdkWindow *     window,
48                         gint            owner_events,
49                         GdkEventMask    event_mask,
50                         GdkWindow *     confine_to,
51                         guint32         time);
52   void (*ungrab_pointer) (guint32 time);
53
54   void (*configure_event) (XConfigureEvent *xevent, GdkWindow *window);
55   void (*enter_event) (XCrossingEvent *xevent, GdkWindow *window);
56   gint (*other_event) (GdkEvent *event, XEvent *xevent, GdkWindow *window);
57   /* Handle an unidentified event. Returns TRUE if handled, FALSE
58      otherwise */
59   gint (*window_none_event) (GdkEvent *event, XEvent *xevent);
60   gint (*enable_window) (GdkWindow *window, GdkDevicePrivate *gdkdev);
61   gint (*disable_window) (GdkWindow *window, GdkDevicePrivate *gdkdev);
62 };
63
64 /* information about a device axis */
65 struct _GdkAxisInfo
66 {
67   /* reported x resolution */
68   gint xresolution;
69
70   /* reported x minimum/maximum values */
71   gint xmin_value, xmax_value;
72
73   /* calibrated resolution (for aspect ration) - only relative values
74      between axes used */
75   gint resolution;
76   
77   /* calibrated minimum/maximum values */
78   gint min_value, max_value;
79 };
80
81 #define GDK_INPUT_NUM_EVENTC 6
82
83 struct _GdkDevicePrivate {
84   GdkDeviceInfo  info;
85
86 #ifndef XINPUT_NONE
87   /* information about the axes */
88   GdkAxisInfo *axes;
89
90   /* reverse lookup on axis use type */
91   gint axis_for_use[GDK_AXIS_LAST];
92   
93   /* Information about XInput device */
94   XDevice       *xdevice;
95
96   int buttonpress_type, buttonrelease_type, motionnotify_type,
97       proximityin_type, proximityout_type, changenotify_type;
98
99   /* true if we need to select a different set of events, but
100      can't because this is the core pointer */
101   gint needs_update;
102
103   /* Mask of buttons (used for button grabs) */
104   gint button_state;
105
106   /* true if we've claimed the device as active. (used only for XINPUT_GXI) */
107   gint claimed;
108 #endif /* !XINPUT_NONE */
109 };
110
111 struct _GdkInputWindow
112 {
113   /* gdk window */
114   GdkWindow *window;
115
116   /* Extension mode (GDK_EXTENSION_EVENTS_ALL/CURSOR) */
117   GdkExtensionMode mode;
118
119   /* position relative to root window */
120   gint16 root_x;
121   gint16 root_y;
122
123   /* rectangles relative to window of windows obscuring this one */
124   GdkRectangle *obscuring;
125   gint num_obscuring;
126
127   /* Is there a pointer grab for this window ? */
128   gint grabbed;
129 };
130
131 /* Global data */
132
133 extern GdkInputVTable gdk_input_vtable;
134 /* information about network port and host for gxid daemon */
135 extern gchar           *gdk_input_gxid_host;
136 extern gint             gdk_input_gxid_port;
137 extern gint             gdk_input_ignore_core;
138
139 /* Function declarations */
140
141 void gdk_input_window_destroy (GdkWindow *window);
142
143 #endif __GDK_INPUT_H__