]> Pileus Git - ~andy/gtk/blob - gdk/gdkevents.h
f49b156ecdb39b9fdc9d0d726a646b21461197d1
[~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   guint16 hardware_keycode;
283   guint8 group;
284 };
285
286 struct _GdkEventCrossing
287 {
288   GdkEventType type;
289   GdkWindow *window;
290   gint8 send_event;
291   GdkWindow *subwindow;
292   guint32 time;
293   gdouble x;
294   gdouble y;
295   gdouble x_root;
296   gdouble y_root;
297   GdkCrossingMode mode;
298   GdkNotifyType detail;
299   gboolean focus;
300   guint state;
301 };
302
303 struct _GdkEventFocus
304 {
305   GdkEventType type;
306   GdkWindow *window;
307   gint8 send_event;
308   gint16 in;
309 };
310
311 struct _GdkEventConfigure
312 {
313   GdkEventType type;
314   GdkWindow *window;
315   gint8 send_event;
316   gint x, y;
317   gint width;
318   gint height;
319 };
320
321 struct _GdkEventProperty
322 {
323   GdkEventType type;
324   GdkWindow *window;
325   gint8 send_event;
326   GdkAtom atom;
327   guint32 time;
328   guint state;
329 };
330
331 struct _GdkEventSelection
332 {
333   GdkEventType type;
334   GdkWindow *window;
335   gint8 send_event;
336   GdkAtom selection;
337   GdkAtom target;
338   GdkAtom property;
339   guint32 time;
340   GdkNativeWindow requestor;
341 };
342
343 /* This event type will be used pretty rarely. It only is important
344    for XInput aware programs that are drawing their own cursor */
345
346 struct _GdkEventProximity
347 {
348   GdkEventType type;
349   GdkWindow *window;
350   gint8 send_event;
351   guint32 time;
352   GdkDevice *device;
353 };
354
355 struct _GdkEventClient
356 {
357   GdkEventType type;
358   GdkWindow *window;
359   gint8 send_event;
360   GdkAtom message_type;
361   gushort data_format;
362   union {
363     char b[20];
364     short s[10];
365     long l[5];
366   } data;
367 };
368
369 /* Event types for DND */
370
371 struct _GdkEventDND {
372   GdkEventType type;
373   GdkWindow *window;
374   gint8 send_event;
375   GdkDragContext *context;
376
377   guint32 time;
378   gshort x_root, y_root;
379 };
380
381 union _GdkEvent
382 {
383   GdkEventType              type;
384   GdkEventAny               any;
385   GdkEventExpose            expose;
386   GdkEventNoExpose          no_expose;
387   GdkEventVisibility        visibility;
388   GdkEventMotion            motion;
389   GdkEventButton            button;
390   GdkEventScroll            scroll;
391   GdkEventKey               key;
392   GdkEventCrossing          crossing;
393   GdkEventFocus             focus_change;
394   GdkEventConfigure         configure;
395   GdkEventProperty          property;
396   GdkEventSelection         selection;
397   GdkEventProximity         proximity;
398   GdkEventClient            client;
399   GdkEventDND               dnd;
400 };
401
402 gboolean  gdk_events_pending            (void);
403 GdkEvent* gdk_event_get                 (void);
404
405 GdkEvent* gdk_event_peek                (void);
406 GdkEvent* gdk_event_get_graphics_expose (GdkWindow      *window);
407 void      gdk_event_put                 (GdkEvent       *event);
408
409 GdkEvent* gdk_event_copy                (GdkEvent       *event);
410 void      gdk_event_free                (GdkEvent       *event);
411
412 guint32   gdk_event_get_time            (GdkEvent        *event);
413 gboolean  gdk_event_get_state           (GdkEvent        *event,
414                                          GdkModifierType *state);
415 gboolean  gdk_event_get_axis            (GdkEvent        *event,
416                                          GdkAxisUse       axis_use,
417                                          gdouble         *value);
418
419 void      gdk_event_handler_set         (GdkEventFunc    func,
420                                          gpointer        data,
421                                          GDestroyNotify  notify);
422
423 void      gdk_set_show_events           (gboolean        show_events);
424 gboolean  gdk_get_show_events           (void);
425
426 /*
427  * The following function adds a global filter for all client
428  * messages of type message_type
429  */
430 void gdk_add_client_message_filter (GdkAtom       message_type,
431                                     GdkFilterFunc func,
432                                     gpointer      data);
433
434
435 #ifdef __cplusplus
436 }
437 #endif /* __cplusplus */
438
439 #endif /* __GDK_EVENTS_H__ */