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