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