]> Pileus Git - ~andy/gtk/blob - gdk/gdkevents.h
Add symbolic constants for event emission control
[~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/gdkdevice.h>
38
39 G_BEGIN_DECLS
40
41
42 /**
43  * SECTION:event_structs
44  * @Short_description: Data structures specific to each type of event
45  * @Title: Event Structures
46  *
47  * The event structs contain data specific to each type of event in GDK.
48  *
49  * <note>
50  * <para>
51  * A common mistake is to forget to set the event mask of a widget so that
52  * the required events are received. See gtk_widget_set_events().
53  * </para>
54  * </note>
55  */
56
57
58 #define GDK_TYPE_EVENT          (gdk_event_get_type ())
59
60 /**
61  * GDK_PRIORITY_EVENTS:
62  *
63  * This is the priority that events from the X server are given in the
64  * <link linkend="glib-The-Main-Event-Loop">GLib Main Loop</link>.
65  */
66 #define GDK_PRIORITY_EVENTS     (G_PRIORITY_DEFAULT)
67
68 /**
69  * GDK_PRIORITY_REDRAW:
70  *
71  * This is the priority that the idle handler processing window updates
72  * is given in the
73  * <link linkend="glib-The-Main-Event-Loop">GLib Main Loop</link>.
74  */
75 #define GDK_PRIORITY_REDRAW     (G_PRIORITY_HIGH_IDLE + 20)
76
77 /**
78  * GDK_EVENT_PROPAGATE:
79  *
80  * Use this macro as the return value for continuing the propagation of
81  * an event handler.
82  *
83  * Since: 3.4
84  */
85 #define GDK_EVENT_PROPAGATE     (FALSE)
86
87 /**
88  * GDK_EVENT_STOP:
89  *
90  * Use this macro as the return value for stopping the propagation of
91  * an event handler.
92  *
93  * Since: 3.4
94  */
95 #define GDK_EVENT_STOP          (TRUE)
96
97 typedef struct _GdkEventAny         GdkEventAny;
98 typedef struct _GdkEventExpose      GdkEventExpose;
99 typedef struct _GdkEventVisibility  GdkEventVisibility;
100 typedef struct _GdkEventMotion      GdkEventMotion;
101 typedef struct _GdkEventButton      GdkEventButton;
102 typedef struct _GdkEventScroll      GdkEventScroll;  
103 typedef struct _GdkEventKey         GdkEventKey;
104 typedef struct _GdkEventFocus       GdkEventFocus;
105 typedef struct _GdkEventCrossing    GdkEventCrossing;
106 typedef struct _GdkEventConfigure   GdkEventConfigure;
107 typedef struct _GdkEventProperty    GdkEventProperty;
108 typedef struct _GdkEventSelection   GdkEventSelection;
109 typedef struct _GdkEventOwnerChange GdkEventOwnerChange;
110 typedef struct _GdkEventProximity   GdkEventProximity;
111 typedef struct _GdkEventDND         GdkEventDND;
112 typedef struct _GdkEventWindowState GdkEventWindowState;
113 typedef struct _GdkEventSetting     GdkEventSetting;
114 typedef struct _GdkEventGrabBroken  GdkEventGrabBroken;
115
116 typedef union  _GdkEvent            GdkEvent;
117
118 /**
119  * GdkEventFunc:
120  * @event: the #GdkEvent to process.
121  * @data: (closure): user data set when the event handler was installed with
122  *   gdk_event_handler_set().
123  *
124  * Specifies the type of function passed to gdk_event_handler_set() to
125  * handle all GDK events.
126  */
127 typedef void (*GdkEventFunc) (GdkEvent *event,
128                               gpointer  data);
129
130 /* Event filtering */
131
132 /**
133  * GdkXEvent:
134  *
135  * Used to represent native events (<type>XEvent</type>s for the X11
136  * backend, <type>MSG</type>s for Win32).
137  */
138 typedef void GdkXEvent;   /* Can be cast to window system specific
139                            * even type, XEvent on X11, MSG on Win32.
140                            */
141
142 /**
143  * GdkFilterReturn:
144  * @GDK_FILTER_CONTINUE: event not handled, continue processing.
145  * @GDK_FILTER_TRANSLATE: native event translated into a GDK event and stored
146  *  in the <literal>event</literal> structure that was passed in.
147  * @GDK_FILTER_REMOVE: event handled, terminate processing.
148  *
149  * Specifies the result of applying a #GdkFilterFunc to a native event.
150  */
151 typedef enum {
152   GDK_FILTER_CONTINUE,    /* Event not handled, continue processesing */
153   GDK_FILTER_TRANSLATE,   /* Native event translated into a GDK event and
154                              stored in the "event" structure that was
155                              passed in */
156   GDK_FILTER_REMOVE       /* Terminate processing, removing event */
157 } GdkFilterReturn;
158
159 /**
160  * GdkFilterFunc:
161  * @xevent: the native event to filter.
162  * @event: the GDK event to which the X event will be translated.
163  * @data: user data set when the filter was installed.
164  *
165  * Specifies the type of function used to filter native events before they are
166  * converted to GDK events.
167  *
168  * When a filter is called, @event is unpopulated, except for
169  * <literal>event->window</literal>. The filter may translate the native
170  * event to a GDK event and store the result in @event, or handle it without
171  * translation. If the filter translates the event and processing should
172  * continue, it should return %GDK_FILTER_TRANSLATE.
173  *
174  * Returns: a #GdkFilterReturn value.
175  */
176 typedef GdkFilterReturn (*GdkFilterFunc) (GdkXEvent *xevent,
177                                           GdkEvent *event,
178                                           gpointer  data);
179
180
181 /**
182  * GdkEventType:
183  * @GDK_NOTHING: a special code to indicate a null event.
184  * @GDK_DELETE: the window manager has requested that the toplevel window be
185  *   hidden or destroyed, usually when the user clicks on a special icon in the
186  *   title bar.
187  * @GDK_DESTROY: the window has been destroyed.
188  * @GDK_EXPOSE: all or part of the window has become visible and needs to be
189  *   redrawn.
190  * @GDK_MOTION_NOTIFY: the pointer (usually a mouse) has moved.
191  * @GDK_BUTTON_PRESS: a mouse button has been pressed.
192  * @GDK_2BUTTON_PRESS: a mouse button has been double-clicked (clicked twice
193  *   within a short period of time). Note that each click also generates a
194  *   %GDK_BUTTON_PRESS event.
195  * @GDK_3BUTTON_PRESS: a mouse button has been clicked 3 times in a short period
196  *   of time. Note that each click also generates a %GDK_BUTTON_PRESS event.
197  * @GDK_BUTTON_RELEASE: a mouse button has been released.
198  * @GDK_KEY_PRESS: a key has been pressed.
199  * @GDK_KEY_RELEASE: a key has been released.
200  * @GDK_ENTER_NOTIFY: the pointer has entered the window.
201  * @GDK_LEAVE_NOTIFY: the pointer has left the window.
202  * @GDK_FOCUS_CHANGE: the keyboard focus has entered or left the window.
203  * @GDK_CONFIGURE: the size, position or stacking order of the window has changed.
204  *   Note that GTK+ discards these events for %GDK_WINDOW_CHILD windows.
205  * @GDK_MAP: the window has been mapped.
206  * @GDK_UNMAP: the window has been unmapped.
207  * @GDK_PROPERTY_NOTIFY: a property on the window has been changed or deleted.
208  * @GDK_SELECTION_CLEAR: the application has lost ownership of a selection.
209  * @GDK_SELECTION_REQUEST: another application has requested a selection.
210  * @GDK_SELECTION_NOTIFY: a selection has been received.
211  * @GDK_PROXIMITY_IN: an input device has moved into contact with a sensing
212  *   surface (e.g. a touchscreen or graphics tablet).
213  * @GDK_PROXIMITY_OUT: an input device has moved out of contact with a sensing
214  *   surface.
215  * @GDK_DRAG_ENTER: the mouse has entered the window while a drag is in progress.
216  * @GDK_DRAG_LEAVE: the mouse has left the window while a drag is in progress.
217  * @GDK_DRAG_MOTION: the mouse has moved in the window while a drag is in
218  *   progress.
219  * @GDK_DRAG_STATUS: the status of the drag operation initiated by the window
220  *   has changed.
221  * @GDK_DROP_START: a drop operation onto the window has started.
222  * @GDK_DROP_FINISHED: the drop operation initiated by the window has completed.
223  * @GDK_CLIENT_EVENT: a message has been received from another application.
224  * @GDK_VISIBILITY_NOTIFY: the window visibility status has changed.
225  * @GDK_SCROLL: the scroll wheel was turned
226  * @GDK_WINDOW_STATE: the state of a window has changed. See #GdkWindowState
227  *   for the possible window states
228  * @GDK_SETTING: a setting has been modified.
229  * @GDK_OWNER_CHANGE: the owner of a selection has changed. This event type
230  *   was added in 2.6
231  * @GDK_GRAB_BROKEN: a pointer or keyboard grab was broken. This event type
232  *   was added in 2.8.
233  * @GDK_DAMAGE: the content of the window has been changed. This event type
234  *   was added in 2.14.
235  * @GDK_EVENT_LAST: marks the end of the GdkEventType enumeration. Added in 2.18
236  *
237  * Specifies the type of the event.
238  *
239  * Do not confuse these events with the signals that GTK+ widgets emit.
240  * Although many of these events result in corresponding signals being emitted,
241  * the events are often transformed or filtered along the way.
242  */
243 typedef enum
244 {
245   GDK_NOTHING           = -1,
246   GDK_DELETE            = 0,
247   GDK_DESTROY           = 1,
248   GDK_EXPOSE            = 2,
249   GDK_MOTION_NOTIFY     = 3,
250   GDK_BUTTON_PRESS      = 4,
251   GDK_2BUTTON_PRESS     = 5,
252   GDK_3BUTTON_PRESS     = 6,
253   GDK_BUTTON_RELEASE    = 7,
254   GDK_KEY_PRESS         = 8,
255   GDK_KEY_RELEASE       = 9,
256   GDK_ENTER_NOTIFY      = 10,
257   GDK_LEAVE_NOTIFY      = 11,
258   GDK_FOCUS_CHANGE      = 12,
259   GDK_CONFIGURE         = 13,
260   GDK_MAP               = 14,
261   GDK_UNMAP             = 15,
262   GDK_PROPERTY_NOTIFY   = 16,
263   GDK_SELECTION_CLEAR   = 17,
264   GDK_SELECTION_REQUEST = 18,
265   GDK_SELECTION_NOTIFY  = 19,
266   GDK_PROXIMITY_IN      = 20,
267   GDK_PROXIMITY_OUT     = 21,
268   GDK_DRAG_ENTER        = 22,
269   GDK_DRAG_LEAVE        = 23,
270   GDK_DRAG_MOTION       = 24,
271   GDK_DRAG_STATUS       = 25,
272   GDK_DROP_START        = 26,
273   GDK_DROP_FINISHED     = 27,
274   GDK_CLIENT_EVENT      = 28,
275   GDK_VISIBILITY_NOTIFY = 29,
276   GDK_SCROLL            = 31,
277   GDK_WINDOW_STATE      = 32,
278   GDK_SETTING           = 33,
279   GDK_OWNER_CHANGE      = 34,
280   GDK_GRAB_BROKEN       = 35,
281   GDK_DAMAGE            = 36,
282   GDK_EVENT_LAST        /* helper variable for decls */
283 } GdkEventType;
284
285 /**
286  * GdkVisibilityState:
287  * @GDK_VISIBILITY_UNOBSCURED: the window is completely visible.
288  * @GDK_VISIBILITY_PARTIAL: the window is partially visible.
289  * @GDK_VISIBILITY_FULLY_OBSCURED: the window is not visible at all.
290  *
291  * Specifies the visiblity status of a window for a #GdkEventVisibility.
292  */
293 typedef enum
294 {
295   GDK_VISIBILITY_UNOBSCURED,
296   GDK_VISIBILITY_PARTIAL,
297   GDK_VISIBILITY_FULLY_OBSCURED
298 } GdkVisibilityState;
299
300 /**
301  * GdkScrollDirection:
302  * @GDK_SCROLL_UP: the window is scrolled up.
303  * @GDK_SCROLL_DOWN: the window is scrolled down.
304  * @GDK_SCROLL_LEFT: the window is scrolled to the left.
305  * @GDK_SCROLL_RIGHT: the window is scrolled to the right.
306  *
307  * Specifies the direction for #GdkEventScroll.
308  */
309 typedef enum
310 {
311   GDK_SCROLL_UP,
312   GDK_SCROLL_DOWN,
313   GDK_SCROLL_LEFT,
314   GDK_SCROLL_RIGHT
315 } GdkScrollDirection;
316
317 /**
318  * GdkNotifyType:
319  * @GDK_NOTIFY_ANCESTOR: the window is entered from an ancestor or
320  *   left towards an ancestor.
321  * @GDK_NOTIFY_VIRTUAL: the pointer moves between an ancestor and an
322  *   inferior of the window.
323  * @GDK_NOTIFY_INFERIOR: the window is entered from an inferior or
324  *   left towards an inferior.
325  * @GDK_NOTIFY_NONLINEAR: the window is entered from or left towards
326  *   a window which is neither an ancestor nor an inferior.
327  * @GDK_NOTIFY_NONLINEAR_VIRTUAL: the pointer moves between two windows
328  *   which are not ancestors of each other and the window is part of
329  *   the ancestor chain between one of these windows and their least
330  *   common ancestor.
331  * @GDK_NOTIFY_UNKNOWN: an unknown type of enter/leave event occurred.
332  *
333  * Specifies the kind of crossing for #GdkEventCrossing.
334  *
335  * See the X11 protocol specification of <type>LeaveNotify</type> for
336  * full details of crossing event generation.
337  */
338 typedef enum
339 {
340   GDK_NOTIFY_ANCESTOR           = 0,
341   GDK_NOTIFY_VIRTUAL            = 1,
342   GDK_NOTIFY_INFERIOR           = 2,
343   GDK_NOTIFY_NONLINEAR          = 3,
344   GDK_NOTIFY_NONLINEAR_VIRTUAL  = 4,
345   GDK_NOTIFY_UNKNOWN            = 5
346 } GdkNotifyType;
347
348 /**
349  * GdkCrossingMode:
350  * @GDK_CROSSING_NORMAL: crossing because of pointer motion.
351  * @GDK_CROSSING_GRAB: crossing because a grab is activated.
352  * @GDK_CROSSING_UNGRAB: crossing because a grab is deactivated.
353  * @GDK_CROSSING_GTK_GRAB: crossing because a GTK+ grab is activated.
354  * @GDK_CROSSING_GTK_UNGRAB: crossing because a GTK+ grab is deactivated.
355  * @GDK_CROSSING_STATE_CHANGED: crossing because a GTK+ widget changed
356  *   state (e.g. sensitivity).
357  *
358  * Specifies the crossing mode for #GdkEventCrossing.
359  */
360 typedef enum
361 {
362   GDK_CROSSING_NORMAL,
363   GDK_CROSSING_GRAB,
364   GDK_CROSSING_UNGRAB,
365   GDK_CROSSING_GTK_GRAB,
366   GDK_CROSSING_GTK_UNGRAB,
367   GDK_CROSSING_STATE_CHANGED
368 } GdkCrossingMode;
369
370 /**
371  * GdkPropertyState:
372  * @GDK_PROPERTY_NEW_VALUE: the property value was changed.
373  * @GDK_PROPERTY_DELETE: the property was deleted.
374  *
375  * Specifies the type of a property change for a #GdkEventProperty.
376  */
377 typedef enum
378 {
379   GDK_PROPERTY_NEW_VALUE,
380   GDK_PROPERTY_DELETE
381 } GdkPropertyState;
382
383 /**
384  * GdkWindowState:
385  * @GDK_WINDOW_STATE_WITHDRAWN: the window is not shown.
386  * @GDK_WINDOW_STATE_ICONIFIED: the window is minimized.
387  * @GDK_WINDOW_STATE_MAXIMIZED: the window is maximized.
388  * @GDK_WINDOW_STATE_STICKY: the window is sticky.
389  * @GDK_WINDOW_STATE_FULLSCREEN: the window is maximized without
390  *   decorations.
391  * @GDK_WINDOW_STATE_ABOVE: the window is kept above other windows.
392  * @GDK_WINDOW_STATE_BELOW: the window is kept below other windows.
393  * @GDK_WINDOW_STATE_FOCUSED: the window is presented as focused (with active decorations).
394  *
395  * Specifies the state of a toplevel window.
396  */
397 typedef enum
398 {
399   GDK_WINDOW_STATE_WITHDRAWN  = 1 << 0,
400   GDK_WINDOW_STATE_ICONIFIED  = 1 << 1,
401   GDK_WINDOW_STATE_MAXIMIZED  = 1 << 2,
402   GDK_WINDOW_STATE_STICKY     = 1 << 3,
403   GDK_WINDOW_STATE_FULLSCREEN = 1 << 4,
404   GDK_WINDOW_STATE_ABOVE      = 1 << 5,
405   GDK_WINDOW_STATE_BELOW      = 1 << 6,
406   GDK_WINDOW_STATE_FOCUSED    = 1 << 7
407 } GdkWindowState;
408
409 /**
410  * GdkSettingAction:
411  * @GDK_SETTING_ACTION_NEW: a setting was added.
412  * @GDK_SETTING_ACTION_CHANGED: a setting was changed.
413  * @GDK_SETTING_ACTION_DELETED: a setting was deleted.
414  *
415  * Specifies the kind of modification applied to a setting in a
416  * #GdkEventSetting.
417  */
418 typedef enum
419 {
420   GDK_SETTING_ACTION_NEW,
421   GDK_SETTING_ACTION_CHANGED,
422   GDK_SETTING_ACTION_DELETED
423 } GdkSettingAction;
424
425 /**
426  * GdkOwnerChange:
427  * @GDK_OWNER_CHANGE_NEW_OWNER: some other app claimed the ownership
428  * @GDK_OWNER_CHANGE_DESTROY: the window was destroyed
429  * @GDK_OWNER_CHANGE_CLOSE: the client was closed
430  *
431  * Specifies why a selection ownership was changed.
432  */
433 typedef enum
434 {
435   GDK_OWNER_CHANGE_NEW_OWNER,
436   GDK_OWNER_CHANGE_DESTROY,
437   GDK_OWNER_CHANGE_CLOSE
438 } GdkOwnerChange;
439
440 /**
441  * GdkEventAny:
442  * @type: the type of the event.
443  * @window: the window which received the event.
444  * @send_event: %TRUE if the event was sent explicitly (e.g. using
445  *   <function>XSendEvent</function>).
446  *
447  * Contains the fields which are common to all event structs.
448  * Any event pointer can safely be cast to a pointer to a #GdkEventAny to
449  * access these fields.
450  */
451 struct _GdkEventAny
452 {
453   GdkEventType type;
454   GdkWindow *window;
455   gint8 send_event;
456 };
457
458 /**
459  * GdkEventExpose:
460  * @type: the type of the event (%GDK_EXPOSE or %GDK_DAMAGE).
461  * @window: the window which received the event.
462  * @send_event: %TRUE if the event was sent explicitly (e.g. using
463  *   <function>XSendEvent</function>).
464  * @area: bounding box of @region.
465  * @region: the region that needs to be redrawn.
466  * @count: the number of contiguous %GDK_EXPOSE events following this one.
467  *   The only use for this is "exposure compression", i.e. handling all
468  *   contiguous %GDK_EXPOSE events in one go, though GDK performs some
469  *   exposure compression so this is not normally needed.
470  *
471  * Generated when all or part of a window becomes visible and needs to be
472  * redrawn.
473  */
474 struct _GdkEventExpose
475 {
476   GdkEventType type;
477   GdkWindow *window;
478   gint8 send_event;
479   GdkRectangle area;
480   cairo_region_t *region;
481   gint count; /* If non-zero, how many more events follow. */
482 };
483
484 /**
485  * GdkEventVisibility:
486  * @type: the type of the event (%GDK_VISIBILITY_NOTIFY).
487  * @window: the window which received the event.
488  * @send_event: %TRUE if the event was sent explicitly (e.g. using
489  *   <function>XSendEvent</function>).
490  * @state: the new visibility state (%GDK_VISIBILITY_FULLY_OBSCURED,
491  *   %GDK_VISIBILITY_PARTIAL or %GDK_VISIBILITY_UNOBSCURED).
492  *
493  * Generated when the window visibility status has changed.
494  */
495 struct _GdkEventVisibility
496 {
497   GdkEventType type;
498   GdkWindow *window;
499   gint8 send_event;
500   GdkVisibilityState state;
501 };
502
503 /**
504  * GdkEventMotion:
505  * @type: the type of the event.
506  * @window: the window which received the event.
507  * @send_event: %TRUE if the event was sent explicitly (e.g. using
508  *   <function>XSendEvent</function>).
509  * @time: the time of the event in milliseconds.
510  * @x: the x coordinate of the pointer relative to the window.
511  * @y: the y coordinate of the pointer relative to the window.
512  * @axes: @x, @y translated to the axes of @device, or %NULL if @device is
513  *   the mouse.
514  * @state: (type GdkModifierType): a bit-mask representing the state of
515  *   the modifier keys (e.g. Control, Shift and Alt) and the pointer
516  *   buttons. See #GdkModifierType.
517  * @is_hint: set to 1 if this event is just a hint, see the
518  *   %GDK_POINTER_MOTION_HINT_MASK value of #GdkEventMask.
519  * @device: the device where the event originated.
520  * @x_root: the x coordinate of the pointer relative to the root of the
521  *   screen.
522  * @y_root: the y coordinate of the pointer relative to the root of the
523  *   screen.
524  *
525  * Generated when the pointer moves.
526  */
527 struct _GdkEventMotion
528 {
529   GdkEventType type;
530   GdkWindow *window;
531   gint8 send_event;
532   guint32 time;
533   gdouble x;
534   gdouble y;
535   gdouble *axes;
536   guint state;
537   gint16 is_hint;
538   GdkDevice *device;
539   gdouble x_root, y_root;
540 };
541
542 /**
543  * GdkEventButton:
544  * @type: the type of the event (%GDK_BUTTON_PRESS, %GDK_2BUTTON_PRESS,
545  *   %GDK_3BUTTON_PRESS or %GDK_BUTTON_RELEASE).
546  * @window: the window which received the event.
547  * @send_event: %TRUE if the event was sent explicitly (e.g. using
548  *   <function>XSendEvent</function>).
549  * @time: the time of the event in milliseconds.
550  * @x: the x coordinate of the pointer relative to the window.
551  * @y: the y coordinate of the pointer relative to the window.
552  * @axes: @x, @y translated to the axes of @device, or %NULL if @device is
553  *   the mouse.
554  * @state: (type GdkModifierType): a bit-mask representing the state of
555  *   the modifier keys (e.g. Control, Shift and Alt) and the pointer
556  *   buttons. See #GdkModifierType.
557  * @button: the button which was pressed or released, numbered from 1 to 5.
558  *   Normally button 1 is the left mouse button, 2 is the middle button,
559  *   and 3 is the right button. On 2-button mice, the middle button can
560  *   often be simulated by pressing both mouse buttons together.
561  * @device: the device where the event originated.
562  * @x_root: the x coordinate of the pointer relative to the root of the
563  *   screen.
564  * @y_root: the y coordinate of the pointer relative to the root of the
565  *   screen.
566  *
567  * Used for button press and button release events. The
568  * @type field will be one of %GDK_BUTTON_PRESS,
569  * %GDK_2BUTTON_PRESS, %GDK_3BUTTON_PRESS, and %GDK_BUTTON_RELEASE.
570  *
571  * Double and triple-clicks result in a sequence of events being received.
572  * For double-clicks the order of events will be:
573  * <orderedlist>
574  * <listitem><para>%GDK_BUTTON_PRESS</para></listitem>
575  * <listitem><para>%GDK_BUTTON_RELEASE</para></listitem>
576  * <listitem><para>%GDK_BUTTON_PRESS</para></listitem>
577  * <listitem><para>%GDK_2BUTTON_PRESS</para></listitem>
578  * <listitem><para>%GDK_BUTTON_RELEASE</para></listitem>
579  * </orderedlist>
580  * Note that the first click is received just like a normal
581  * button press, while the second click results in a %GDK_2BUTTON_PRESS
582  * being received just after the %GDK_BUTTON_PRESS.
583  *
584  * Triple-clicks are very similar to double-clicks, except that
585  * %GDK_3BUTTON_PRESS is inserted after the third click. The order of the
586  * events is:
587  * <orderedlist>
588  * <listitem><para>%GDK_BUTTON_PRESS</para></listitem>
589  * <listitem><para>%GDK_BUTTON_RELEASE</para></listitem>
590  * <listitem><para>%GDK_BUTTON_PRESS</para></listitem>
591  * <listitem><para>%GDK_2BUTTON_PRESS</para></listitem>
592  * <listitem><para>%GDK_BUTTON_RELEASE</para></listitem>
593  * <listitem><para>%GDK_BUTTON_PRESS</para></listitem>
594  * <listitem><para>%GDK_3BUTTON_PRESS</para></listitem>
595  * <listitem><para>%GDK_BUTTON_RELEASE</para></listitem>
596  * </orderedlist>
597  *
598  * For a double click to occur, the second button press must occur within
599  * 1/4 of a second of the first. For a triple click to occur, the third
600  * button press must also occur within 1/2 second of the first button press.
601  */
602 struct _GdkEventButton
603 {
604   GdkEventType type;
605   GdkWindow *window;
606   gint8 send_event;
607   guint32 time;
608   gdouble x;
609   gdouble y;
610   gdouble *axes;
611   guint state;
612   guint button;
613   GdkDevice *device;
614   gdouble x_root, y_root;
615 };
616
617 /**
618  * GdkEventScroll:
619  * @type: the type of the event (%GDK_SCROLL).
620  * @window: the window which received the event.
621  * @send_event: %TRUE if the event was sent explicitly (e.g. using
622  *   <function>XSendEvent</function>).
623  * @time: the time of the event in milliseconds.
624  * @x: the x coordinate of the pointer relative to the window.
625  * @y: the y coordinate of the pointer relative to the window.
626  * @state: (type GdkModifierType): a bit-mask representing the state of
627  *   the modifier keys (e.g. Control, Shift and Alt) and the pointer
628  *   buttons. See #GdkModifierType.
629  * @direction: the direction to scroll to (one of %GDK_SCROLL_UP,
630  *   %GDK_SCROLL_DOWN, %GDK_SCROLL_LEFT and %GDK_SCROLL_RIGHT).
631  * @device: the device where the event originated.
632  * @x_root: the x coordinate of the pointer relative to the root of the
633  *   screen.
634  * @y_root: the y coordinate of the pointer relative to the root of the
635  *   screen.
636  *
637  * Generated from button presses for the buttons 4 to 7. Wheel mice are
638  * usually configured to generate button press events for buttons 4 and 5
639  * when the wheel is turned.
640  */
641 struct _GdkEventScroll
642 {
643   GdkEventType type;
644   GdkWindow *window;
645   gint8 send_event;
646   guint32 time;
647   gdouble x;
648   gdouble y;
649   guint state;
650   GdkScrollDirection direction;
651   GdkDevice *device;
652   gdouble x_root, y_root;
653 };
654
655 /**
656  * GdkEventKey:
657  * @type: the type of the event (%GDK_KEY_PRESS or %GDK_KEY_RELEASE).
658  * @window: the window which received the event.
659  * @send_event: %TRUE if the event was sent explicitly (e.g. using
660  *   <function>XSendEvent</function>).
661  * @time: the time of the event in milliseconds.
662  * @state: (type GdkModifierType): a bit-mask representing the state of
663  *   the modifier keys (e.g. Control, Shift and Alt) and the pointer
664  *   buttons. See #GdkModifierType.
665  * @keyval: the key that was pressed or released. See the
666  *   <filename>&lt;gdk/gdkkeysyms.h&gt;</filename> header file for a
667  *   complete list of GDK key codes.
668  * @length: the length of @string.
669  * @string: a string containing the an approximation of the text that
670  *   would result from this keypress. The only correct way to handle text
671  *   input of text is using input methods (see #GtkIMContext), so this
672  *   field is deprecated and should never be used.
673  *   (gdk_unicode_to_keyval() provides a non-deprecated way of getting
674  *   an approximate translation for a key.) The string is encoded in the
675  *   encoding of the current locale (Note: this for backwards compatibility:
676  *   strings in GTK+ and GDK are typically in UTF-8.) and NUL-terminated.
677  *   In some cases, the translation of the key code will be a single
678  *   NUL byte, in which case looking at @length is necessary to distinguish
679  *   it from the an empty translation.
680  * @hardware_keycode: the raw code of the key that was pressed or released.
681  * @group: the keyboard group.
682  * @is_modifier: a flag that indicates if @hardware_keycode is mapped to a
683  *   modifier. Since 2.10
684  *
685  * Describes a key press or key release event.
686  */
687 struct _GdkEventKey
688 {
689   GdkEventType type;
690   GdkWindow *window;
691   gint8 send_event;
692   guint32 time;
693   guint state;
694   guint keyval;
695   gint length;
696   gchar *string;
697   guint16 hardware_keycode;
698   guint8 group;
699   guint is_modifier : 1;
700 };
701
702 /**
703  * GdkEventCrossing:
704  * @type: the type of the event (%GDK_ENTER_NOTIFY or %GDK_LEAVE_NOTIFY).
705  * @window: the window which received the event.
706  * @send_event: %TRUE if the event was sent explicitly (e.g. using
707  *  <function>XSendEvent</function>).
708  * @subwindow: the window that was entered or left.
709  * @time: the time of the event in milliseconds.
710  * @x: the x coordinate of the pointer relative to the window.
711  * @y: the y coordinate of the pointer relative to the window.
712  * @x_root: the x coordinate of the pointer relative to the root of the screen.
713  * @y_root: the y coordinate of the pointer relative to the root of the screen.
714  * @mode: the crossing mode (%GDK_CROSSING_NORMAL, %GDK_CROSSING_GRAB,
715  *  %GDK_CROSSING_UNGRAB, %GDK_CROSSING_GTK_GRAB, %GDK_CROSSING_GTK_UNGRAB or
716  *  %GDK_CROSSING_STATE_CHANGED).  %GDK_CROSSING_GTK_GRAB, %GDK_CROSSING_GTK_UNGRAB,
717  *  and %GDK_CROSSING_STATE_CHANGED were added in 2.14 and are always synthesized,
718  *  never native.
719  * @detail: the kind of crossing that happened (%GDK_NOTIFY_INFERIOR,
720  *  %GDK_NOTIFY_ANCESTOR, %GDK_NOTIFY_VIRTUAL, %GDK_NOTIFY_NONLINEAR or
721  *  %GDK_NOTIFY_NONLINEAR_VIRTUAL).
722  * @focus: %TRUE if @window is the focus window or an inferior.
723  * @state: (type GdkModifierType): a bit-mask representing the state of
724  *   the modifier keys (e.g. Control, Shift and Alt) and the pointer
725  *   buttons. See #GdkModifierType.
726  *
727  * Generated when the pointer enters or leaves a window.
728  */
729 struct _GdkEventCrossing
730 {
731   GdkEventType type;
732   GdkWindow *window;
733   gint8 send_event;
734   GdkWindow *subwindow;
735   guint32 time;
736   gdouble x;
737   gdouble y;
738   gdouble x_root;
739   gdouble y_root;
740   GdkCrossingMode mode;
741   GdkNotifyType detail;
742   gboolean focus;
743   guint state;
744 };
745
746 /**
747  * GdkEventFocus:
748  * @type: the type of the event (%GDK_FOCUS_CHANGE).
749  * @window: the window which received the event.
750  * @send_event: %TRUE if the event was sent explicitly (e.g. using
751  *   <function>XSendEvent</function>).
752  * @in: %TRUE if the window has gained the keyboard focus, %FALSE if
753  *   it has lost the focus.
754  *
755  * Describes a change of keyboard focus.
756  */
757 struct _GdkEventFocus
758 {
759   GdkEventType type;
760   GdkWindow *window;
761   gint8 send_event;
762   gint16 in;
763 };
764
765 /**
766  * GdkEventConfigure:
767  * @type: the type of the event (%GDK_CONFIGURE).
768  * @window: the window which received the event.
769  * @send_event: %TRUE if the event was sent explicitly (e.g. using
770  *   <function>XSendEvent</function>).
771  * @x: the new x coordinate of the window, relative to its parent.
772  * @y: the new y coordinate of the window, relative to its parent.
773  * @width: the new width of the window.
774  * @height: the new height of the window.
775  *
776  * Generated when a window size or position has changed.
777  */
778 struct _GdkEventConfigure
779 {
780   GdkEventType type;
781   GdkWindow *window;
782   gint8 send_event;
783   gint x, y;
784   gint width;
785   gint height;
786 };
787
788 /**
789  * GdkEventProperty:
790  * @type: the type of the event (%GDK_PROPERTY_NOTIFY).
791  * @window: the window which received the event.
792  * @send_event: %TRUE if the event was sent explicitly (e.g. using
793  *   <function>XSendEvent</function>).
794  * @atom: the property that was changed.
795  * @time: the time of the event in milliseconds.
796  * @state: whether the property was changed (%GDK_PROPERTY_NEW_VALUE) or
797  *   deleted (%GDK_PROPERTY_DELETE).
798  *
799  * Describes a property change on a window.
800  */
801 struct _GdkEventProperty
802 {
803   GdkEventType type;
804   GdkWindow *window;
805   gint8 send_event;
806   GdkAtom atom;
807   guint32 time;
808   guint state;
809 };
810
811 /**
812  * GdkEventSelection:
813  * @type: the type of the event (%GDK_SELECTION_CLEAR,
814  *   %GDK_SELECTION_NOTIFY or %GDK_SELECTION_REQUEST).
815  * @window: the window which received the event.
816  * @send_event: %TRUE if the event was sent explicitly (e.g. using
817  *   <function>XSendEvent</function>).
818  * @selection: the selection.
819  * @target: the target to which the selection should be converted.
820  * @property: the property in which to place the result of the conversion.
821  * @time: the time of the event in milliseconds.
822  * @requestor: the window on which to place @property or %NULL if none.
823  *
824  * Generated when a selection is requested or ownership of a selection
825  * is taken over by another client application.
826  */
827 struct _GdkEventSelection
828 {
829   GdkEventType type;
830   GdkWindow *window;
831   gint8 send_event;
832   GdkAtom selection;
833   GdkAtom target;
834   GdkAtom property;
835   guint32 time;
836   GdkWindow *requestor;
837 };
838
839 /**
840  * GdkEventOwnerChange:
841  * @type: the type of the event (%GDK_OWNER_CHANGE).
842  * @window: the window which received the event
843  * @send_event: %TRUE if the event was sent explicitly (e.g. using
844  *   <function>XSendEvent</function>)
845  * @owner: the new owner of the selection, or %NULL if there is none
846  * @reason: the reason for the ownership change as a #GdkOwnerChange value
847  * @selection: the atom identifying the selection
848  * @time: the timestamp of the event
849  * @selection_time: the time at which the selection ownership was taken
850  *   over
851  *
852  * Generated when the owner of a selection changes. On X11, this
853  * information is only available if the X server supports the XFIXES
854  * extension.
855  *
856  * Since: 2.6
857  */
858 struct _GdkEventOwnerChange
859 {
860   GdkEventType type;
861   GdkWindow *window;
862   gint8 send_event;
863   GdkWindow *owner;
864   GdkOwnerChange reason;
865   GdkAtom selection;
866   guint32 time;
867   guint32 selection_time;
868 };
869
870 /**
871  * GdkEventProximity:
872  * @type: the type of the event (%GDK_PROXIMITY_IN or %GDK_PROXIMITY_OUT).
873  * @window: the window which received the event.
874  * @send_event: %TRUE if the event was sent explicitly (e.g. using <function>XSendEvent</function>).
875  * @time: the time of the event in milliseconds.
876  * @device: the device where the event originated.
877  *
878  * Proximity events are generated when using GDK's wrapper for the
879  * XInput extension. The XInput extension is an add-on for standard X
880  * that allows you to use nonstandard devices such as graphics tablets.
881  * A proximity event indicates that the stylus has moved in or out of
882  * contact with the tablet, or perhaps that the user's finger has moved
883  * in or out of contact with a touch screen.
884  *
885  * This event type will be used pretty rarely. It only is important for
886  * XInput aware programs that are drawing their own cursor.
887  */
888 struct _GdkEventProximity
889 {
890   GdkEventType type;
891   GdkWindow *window;
892   gint8 send_event;
893   guint32 time;
894   GdkDevice *device;
895 };
896
897 /**
898  * GdkEventSetting:
899  * @type: the type of the event (%GDK_SETTING).
900  * @window: the window which received the event.
901  * @send_event: %TRUE if the event was sent explicitly (e.g. using
902  *   <function>XSendEvent</function>).
903  * @action: what happened to the setting (%GDK_SETTING_ACTION_NEW,
904  *   %GDK_SETTING_ACTION_CHANGED or %GDK_SETTING_ACTION_DELETED).
905  * @name: the name of the setting.
906  *
907  * Generated when a setting is modified.
908  */
909 struct _GdkEventSetting
910 {
911   GdkEventType type;
912   GdkWindow *window;
913   gint8 send_event;
914   GdkSettingAction action;
915   char *name;
916 };
917
918 /**
919  * GdkEventWindowState:
920  * @type: the type of the event (%GDK_WINDOW_STATE).
921  * @window: the window which received the event.
922  * @send_event: %TRUE if the event was sent explicitly (e.g. using
923  *   <function>XSendEvent</function>).
924  * @changed_mask: mask specifying what flags have changed.
925  * @new_window_state: the new window state, a combination of
926  *   #GdkWindowState bits.
927  *
928  * Generated when the state of a toplevel window changes.
929  */
930 struct _GdkEventWindowState
931 {
932   GdkEventType type;
933   GdkWindow *window;
934   gint8 send_event;
935   GdkWindowState changed_mask;
936   GdkWindowState new_window_state;
937 };
938
939 /**
940  * GdkEventGrabBroken:
941  * @type: the type of the event (%GDK_GRAB_BROKEN)
942  * @window: the window which received the event, i.e. the window
943  *   that previously owned the grab
944  * @send_event: %TRUE if the event was sent explicitly (e.g. using
945  *   <function>XSendEvent</function>).
946  * @keyboard: %TRUE if a keyboard grab was broken, %FALSE if a pointer
947  *   grab was broken
948  * @implicit: %TRUE if the broken grab was implicit
949  * @grab_window: If this event is caused by another grab in the same
950  *   application, @grab_window contains the new grab window. Otherwise
951  *   @grab_window is %NULL.
952  *
953  * Generated when a pointer or keyboard grab is broken. On X11, this happens
954  * when the grab window becomes unviewable (i.e. it or one of its ancestors
955  * is unmapped), or if the same application grabs the pointer or keyboard
956  * again. Note that implicit grabs (which are initiated by button presses)
957  * can also cause #GdkEventGrabBroken events.
958  *
959  * Since: 2.8
960  */
961 struct _GdkEventGrabBroken {
962   GdkEventType type;
963   GdkWindow *window;
964   gint8 send_event;
965   gboolean keyboard;
966   gboolean implicit;
967   GdkWindow *grab_window;
968 };
969
970 /**
971  * GdkEventDND:
972  * @type: the type of the event (%GDK_DRAG_ENTER, %GDK_DRAG_LEAVE,
973  *   %GDK_DRAG_MOTION, %GDK_DRAG_STATUS, %GDK_DROP_START or
974  *   %GDK_DROP_FINISHED).
975  * @window: the window which received the event.
976  * @send_event: %TRUE if the event was sent explicitly (e.g. using
977  *   <function>XSendEvent</function>).
978  * @context: the #GdkDragContext for the current DND operation.
979  * @time: the time of the event in milliseconds.
980  * @x_root: the x coordinate of the pointer relative to the root of the
981  *   screen, only set for %GDK_DRAG_MOTION and %GDK_DROP_START.
982  * @y_root: the y coordinate of the pointer relative to the root of the
983  *   screen, only set for %GDK_DRAG_MOTION and %GDK_DROP_START.
984  *
985  * Generated during DND operations.
986  */
987 struct _GdkEventDND {
988   GdkEventType type;
989   GdkWindow *window;
990   gint8 send_event;
991   GdkDragContext *context;
992
993   guint32 time;
994   gshort x_root, y_root;
995 };
996
997 /**
998  * GdkEvent:
999  *
1000  * The #GdkEvent struct contains a union of all of the event structs,
1001  * and allows access to the data fields in a number of ways.
1002  *
1003  * The event type is always the first field in all of the event structs, and
1004  * can always be accessed with the following code, no matter what type of
1005  * event it is:
1006  * <informalexample>
1007  * <programlisting>
1008  *   GdkEvent *event;
1009  *   GdkEventType type;
1010  *
1011  *   type = event->type;
1012  * </programlisting>
1013  * </informalexample>
1014  *
1015  * To access other fields of the event structs, the pointer to the event
1016  * can be cast to the appropriate event struct pointer, or the union member
1017  * name can be used. For example if the event type is %GDK_BUTTON_PRESS
1018  * then the x coordinate of the button press can be accessed with:
1019  * <informalexample>
1020  * <programlisting>
1021  *   GdkEvent *event;
1022  *   gdouble x;
1023  *
1024  *   x = ((GdkEventButton*)event)->x;
1025  * </programlisting>
1026  * </informalexample>
1027  * or:
1028  * <informalexample>
1029  * <programlisting>
1030  *   GdkEvent *event;
1031  *   gdouble x;
1032  *
1033  *   x = event->button.x;
1034  * </programlisting>
1035  * </informalexample>
1036  */
1037 union _GdkEvent
1038 {
1039   GdkEventType              type;
1040   GdkEventAny               any;
1041   GdkEventExpose            expose;
1042   GdkEventVisibility        visibility;
1043   GdkEventMotion            motion;
1044   GdkEventButton            button;
1045   GdkEventScroll            scroll;
1046   GdkEventKey               key;
1047   GdkEventCrossing          crossing;
1048   GdkEventFocus             focus_change;
1049   GdkEventConfigure         configure;
1050   GdkEventProperty          property;
1051   GdkEventSelection         selection;
1052   GdkEventOwnerChange       owner_change;
1053   GdkEventProximity         proximity;
1054   GdkEventDND               dnd;
1055   GdkEventWindowState       window_state;
1056   GdkEventSetting           setting;
1057   GdkEventGrabBroken        grab_broken;
1058 };
1059
1060 GType     gdk_event_get_type            (void) G_GNUC_CONST;
1061
1062 gboolean  gdk_events_pending            (void);
1063 GdkEvent* gdk_event_get                 (void);
1064
1065 GdkEvent* gdk_event_peek                (void);
1066 void      gdk_event_put                 (const GdkEvent *event);
1067
1068 GdkEvent* gdk_event_new                 (GdkEventType    type);
1069 GdkEvent* gdk_event_copy                (const GdkEvent *event);
1070 void      gdk_event_free                (GdkEvent       *event);
1071
1072 guint32   gdk_event_get_time            (const GdkEvent  *event);
1073 gboolean  gdk_event_get_state           (const GdkEvent  *event,
1074                                          GdkModifierType *state);
1075 gboolean  gdk_event_get_coords          (const GdkEvent  *event,
1076                                          gdouble         *x_win,
1077                                          gdouble         *y_win);
1078 gboolean  gdk_event_get_root_coords     (const GdkEvent *event,
1079                                          gdouble        *x_root,
1080                                          gdouble        *y_root);
1081 gboolean  gdk_event_get_button          (const GdkEvent *event,
1082                                          guint          *button);
1083 gboolean  gdk_event_get_click_count     (const GdkEvent *event,
1084                                          guint          *click_count);
1085 gboolean  gdk_event_get_keyval          (const GdkEvent *event,
1086                                          guint          *keyval);
1087 gboolean  gdk_event_get_keycode         (const GdkEvent *event,
1088                                          guint16        *keycode);
1089 gboolean gdk_event_get_scroll_direction (const GdkEvent *event,
1090                                          GdkScrollDirection *direction);
1091 gboolean  gdk_event_get_axis            (const GdkEvent  *event,
1092                                          GdkAxisUse       axis_use,
1093                                          gdouble         *value);
1094 void       gdk_event_set_device         (GdkEvent        *event,
1095                                          GdkDevice       *device);
1096 GdkDevice* gdk_event_get_device         (const GdkEvent  *event);
1097 void       gdk_event_set_source_device  (GdkEvent        *event,
1098                                          GdkDevice       *device);
1099 GdkDevice* gdk_event_get_source_device  (const GdkEvent  *event);
1100 void       gdk_event_request_motions    (const GdkEventMotion *event);
1101 gboolean   gdk_event_triggers_context_menu (const GdkEvent *event);
1102
1103 gboolean  gdk_events_get_distance       (GdkEvent        *event1,
1104                                          GdkEvent        *event2,
1105                                          gdouble         *distance);
1106 gboolean  gdk_events_get_angle          (GdkEvent        *event1,
1107                                          GdkEvent        *event2,
1108                                          gdouble         *angle);
1109 gboolean  gdk_events_get_center         (GdkEvent        *event1,
1110                                          GdkEvent        *event2,
1111                                          gdouble         *x,
1112                                          gdouble         *y);
1113
1114 void      gdk_event_handler_set         (GdkEventFunc    func,
1115                                          gpointer        data,
1116                                          GDestroyNotify  notify);
1117
1118 void       gdk_event_set_screen         (GdkEvent        *event,
1119                                          GdkScreen       *screen);
1120 GdkScreen *gdk_event_get_screen         (const GdkEvent  *event);
1121
1122 void      gdk_set_show_events           (gboolean        show_events);
1123 gboolean  gdk_get_show_events           (void);
1124
1125 #ifndef GDK_MULTIHEAD_SAFE
1126
1127 gboolean gdk_setting_get                           (const gchar *name,
1128                                                     GValue          *value);
1129
1130 #endif /* GDK_MULTIHEAD_SAFE */
1131
1132 G_END_DECLS
1133
1134 #endif /* __GDK_EVENTS_H__ */