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