]> Pileus Git - ~andy/gtk/blob - gdk/gdkevents.h
Add gdk_screen_set_screen()/_get_screen() which (by evil hacks) work for
[~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   /* XXX: does anyone need the X major_code or minor_code fields? */
241 };
242
243 struct _GdkEventVisibility
244 {
245   GdkEventType type;
246   GdkWindow *window;
247   gint8 send_event;
248   GdkVisibilityState state;
249 };
250
251 struct _GdkEventMotion
252 {
253   GdkEventType type;
254   GdkWindow *window;
255   gint8 send_event;
256   guint32 time;
257   gdouble x;
258   gdouble y;
259   gdouble *axes;
260   guint state;
261   gint16 is_hint;
262   GdkDevice *device;
263   gdouble x_root, y_root;
264 };
265
266 struct _GdkEventButton
267 {
268   GdkEventType type;
269   GdkWindow *window;
270   gint8 send_event;
271   guint32 time;
272   gdouble x;
273   gdouble y;
274   gdouble *axes;
275   guint state;
276   guint button;
277   GdkDevice *device;
278   gdouble x_root, y_root;
279 };
280
281 struct _GdkEventScroll
282 {
283   GdkEventType type;
284   GdkWindow *window;
285   gint8 send_event;
286   guint32 time;
287   gdouble x;
288   gdouble y;
289   guint state;
290   GdkScrollDirection direction;
291   GdkDevice *device;
292   gdouble x_root, y_root;
293 };
294
295 struct _GdkEventKey
296 {
297   GdkEventType type;
298   GdkWindow *window;
299   gint8 send_event;
300   guint32 time;
301   guint state;
302   guint keyval;
303   gint length;
304   gchar *string;
305   guint16 hardware_keycode;
306   guint8 group;
307 };
308
309 struct _GdkEventCrossing
310 {
311   GdkEventType type;
312   GdkWindow *window;
313   gint8 send_event;
314   GdkWindow *subwindow;
315   guint32 time;
316   gdouble x;
317   gdouble y;
318   gdouble x_root;
319   gdouble y_root;
320   GdkCrossingMode mode;
321   GdkNotifyType detail;
322   gboolean focus;
323   guint state;
324 };
325
326 struct _GdkEventFocus
327 {
328   GdkEventType type;
329   GdkWindow *window;
330   gint8 send_event;
331   gint16 in;
332 };
333
334 struct _GdkEventConfigure
335 {
336   GdkEventType type;
337   GdkWindow *window;
338   gint8 send_event;
339   gint x, y;
340   gint width;
341   gint height;
342 };
343
344 struct _GdkEventProperty
345 {
346   GdkEventType type;
347   GdkWindow *window;
348   gint8 send_event;
349   GdkAtom atom;
350   guint32 time;
351   guint state;
352 };
353
354 struct _GdkEventSelection
355 {
356   GdkEventType type;
357   GdkWindow *window;
358   gint8 send_event;
359   GdkAtom selection;
360   GdkAtom target;
361   GdkAtom property;
362   guint32 time;
363   GdkNativeWindow requestor;
364 };
365
366 /* This event type will be used pretty rarely. It only is important
367    for XInput aware programs that are drawing their own cursor */
368
369 struct _GdkEventProximity
370 {
371   GdkEventType type;
372   GdkWindow *window;
373   gint8 send_event;
374   guint32 time;
375   GdkDevice *device;
376 };
377
378 struct _GdkEventClient
379 {
380   GdkEventType type;
381   GdkWindow *window;
382   gint8 send_event;
383   GdkAtom message_type;
384   gushort data_format;
385   union {
386     char b[20];
387     short s[10];
388     long l[5];
389   } data;
390 };
391
392 struct _GdkEventSetting
393 {
394   GdkEventType type;
395   GdkWindow *window;
396   gint8 send_event;
397   GdkSettingAction action;
398   char *name;
399 };
400
401 struct _GdkEventWindowState
402 {
403   GdkEventType type;
404   GdkWindow *window;
405   gint8 send_event;
406   GdkWindowState changed_mask;
407   GdkWindowState new_window_state;
408 };
409
410 /* Event types for DND */
411
412 struct _GdkEventDND {
413   GdkEventType type;
414   GdkWindow *window;
415   gint8 send_event;
416   GdkDragContext *context;
417
418   guint32 time;
419   gshort x_root, y_root;
420 };
421
422 union _GdkEvent
423 {
424   GdkEventType              type;
425   GdkEventAny               any;
426   GdkEventExpose            expose;
427   GdkEventNoExpose          no_expose;
428   GdkEventVisibility        visibility;
429   GdkEventMotion            motion;
430   GdkEventButton            button;
431   GdkEventScroll            scroll;
432   GdkEventKey               key;
433   GdkEventCrossing          crossing;
434   GdkEventFocus             focus_change;
435   GdkEventConfigure         configure;
436   GdkEventProperty          property;
437   GdkEventSelection         selection;
438   GdkEventProximity         proximity;
439   GdkEventClient            client;
440   GdkEventDND               dnd;
441   GdkEventWindowState       window_state;
442   GdkEventSetting           setting;
443 };
444
445 GType     gdk_event_get_type            (void);
446
447 gboolean  gdk_events_pending            (void);
448 GdkEvent* gdk_event_get                 (void);
449
450 GdkEvent* gdk_event_peek                (void);
451 GdkEvent* gdk_event_get_graphics_expose (GdkWindow      *window);
452 void      gdk_event_put                 (GdkEvent       *event);
453
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__ */