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