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