]> Pileus Git - ~andy/gtk/blob - gdk/gdkevents.h
Move documentation to inline comments: GdkWindow
[~andy/gtk] / gdk / gdkevents.h
1 /* GDK - The GIMP Drawing Kit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 /*
21  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
22  * file for a list of people on the GTK+ Team.  See the ChangeLog
23  * files for a list of changes.  These files are distributed with
24  * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
25  */
26
27 #if !defined (__GDK_H_INSIDE__) && !defined (GDK_COMPILATION)
28 #error "Only <gdk/gdk.h> can be included directly."
29 #endif
30
31 #ifndef __GDK_EVENTS_H__
32 #define __GDK_EVENTS_H__
33
34 #include <gdk/gdkcolor.h>
35 #include <gdk/gdktypes.h>
36 #include <gdk/gdkdnd.h>
37 #include <gdk/gdkinput.h>
38
39 G_BEGIN_DECLS
40
41 #define GDK_TYPE_EVENT          (gdk_event_get_type ())
42
43 #define GDK_PRIORITY_EVENTS     (G_PRIORITY_DEFAULT)
44 #define GDK_PRIORITY_REDRAW     (G_PRIORITY_HIGH_IDLE + 20)
45
46
47 typedef struct _GdkEventAny         GdkEventAny;
48 typedef struct _GdkEventExpose      GdkEventExpose;
49 typedef struct _GdkEventNoExpose    GdkEventNoExpose;
50 typedef struct _GdkEventVisibility  GdkEventVisibility;
51 typedef struct _GdkEventMotion      GdkEventMotion;
52 typedef struct _GdkEventButton      GdkEventButton;
53 typedef struct _GdkEventScroll      GdkEventScroll;  
54 typedef struct _GdkEventKey         GdkEventKey;
55 typedef struct _GdkEventFocus       GdkEventFocus;
56 typedef struct _GdkEventCrossing    GdkEventCrossing;
57 typedef struct _GdkEventConfigure   GdkEventConfigure;
58 typedef struct _GdkEventProperty    GdkEventProperty;
59 typedef struct _GdkEventSelection   GdkEventSelection;
60 typedef struct _GdkEventOwnerChange GdkEventOwnerChange;
61 typedef struct _GdkEventProximity   GdkEventProximity;
62 typedef struct _GdkEventClient      GdkEventClient;
63 typedef struct _GdkEventDND         GdkEventDND;
64 typedef struct _GdkEventWindowState GdkEventWindowState;
65 typedef struct _GdkEventSetting     GdkEventSetting;
66 typedef struct _GdkEventGrabBroken  GdkEventGrabBroken;
67
68 typedef union  _GdkEvent            GdkEvent;
69
70 typedef void (*GdkEventFunc) (GdkEvent *event,
71                               gpointer  data);
72
73 /* Event filtering */
74
75 /**
76  * GdkXEvent:
77  *
78  * Used to represent native events (<type>XEvent</type>s for the X11
79  * backend, <type>MSG</type>s for Win32).
80  */
81 typedef void GdkXEvent;   /* Can be cast to window system specific
82                            * even type, XEvent on X11, MSG on Win32.
83                            */
84
85 /**
86  * GdkFilterReturn:
87  * @GDK_FILTER_CONTINUE: event not handled, continue processing.
88  * @GDK_FILTER_TRANSLATE: native event translated into a GDK event and stored
89  *  in the <literal>event</literal> structure that was passed in.
90  * @GDK_FILTER_REMOVE: event handled, terminate processing.
91  *
92  * Specifies the result of applying a #GdkFilterFunc to a native event.
93  */
94 typedef enum {
95   GDK_FILTER_CONTINUE,    /* Event not handled, continue processesing */
96   GDK_FILTER_TRANSLATE,   /* Native event translated into a GDK event and
97                              stored in the "event" structure that was
98                              passed in */
99   GDK_FILTER_REMOVE       /* Terminate processing, removing event */
100 } GdkFilterReturn;
101
102 /**
103  * GdkFilterFunc:
104  * @xevent: the native event to filter.
105  * @event: the GDK event to which the X event will be translated.
106  * @data: user data set when the filter was installed.
107  *
108  * Specifies the type of function used to filter native events before they are
109  * converted to GDK events.
110  *
111  * When a filter is called, @event is unpopulated, except for
112  * <literal>event->window</literal>. The filter may translate the native
113  * event to a GDK event and store the result in @event, or handle it without
114  * translation. If the filter translates the event and processing should
115  * continue, it should return %GDK_FILTER_TRANSLATE.
116  *
117  * Returns: a #GdkFilterReturn value.
118  */
119 typedef GdkFilterReturn (*GdkFilterFunc) (GdkXEvent *xevent,
120                                           GdkEvent *event,
121                                           gpointer  data);
122
123
124 /* Event types.
125  *   Nothing: No event occurred.
126  *   Delete: A window delete event was sent by the window manager.
127  *           The specified window should be deleted.
128  *   Destroy: A window has been destroyed.
129  *   Expose: Part of a window has been uncovered.
130  *   NoExpose: Same as expose, but no expose event was generated.
131  *   VisibilityNotify: A window has become fully/partially/not obscured.
132  *   MotionNotify: The mouse has moved.
133  *   ButtonPress: A mouse button was pressed.
134  *   ButtonRelease: A mouse button was release.
135  *   KeyPress: A key was pressed.
136  *   KeyRelease: A key was released.
137  *   EnterNotify: A window was entered.
138  *   LeaveNotify: A window was exited.
139  *   FocusChange: The focus window has changed. (The focus window gets
140  *                keyboard events).
141  *   Resize: A window has been resized.
142  *   Map: A window has been mapped. (It is now visible on the screen).
143  *   Unmap: A window has been unmapped. (It is no longer visible on
144  *          the screen).
145  *   Scroll: A mouse wheel was scrolled either up or down.
146  */
147 typedef enum
148 {
149   GDK_NOTHING           = -1,
150   GDK_DELETE            = 0,
151   GDK_DESTROY           = 1,
152   GDK_EXPOSE            = 2,
153   GDK_MOTION_NOTIFY     = 3,
154   GDK_BUTTON_PRESS      = 4,
155   GDK_2BUTTON_PRESS     = 5,
156   GDK_3BUTTON_PRESS     = 6,
157   GDK_BUTTON_RELEASE    = 7,
158   GDK_KEY_PRESS         = 8,
159   GDK_KEY_RELEASE       = 9,
160   GDK_ENTER_NOTIFY      = 10,
161   GDK_LEAVE_NOTIFY      = 11,
162   GDK_FOCUS_CHANGE      = 12,
163   GDK_CONFIGURE         = 13,
164   GDK_MAP               = 14,
165   GDK_UNMAP             = 15,
166   GDK_PROPERTY_NOTIFY   = 16,
167   GDK_SELECTION_CLEAR   = 17,
168   GDK_SELECTION_REQUEST = 18,
169   GDK_SELECTION_NOTIFY  = 19,
170   GDK_PROXIMITY_IN      = 20,
171   GDK_PROXIMITY_OUT     = 21,
172   GDK_DRAG_ENTER        = 22,
173   GDK_DRAG_LEAVE        = 23,
174   GDK_DRAG_MOTION       = 24,
175   GDK_DRAG_STATUS       = 25,
176   GDK_DROP_START        = 26,
177   GDK_DROP_FINISHED     = 27,
178   GDK_CLIENT_EVENT      = 28,
179   GDK_VISIBILITY_NOTIFY = 29,
180   GDK_NO_EXPOSE         = 30,
181   GDK_SCROLL            = 31,
182   GDK_WINDOW_STATE      = 32,
183   GDK_SETTING           = 33,
184   GDK_OWNER_CHANGE      = 34,
185   GDK_GRAB_BROKEN       = 35,
186   GDK_DAMAGE            = 36,
187   GDK_EVENT_LAST        /* helper variable for decls */
188 } GdkEventType;
189
190 /* Event masks. (Used to select what types of events a window
191  *  will receive).
192  */
193 typedef enum
194 {
195   GDK_EXPOSURE_MASK             = 1 << 1,
196   GDK_POINTER_MOTION_MASK       = 1 << 2,
197   GDK_POINTER_MOTION_HINT_MASK  = 1 << 3,
198   GDK_BUTTON_MOTION_MASK        = 1 << 4,
199   GDK_BUTTON1_MOTION_MASK       = 1 << 5,
200   GDK_BUTTON2_MOTION_MASK       = 1 << 6,
201   GDK_BUTTON3_MOTION_MASK       = 1 << 7,
202   GDK_BUTTON_PRESS_MASK         = 1 << 8,
203   GDK_BUTTON_RELEASE_MASK       = 1 << 9,
204   GDK_KEY_PRESS_MASK            = 1 << 10,
205   GDK_KEY_RELEASE_MASK          = 1 << 11,
206   GDK_ENTER_NOTIFY_MASK         = 1 << 12,
207   GDK_LEAVE_NOTIFY_MASK         = 1 << 13,
208   GDK_FOCUS_CHANGE_MASK         = 1 << 14,
209   GDK_STRUCTURE_MASK            = 1 << 15,
210   GDK_PROPERTY_CHANGE_MASK      = 1 << 16,
211   GDK_VISIBILITY_NOTIFY_MASK    = 1 << 17,
212   GDK_PROXIMITY_IN_MASK         = 1 << 18,
213   GDK_PROXIMITY_OUT_MASK        = 1 << 19,
214   GDK_SUBSTRUCTURE_MASK         = 1 << 20,
215   GDK_SCROLL_MASK               = 1 << 21,
216   GDK_ALL_EVENTS_MASK           = 0x3FFFFE
217 } GdkEventMask;
218
219 typedef enum
220 {
221   GDK_VISIBILITY_UNOBSCURED,
222   GDK_VISIBILITY_PARTIAL,
223   GDK_VISIBILITY_FULLY_OBSCURED
224 } GdkVisibilityState;
225
226 typedef enum
227 {
228   GDK_SCROLL_UP,
229   GDK_SCROLL_DOWN,
230   GDK_SCROLL_LEFT,
231   GDK_SCROLL_RIGHT
232 } GdkScrollDirection;
233
234 /* Types of enter/leave notifications.
235  *   Ancestor:
236  *   Virtual:
237  *   Inferior:
238  *   Nonlinear:
239  *   NonlinearVirtual:
240  *   Unknown: An unknown type of enter/leave event occurred.
241  */
242 typedef enum
243 {
244   GDK_NOTIFY_ANCESTOR           = 0,
245   GDK_NOTIFY_VIRTUAL            = 1,
246   GDK_NOTIFY_INFERIOR           = 2,
247   GDK_NOTIFY_NONLINEAR          = 3,
248   GDK_NOTIFY_NONLINEAR_VIRTUAL  = 4,
249   GDK_NOTIFY_UNKNOWN            = 5
250 } GdkNotifyType;
251
252 /* Enter/leave event modes.
253  *   NotifyNormal
254  *   NotifyGrab
255  *   NotifyUngrab
256  */
257 typedef enum
258 {
259   GDK_CROSSING_NORMAL,
260   GDK_CROSSING_GRAB,
261   GDK_CROSSING_UNGRAB,
262   GDK_CROSSING_GTK_GRAB,
263   GDK_CROSSING_GTK_UNGRAB,
264   GDK_CROSSING_STATE_CHANGED
265 } GdkCrossingMode;
266
267 typedef enum
268 {
269   GDK_PROPERTY_NEW_VALUE,
270   GDK_PROPERTY_DELETE
271 } GdkPropertyState;
272
273 typedef enum
274 {
275   GDK_WINDOW_STATE_WITHDRAWN  = 1 << 0,
276   GDK_WINDOW_STATE_ICONIFIED  = 1 << 1,
277   GDK_WINDOW_STATE_MAXIMIZED  = 1 << 2,
278   GDK_WINDOW_STATE_STICKY     = 1 << 3,
279   GDK_WINDOW_STATE_FULLSCREEN = 1 << 4,
280   GDK_WINDOW_STATE_ABOVE      = 1 << 5,
281   GDK_WINDOW_STATE_BELOW      = 1 << 6
282 } GdkWindowState;
283
284 typedef enum
285 {
286   GDK_SETTING_ACTION_NEW,
287   GDK_SETTING_ACTION_CHANGED,
288   GDK_SETTING_ACTION_DELETED
289 } GdkSettingAction;
290
291 typedef enum
292 {
293   GDK_OWNER_CHANGE_NEW_OWNER,
294   GDK_OWNER_CHANGE_DESTROY,
295   GDK_OWNER_CHANGE_CLOSE
296 } GdkOwnerChange;
297
298 struct _GdkEventAny
299 {
300   GdkEventType type;
301   GdkWindow *window;
302   gint8 send_event;
303 };
304
305 struct _GdkEventExpose
306 {
307   GdkEventType type;
308   GdkWindow *window;
309   gint8 send_event;
310   GdkRectangle area;
311   GdkRegion *region;
312   gint count; /* If non-zero, how many more events follow. */
313 };
314
315 struct _GdkEventNoExpose
316 {
317   GdkEventType type;
318   GdkWindow *window;
319   gint8 send_event;
320 };
321
322 struct _GdkEventVisibility
323 {
324   GdkEventType type;
325   GdkWindow *window;
326   gint8 send_event;
327   GdkVisibilityState state;
328 };
329
330 struct _GdkEventMotion
331 {
332   GdkEventType type;
333   GdkWindow *window;
334   gint8 send_event;
335   guint32 time;
336   gdouble x;
337   gdouble y;
338   gdouble *axes;
339   guint state;
340   gint16 is_hint;
341   GdkDevice *device;
342   gdouble x_root, y_root;
343 };
344
345 struct _GdkEventButton
346 {
347   GdkEventType type;
348   GdkWindow *window;
349   gint8 send_event;
350   guint32 time;
351   gdouble x;
352   gdouble y;
353   gdouble *axes;
354   guint state;
355   guint button;
356   GdkDevice *device;
357   gdouble x_root, y_root;
358 };
359
360 struct _GdkEventScroll
361 {
362   GdkEventType type;
363   GdkWindow *window;
364   gint8 send_event;
365   guint32 time;
366   gdouble x;
367   gdouble y;
368   guint state;
369   GdkScrollDirection direction;
370   GdkDevice *device;
371   gdouble x_root, y_root;
372 };
373
374 struct _GdkEventKey
375 {
376   GdkEventType type;
377   GdkWindow *window;
378   gint8 send_event;
379   guint32 time;
380   guint state;
381   guint keyval;
382   gint length;
383   gchar *string;
384   guint16 hardware_keycode;
385   guint8 group;
386   guint is_modifier : 1;
387 };
388
389 struct _GdkEventCrossing
390 {
391   GdkEventType type;
392   GdkWindow *window;
393   gint8 send_event;
394   GdkWindow *subwindow;
395   guint32 time;
396   gdouble x;
397   gdouble y;
398   gdouble x_root;
399   gdouble y_root;
400   GdkCrossingMode mode;
401   GdkNotifyType detail;
402   gboolean focus;
403   guint state;
404 };
405
406 struct _GdkEventFocus
407 {
408   GdkEventType type;
409   GdkWindow *window;
410   gint8 send_event;
411   gint16 in;
412 };
413
414 struct _GdkEventConfigure
415 {
416   GdkEventType type;
417   GdkWindow *window;
418   gint8 send_event;
419   gint x, y;
420   gint width;
421   gint height;
422 };
423
424 struct _GdkEventProperty
425 {
426   GdkEventType type;
427   GdkWindow *window;
428   gint8 send_event;
429   GdkAtom atom;
430   guint32 time;
431   guint state;
432 };
433
434 struct _GdkEventSelection
435 {
436   GdkEventType type;
437   GdkWindow *window;
438   gint8 send_event;
439   GdkAtom selection;
440   GdkAtom target;
441   GdkAtom property;
442   guint32 time;
443   GdkNativeWindow requestor;
444 };
445
446 struct _GdkEventOwnerChange
447 {
448   GdkEventType type;
449   GdkWindow *window;
450   gint8 send_event;
451   GdkNativeWindow owner;
452   GdkOwnerChange reason;
453   GdkAtom selection;
454   guint32 time;
455   guint32 selection_time;
456 };
457
458 /* This event type will be used pretty rarely. It only is important
459    for XInput aware programs that are drawing their own cursor */
460
461 struct _GdkEventProximity
462 {
463   GdkEventType type;
464   GdkWindow *window;
465   gint8 send_event;
466   guint32 time;
467   GdkDevice *device;
468 };
469
470 struct _GdkEventClient
471 {
472   GdkEventType type;
473   GdkWindow *window;
474   gint8 send_event;
475   GdkAtom message_type;
476   gushort data_format;
477   union {
478     char b[20];
479     short s[10];
480     long l[5];
481   } data;
482 };
483
484 struct _GdkEventSetting
485 {
486   GdkEventType type;
487   GdkWindow *window;
488   gint8 send_event;
489   GdkSettingAction action;
490   char *name;
491 };
492
493 struct _GdkEventWindowState
494 {
495   GdkEventType type;
496   GdkWindow *window;
497   gint8 send_event;
498   GdkWindowState changed_mask;
499   GdkWindowState new_window_state;
500 };
501
502 struct _GdkEventGrabBroken {
503   GdkEventType type;
504   GdkWindow *window;
505   gint8 send_event;
506   gboolean keyboard;
507   gboolean implicit;
508   GdkWindow *grab_window;
509 };
510
511 /* Event types for DND */
512
513 struct _GdkEventDND {
514   GdkEventType type;
515   GdkWindow *window;
516   gint8 send_event;
517   GdkDragContext *context;
518
519   guint32 time;
520   gshort x_root, y_root;
521 };
522
523 union _GdkEvent
524 {
525   GdkEventType              type;
526   GdkEventAny               any;
527   GdkEventExpose            expose;
528   GdkEventNoExpose          no_expose;
529   GdkEventVisibility        visibility;
530   GdkEventMotion            motion;
531   GdkEventButton            button;
532   GdkEventScroll            scroll;
533   GdkEventKey               key;
534   GdkEventCrossing          crossing;
535   GdkEventFocus             focus_change;
536   GdkEventConfigure         configure;
537   GdkEventProperty          property;
538   GdkEventSelection         selection;
539   GdkEventOwnerChange       owner_change;
540   GdkEventProximity         proximity;
541   GdkEventClient            client;
542   GdkEventDND               dnd;
543   GdkEventWindowState       window_state;
544   GdkEventSetting           setting;
545   GdkEventGrabBroken        grab_broken;
546 };
547
548 GType     gdk_event_get_type            (void) G_GNUC_CONST;
549
550 gboolean  gdk_events_pending            (void);
551 GdkEvent* gdk_event_get                 (void);
552
553 GdkEvent* gdk_event_peek                (void);
554 void      gdk_event_put                 (const GdkEvent *event);
555
556 GdkEvent* gdk_event_new                 (GdkEventType    type);
557 GdkEvent* gdk_event_copy                (const GdkEvent *event);
558 void      gdk_event_free                (GdkEvent       *event);
559
560 guint32   gdk_event_get_time            (const GdkEvent  *event);
561 gboolean  gdk_event_get_state           (const GdkEvent  *event,
562                                          GdkModifierType *state);
563 gboolean  gdk_event_get_coords          (const GdkEvent  *event,
564                                          gdouble         *x_win,
565                                          gdouble         *y_win);
566 gboolean  gdk_event_get_root_coords     (const GdkEvent  *event,
567                                          gdouble         *x_root,
568                                          gdouble         *y_root);
569 gboolean  gdk_event_get_axis            (const GdkEvent  *event,
570                                          GdkAxisUse       axis_use,
571                                          gdouble         *value);
572 void      gdk_event_request_motions     (const GdkEventMotion *event);
573 void      gdk_event_handler_set         (GdkEventFunc    func,
574                                          gpointer        data,
575                                          GDestroyNotify  notify);
576
577 void       gdk_event_set_screen         (GdkEvent        *event,
578                                          GdkScreen       *screen);
579 GdkScreen *gdk_event_get_screen         (const GdkEvent  *event);
580
581 void      gdk_set_show_events           (gboolean        show_events);
582 gboolean  gdk_get_show_events           (void);
583
584 #ifndef GDK_MULTIHEAD_SAFE
585 void gdk_add_client_message_filter (GdkAtom       message_type,
586                                     GdkFilterFunc func,
587                                     gpointer      data);
588
589 gboolean gdk_setting_get (const gchar *name,
590                           GValue      *value); 
591 #endif /* GDK_MULTIHEAD_SAFE */
592
593 G_END_DECLS
594
595 #endif /* __GDK_EVENTS_H__ */