]> Pileus Git - ~andy/gtk/blob - gdk/gdkevents.h
Temp debugging function prototype left in by mistake.
[~andy/gtk] / gdk / gdkevents.h
1 #ifndef __GDK_EVENTS_H__
2 #define __GDK_EVENTS_H__
3
4 #include <gdk/gdktypes.h>
5 #include <gdk/gdkdnd.h>
6 #include <gdk/gdkinput.h>
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif /* __cplusplus */
11
12 #define   GDK_PRIORITY_EVENTS           (G_PRIORITY_DEFAULT)
13
14 typedef struct _GdkEventAny         GdkEventAny;
15 typedef struct _GdkEventExpose      GdkEventExpose;
16 typedef struct _GdkEventNoExpose    GdkEventNoExpose;
17 typedef struct _GdkEventVisibility  GdkEventVisibility;
18 typedef struct _GdkEventMotion      GdkEventMotion;
19 typedef struct _GdkEventButton      GdkEventButton;
20 typedef struct _GdkEventKey         GdkEventKey;
21 typedef struct _GdkEventFocus       GdkEventFocus;
22 typedef struct _GdkEventCrossing    GdkEventCrossing;
23 typedef struct _GdkEventConfigure   GdkEventConfigure;
24 typedef struct _GdkEventProperty    GdkEventProperty;
25 typedef struct _GdkEventSelection   GdkEventSelection;
26 typedef struct _GdkEventProximity   GdkEventProximity;
27 typedef struct _GdkEventClient      GdkEventClient;
28
29 typedef struct _GdkEventDND         GdkEventDND;
30
31 typedef union  _GdkEvent            GdkEvent;
32
33 typedef void (*GdkEventFunc) (GdkEvent *event,
34                               gpointer  data);
35
36 /* Event filtering */
37
38 typedef void GdkXEvent;   /* Can be cast to XEvent */
39
40 typedef enum {
41   GDK_FILTER_CONTINUE,    /* Event not handled, continue processesing */
42   GDK_FILTER_TRANSLATE,   /* Translated event stored */
43   GDK_FILTER_REMOVE       /* Terminate processing, removing event */
44 } GdkFilterReturn;
45
46 typedef GdkFilterReturn (*GdkFilterFunc) (GdkXEvent *xevent,
47                                           GdkEvent *event,
48                                           gpointer  data);
49
50
51 /* Event types.
52  *   Nothing: No event occurred.
53  *   Delete: A window delete event was sent by the window manager.
54  *           The specified window should be deleted.
55  *   Destroy: A window has been destroyed.
56  *   Expose: Part of a window has been uncovered.
57  *   NoExpose: Same as expose, but no expose event was generated.
58  *   VisibilityNotify: A window has become fully/partially/not obscured.
59  *   MotionNotify: The mouse has moved.
60  *   ButtonPress: A mouse button was pressed.
61  *   ButtonRelease: A mouse button was release.
62  *   KeyPress: A key was pressed.
63  *   KeyRelease: A key was released.
64  *   EnterNotify: A window was entered.
65  *   LeaveNotify: A window was exited.
66  *   FocusChange: The focus window has changed. (The focus window gets
67  *                keyboard events).
68  *   Resize: A window has been resized.
69  *   Map: A window has been mapped. (It is now visible on the screen).
70  *   Unmap: A window has been unmapped. (It is no longer visible on
71  *          the screen).
72  */
73 typedef enum
74 {
75   GDK_NOTHING           = -1,
76   GDK_DELETE            = 0,
77   GDK_DESTROY           = 1,
78   GDK_EXPOSE            = 2,
79   GDK_MOTION_NOTIFY     = 3,
80   GDK_BUTTON_PRESS      = 4,
81   GDK_2BUTTON_PRESS     = 5,
82   GDK_3BUTTON_PRESS     = 6,
83   GDK_BUTTON_RELEASE    = 7,
84   GDK_KEY_PRESS         = 8,
85   GDK_KEY_RELEASE       = 9,
86   GDK_ENTER_NOTIFY      = 10,
87   GDK_LEAVE_NOTIFY      = 11,
88   GDK_FOCUS_CHANGE      = 12,
89   GDK_CONFIGURE         = 13,
90   GDK_MAP               = 14,
91   GDK_UNMAP             = 15,
92   GDK_PROPERTY_NOTIFY   = 16,
93   GDK_SELECTION_CLEAR   = 17,
94   GDK_SELECTION_REQUEST = 18,
95   GDK_SELECTION_NOTIFY  = 19,
96   GDK_PROXIMITY_IN      = 20,
97   GDK_PROXIMITY_OUT     = 21,
98   GDK_DRAG_ENTER        = 22,
99   GDK_DRAG_LEAVE        = 23,
100   GDK_DRAG_MOTION       = 24,
101   GDK_DRAG_STATUS       = 25,
102   GDK_DROP_START        = 26,
103   GDK_DROP_FINISHED     = 27,
104   GDK_CLIENT_EVENT      = 28,
105   GDK_VISIBILITY_NOTIFY = 29,
106   GDK_NO_EXPOSE         = 30
107 } GdkEventType;
108
109 /* Event masks. (Used to select what types of events a window
110  *  will receive).
111  */
112 typedef enum
113 {
114   GDK_EXPOSURE_MASK             = 1 << 1,
115   GDK_POINTER_MOTION_MASK       = 1 << 2,
116   GDK_POINTER_MOTION_HINT_MASK  = 1 << 3,
117   GDK_BUTTON_MOTION_MASK        = 1 << 4,
118   GDK_BUTTON1_MOTION_MASK       = 1 << 5,
119   GDK_BUTTON2_MOTION_MASK       = 1 << 6,
120   GDK_BUTTON3_MOTION_MASK       = 1 << 7,
121   GDK_BUTTON_PRESS_MASK         = 1 << 8,
122   GDK_BUTTON_RELEASE_MASK       = 1 << 9,
123   GDK_KEY_PRESS_MASK            = 1 << 10,
124   GDK_KEY_RELEASE_MASK          = 1 << 11,
125   GDK_ENTER_NOTIFY_MASK         = 1 << 12,
126   GDK_LEAVE_NOTIFY_MASK         = 1 << 13,
127   GDK_FOCUS_CHANGE_MASK         = 1 << 14,
128   GDK_STRUCTURE_MASK            = 1 << 15,
129   GDK_PROPERTY_CHANGE_MASK      = 1 << 16,
130   GDK_VISIBILITY_NOTIFY_MASK    = 1 << 17,
131   GDK_PROXIMITY_IN_MASK         = 1 << 18,
132   GDK_PROXIMITY_OUT_MASK        = 1 << 19,
133   GDK_SUBSTRUCTURE_MASK         = 1 << 20,
134   GDK_ALL_EVENTS_MASK           = 0x0FFFFF
135 } GdkEventMask;
136
137 typedef enum {
138   GDK_VISIBILITY_UNOBSCURED,
139   GDK_VISIBILITY_PARTIAL,
140   GDK_VISIBILITY_FULLY_OBSCURED
141 } GdkVisibilityState;
142
143 /* Types of enter/leave notifications.
144  *   Ancestor:
145  *   Virtual:
146  *   Inferior:
147  *   Nonlinear:
148  *   NonlinearVirtual:
149  *   Unknown: An unknown type of enter/leave event occurred.
150  */
151 typedef enum
152 {
153   GDK_NOTIFY_ANCESTOR           = 0,
154   GDK_NOTIFY_VIRTUAL            = 1,
155   GDK_NOTIFY_INFERIOR           = 2,
156   GDK_NOTIFY_NONLINEAR          = 3,
157   GDK_NOTIFY_NONLINEAR_VIRTUAL  = 4,
158   GDK_NOTIFY_UNKNOWN            = 5
159 } GdkNotifyType;
160
161 /* Enter/leave event modes.
162  *   NotifyNormal
163  *   NotifyGrab
164  *   NotifyUngrab
165  */
166 typedef enum
167 {
168   GDK_CROSSING_NORMAL,
169   GDK_CROSSING_GRAB,
170   GDK_CROSSING_UNGRAB
171 } GdkCrossingMode;
172
173 typedef enum
174 {
175   GDK_PROPERTY_NEW_VALUE,
176   GDK_PROPERTY_DELETE
177 } GdkPropertyState;
178
179 struct _GdkEventAny
180 {
181   GdkEventType type;
182   GdkWindow *window;
183   gint8 send_event;
184 };
185
186 struct _GdkEventExpose
187 {
188   GdkEventType type;
189   GdkWindow *window;
190   gint8 send_event;
191   GdkRectangle area;
192   gint count; /* If non-zero, how many more events follow. */
193 };
194
195 struct _GdkEventNoExpose
196 {
197   GdkEventType type;
198   GdkWindow *window;
199   gint8 send_event;
200   /* XXX: does anyone need the X major_code or minor_code fields? */
201 };
202
203 struct _GdkEventVisibility
204 {
205   GdkEventType type;
206   GdkWindow *window;
207   gint8 send_event;
208   GdkVisibilityState state;
209 };
210
211 struct _GdkEventMotion
212 {
213   GdkEventType type;
214   GdkWindow *window;
215   gint8 send_event;
216   guint32 time;
217   gdouble x;
218   gdouble y;
219   gdouble pressure;
220   gdouble xtilt;
221   gdouble ytilt;
222   guint state;
223   gint16 is_hint;
224   GdkInputSource source;
225   guint32 deviceid;
226   gdouble x_root, y_root;
227 };
228
229 struct _GdkEventButton
230 {
231   GdkEventType type;
232   GdkWindow *window;
233   gint8 send_event;
234   guint32 time;
235   gdouble x;
236   gdouble y;
237   gdouble pressure;
238   gdouble xtilt;
239   gdouble ytilt;
240   guint state;
241   guint button;
242   GdkInputSource source;
243   guint32 deviceid;
244   gdouble x_root, y_root;
245 };
246
247 struct _GdkEventKey
248 {
249   GdkEventType type;
250   GdkWindow *window;
251   gint8 send_event;
252   guint32 time;
253   guint state;
254   guint keyval;
255   gint length;
256   gchar *string;
257 };
258
259 struct _GdkEventCrossing
260 {
261   GdkEventType type;
262   GdkWindow *window;
263   gint8 send_event;
264   GdkWindow *subwindow;
265   guint32 time;
266   gdouble x;
267   gdouble y;
268   gdouble x_root;
269   gdouble y_root;
270   GdkCrossingMode mode;
271   GdkNotifyType detail;
272   gboolean focus;
273   guint state;
274 };
275
276 struct _GdkEventFocus
277 {
278   GdkEventType type;
279   GdkWindow *window;
280   gint8 send_event;
281   gint16 in;
282 };
283
284 struct _GdkEventConfigure
285 {
286   GdkEventType type;
287   GdkWindow *window;
288   gint8 send_event;
289   gint16 x, y;
290   gint16 width;
291   gint16 height;
292 };
293
294 struct _GdkEventProperty
295 {
296   GdkEventType type;
297   GdkWindow *window;
298   gint8 send_event;
299   GdkAtom atom;
300   guint32 time;
301   guint state;
302 };
303
304 struct _GdkEventSelection
305 {
306   GdkEventType type;
307   GdkWindow *window;
308   gint8 send_event;
309   GdkAtom selection;
310   GdkAtom target;
311   GdkAtom property;
312   guint32 requestor;
313   guint32 time;
314 };
315
316 /* This event type will be used pretty rarely. It only is important
317    for XInput aware programs that are drawing their own cursor */
318
319 struct _GdkEventProximity
320 {
321   GdkEventType type;
322   GdkWindow *window;
323   gint8 send_event;
324   guint32 time;
325   GdkInputSource source;
326   guint32 deviceid;
327 };
328
329 struct _GdkEventClient
330 {
331   GdkEventType type;
332   GdkWindow *window;
333   gint8 send_event;
334   GdkAtom message_type;
335   gushort data_format;
336   union {
337     char b[20];
338     short s[10];
339     long l[5];
340   } data;
341 };
342
343 /* Event types for DND */
344
345 struct _GdkEventDND {
346   GdkEventType type;
347   GdkWindow *window;
348   gint8 send_event;
349   GdkDragContext *context;
350
351   guint32 time;
352   gshort x_root, y_root;
353 };
354
355 union _GdkEvent
356 {
357   GdkEventType              type;
358   GdkEventAny               any;
359   GdkEventExpose            expose;
360   GdkEventNoExpose          no_expose;
361   GdkEventVisibility        visibility;
362   GdkEventMotion            motion;
363   GdkEventButton            button;
364   GdkEventKey               key;
365   GdkEventCrossing          crossing;
366   GdkEventFocus             focus_change;
367   GdkEventConfigure         configure;
368   GdkEventProperty          property;
369   GdkEventSelection         selection;
370   GdkEventProximity         proximity;
371   GdkEventClient            client;
372   GdkEventDND               dnd;
373 };
374
375 gboolean  gdk_events_pending            (void);
376 GdkEvent* gdk_event_get                 (void);
377
378 GdkEvent* gdk_event_peek                (void);
379 GdkEvent* gdk_event_get_graphics_expose (GdkWindow      *window);
380 void      gdk_event_put                 (GdkEvent       *event);
381
382 GdkEvent* gdk_event_copy                (GdkEvent       *event);
383 void      gdk_event_free                (GdkEvent       *event);
384 guint32   gdk_event_get_time            (GdkEvent       *event);
385
386 void      gdk_event_handler_set         (GdkEventFunc    func,
387                                          gpointer        data,
388                                          GDestroyNotify  notify);
389
390 void      gdk_set_show_events           (gint            show_events);
391 gint      gdk_get_show_events           (void);
392
393 /*
394  * The following function adds a global filter for all client
395  * messages of type message_type
396  */
397 void gdk_add_client_message_filter (GdkAtom       message_type,
398                                     GdkFilterFunc func,
399                                     gpointer      data);
400
401
402 #ifdef __cplusplus
403 }
404 #endif /* __cplusplus */
405
406 #endif /* __GDK_EVENTS_H__ */