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