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