]> Pileus Git - ~andy/gtk/blob - gdk/gdkevents.h
Add support for EWMH "Above" and "Below" window states. (105100, Manuel Clos)
[~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,   /* 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 } GdkEventType;
123
124 /* Event masks. (Used to select what types of events a window
125  *  will receive).
126  */
127 typedef enum
128 {
129   GDK_EXPOSURE_MASK             = 1 << 1,
130   GDK_POINTER_MOTION_MASK       = 1 << 2,
131   GDK_POINTER_MOTION_HINT_MASK  = 1 << 3,
132   GDK_BUTTON_MOTION_MASK        = 1 << 4,
133   GDK_BUTTON1_MOTION_MASK       = 1 << 5,
134   GDK_BUTTON2_MOTION_MASK       = 1 << 6,
135   GDK_BUTTON3_MOTION_MASK       = 1 << 7,
136   GDK_BUTTON_PRESS_MASK         = 1 << 8,
137   GDK_BUTTON_RELEASE_MASK       = 1 << 9,
138   GDK_KEY_PRESS_MASK            = 1 << 10,
139   GDK_KEY_RELEASE_MASK          = 1 << 11,
140   GDK_ENTER_NOTIFY_MASK         = 1 << 12,
141   GDK_LEAVE_NOTIFY_MASK         = 1 << 13,
142   GDK_FOCUS_CHANGE_MASK         = 1 << 14,
143   GDK_STRUCTURE_MASK            = 1 << 15,
144   GDK_PROPERTY_CHANGE_MASK      = 1 << 16,
145   GDK_VISIBILITY_NOTIFY_MASK    = 1 << 17,
146   GDK_PROXIMITY_IN_MASK         = 1 << 18,
147   GDK_PROXIMITY_OUT_MASK        = 1 << 19,
148   GDK_SUBSTRUCTURE_MASK         = 1 << 20,
149   GDK_SCROLL_MASK               = 1 << 21,
150   GDK_ALL_EVENTS_MASK           = 0x3FFFFE
151 } GdkEventMask;
152
153 typedef enum
154 {
155   GDK_VISIBILITY_UNOBSCURED,
156   GDK_VISIBILITY_PARTIAL,
157   GDK_VISIBILITY_FULLY_OBSCURED
158 } GdkVisibilityState;
159
160 typedef enum
161 {
162   GDK_SCROLL_UP,
163   GDK_SCROLL_DOWN,
164   GDK_SCROLL_LEFT,
165   GDK_SCROLL_RIGHT
166 } GdkScrollDirection;
167
168 /* Types of enter/leave notifications.
169  *   Ancestor:
170  *   Virtual:
171  *   Inferior:
172  *   Nonlinear:
173  *   NonlinearVirtual:
174  *   Unknown: An unknown type of enter/leave event occurred.
175  */
176 typedef enum
177 {
178   GDK_NOTIFY_ANCESTOR           = 0,
179   GDK_NOTIFY_VIRTUAL            = 1,
180   GDK_NOTIFY_INFERIOR           = 2,
181   GDK_NOTIFY_NONLINEAR          = 3,
182   GDK_NOTIFY_NONLINEAR_VIRTUAL  = 4,
183   GDK_NOTIFY_UNKNOWN            = 5
184 } GdkNotifyType;
185
186 /* Enter/leave event modes.
187  *   NotifyNormal
188  *   NotifyGrab
189  *   NotifyUngrab
190  */
191 typedef enum
192 {
193   GDK_CROSSING_NORMAL,
194   GDK_CROSSING_GRAB,
195   GDK_CROSSING_UNGRAB
196 } GdkCrossingMode;
197
198 typedef enum
199 {
200   GDK_PROPERTY_NEW_VALUE,
201   GDK_PROPERTY_DELETE
202 } GdkPropertyState;
203
204 typedef enum
205 {
206   GDK_WINDOW_STATE_WITHDRAWN  = 1 << 0,
207   GDK_WINDOW_STATE_ICONIFIED  = 1 << 1,
208   GDK_WINDOW_STATE_MAXIMIZED  = 1 << 2,
209   GDK_WINDOW_STATE_STICKY     = 1 << 3,
210   GDK_WINDOW_STATE_FULLSCREEN = 1 << 4,
211   GDK_WINDOW_STATE_ABOVE      = 1 << 5,
212   GDK_WINDOW_STATE_BELOW      = 1 << 6
213 } GdkWindowState;
214
215 typedef enum
216 {
217   GDK_SETTING_ACTION_NEW,
218   GDK_SETTING_ACTION_CHANGED,
219   GDK_SETTING_ACTION_DELETED
220 } GdkSettingAction;
221
222 struct _GdkEventAny
223 {
224   GdkEventType type;
225   GdkWindow *window;
226   gint8 send_event;
227 };
228
229 struct _GdkEventExpose
230 {
231   GdkEventType type;
232   GdkWindow *window;
233   gint8 send_event;
234   GdkRectangle area;
235   GdkRegion *region;
236   gint count; /* If non-zero, how many more events follow. */
237 };
238
239 struct _GdkEventNoExpose
240 {
241   GdkEventType type;
242   GdkWindow *window;
243   gint8 send_event;
244 };
245
246 struct _GdkEventVisibility
247 {
248   GdkEventType type;
249   GdkWindow *window;
250   gint8 send_event;
251   GdkVisibilityState state;
252 };
253
254 struct _GdkEventMotion
255 {
256   GdkEventType type;
257   GdkWindow *window;
258   gint8 send_event;
259   guint32 time;
260   gdouble x;
261   gdouble y;
262   gdouble *axes;
263   guint state;
264   gint16 is_hint;
265   GdkDevice *device;
266   gdouble x_root, y_root;
267 };
268
269 struct _GdkEventButton
270 {
271   GdkEventType type;
272   GdkWindow *window;
273   gint8 send_event;
274   guint32 time;
275   gdouble x;
276   gdouble y;
277   gdouble *axes;
278   guint state;
279   guint button;
280   GdkDevice *device;
281   gdouble x_root, y_root;
282 };
283
284 struct _GdkEventScroll
285 {
286   GdkEventType type;
287   GdkWindow *window;
288   gint8 send_event;
289   guint32 time;
290   gdouble x;
291   gdouble y;
292   guint state;
293   GdkScrollDirection direction;
294   GdkDevice *device;
295   gdouble x_root, y_root;
296 };
297
298 struct _GdkEventKey
299 {
300   GdkEventType type;
301   GdkWindow *window;
302   gint8 send_event;
303   guint32 time;
304   guint state;
305   guint keyval;
306   gint length;
307   gchar *string;
308   guint16 hardware_keycode;
309   guint8 group;
310 };
311
312 struct _GdkEventCrossing
313 {
314   GdkEventType type;
315   GdkWindow *window;
316   gint8 send_event;
317   GdkWindow *subwindow;
318   guint32 time;
319   gdouble x;
320   gdouble y;
321   gdouble x_root;
322   gdouble y_root;
323   GdkCrossingMode mode;
324   GdkNotifyType detail;
325   gboolean focus;
326   guint state;
327 };
328
329 struct _GdkEventFocus
330 {
331   GdkEventType type;
332   GdkWindow *window;
333   gint8 send_event;
334   gint16 in;
335 };
336
337 struct _GdkEventConfigure
338 {
339   GdkEventType type;
340   GdkWindow *window;
341   gint8 send_event;
342   gint x, y;
343   gint width;
344   gint height;
345 };
346
347 struct _GdkEventProperty
348 {
349   GdkEventType type;
350   GdkWindow *window;
351   gint8 send_event;
352   GdkAtom atom;
353   guint32 time;
354   guint state;
355 };
356
357 struct _GdkEventSelection
358 {
359   GdkEventType type;
360   GdkWindow *window;
361   gint8 send_event;
362   GdkAtom selection;
363   GdkAtom target;
364   GdkAtom property;
365   guint32 time;
366   GdkNativeWindow requestor;
367 };
368
369 /* This event type will be used pretty rarely. It only is important
370    for XInput aware programs that are drawing their own cursor */
371
372 struct _GdkEventProximity
373 {
374   GdkEventType type;
375   GdkWindow *window;
376   gint8 send_event;
377   guint32 time;
378   GdkDevice *device;
379 };
380
381 struct _GdkEventClient
382 {
383   GdkEventType type;
384   GdkWindow *window;
385   gint8 send_event;
386   GdkAtom message_type;
387   gushort data_format;
388   union {
389     char b[20];
390     short s[10];
391     long l[5];
392   } data;
393 };
394
395 struct _GdkEventSetting
396 {
397   GdkEventType type;
398   GdkWindow *window;
399   gint8 send_event;
400   GdkSettingAction action;
401   char *name;
402 };
403
404 struct _GdkEventWindowState
405 {
406   GdkEventType type;
407   GdkWindow *window;
408   gint8 send_event;
409   GdkWindowState changed_mask;
410   GdkWindowState new_window_state;
411 };
412
413 /* Event types for DND */
414
415 struct _GdkEventDND {
416   GdkEventType type;
417   GdkWindow *window;
418   gint8 send_event;
419   GdkDragContext *context;
420
421   guint32 time;
422   gshort x_root, y_root;
423 };
424
425 union _GdkEvent
426 {
427   GdkEventType              type;
428   GdkEventAny               any;
429   GdkEventExpose            expose;
430   GdkEventNoExpose          no_expose;
431   GdkEventVisibility        visibility;
432   GdkEventMotion            motion;
433   GdkEventButton            button;
434   GdkEventScroll            scroll;
435   GdkEventKey               key;
436   GdkEventCrossing          crossing;
437   GdkEventFocus             focus_change;
438   GdkEventConfigure         configure;
439   GdkEventProperty          property;
440   GdkEventSelection         selection;
441   GdkEventProximity         proximity;
442   GdkEventClient            client;
443   GdkEventDND               dnd;
444   GdkEventWindowState       window_state;
445   GdkEventSetting           setting;
446 };
447
448 GType     gdk_event_get_type            (void);
449
450 gboolean  gdk_events_pending            (void);
451 GdkEvent* gdk_event_get                 (void);
452
453 GdkEvent* gdk_event_peek                (void);
454 GdkEvent* gdk_event_get_graphics_expose (GdkWindow      *window);
455 void      gdk_event_put                 (GdkEvent       *event);
456
457 GdkEvent* gdk_event_new                 (GdkEventType    type);
458 GdkEvent* gdk_event_copy                (GdkEvent       *event);
459 void      gdk_event_free                (GdkEvent       *event);
460
461 guint32   gdk_event_get_time            (GdkEvent        *event);
462 gboolean  gdk_event_get_state           (GdkEvent        *event,
463                                          GdkModifierType *state);
464 gboolean  gdk_event_get_coords          (GdkEvent        *event,
465                                          gdouble         *x_win,
466                                          gdouble         *y_win);
467 gboolean  gdk_event_get_root_coords     (GdkEvent        *event,
468                                          gdouble         *x_root,
469                                          gdouble         *y_root);
470 gboolean  gdk_event_get_axis            (GdkEvent        *event,
471                                          GdkAxisUse       axis_use,
472                                          gdouble         *value);
473 void      gdk_event_handler_set         (GdkEventFunc    func,
474                                          gpointer        data,
475                                          GDestroyNotify  notify);
476
477 void       gdk_event_set_screen (GdkEvent  *event,
478                                  GdkScreen *screen);
479 GdkScreen *gdk_event_get_screen (GdkEvent  *event);
480
481 void      gdk_set_show_events           (gboolean        show_events);
482 gboolean  gdk_get_show_events           (void);
483
484 #ifndef GDK_MULTIHEAD_SAFE
485 void gdk_add_client_message_filter (GdkAtom       message_type,
486                                     GdkFilterFunc func,
487                                     gpointer      data);
488
489 gboolean gdk_setting_get (const gchar *name,
490                           GValue      *value); 
491 #endif /* GDK_MULTIHEAD_SAFE */
492
493 #ifdef __cplusplus
494 }
495 #endif /* __cplusplus */
496
497 #endif /* __GDK_EVENTS_H__ */