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