]> Pileus Git - ~andy/gtk/blob - gdk/gdkevents.h
docs: Move documentation to inline comments: gdkevents
[~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 #define GDK_TYPE_EVENT          (gdk_event_get_type ())
42
43 /**
44  * GDK_PRIORITY_EVENTS:
45  *
46  * This is the priority that events from the X server are given in the
47  * <link linkend="glib-The-Main-Event-Loop">GLib Main Loop</link>.
48  */
49 #define GDK_PRIORITY_EVENTS     (G_PRIORITY_DEFAULT)
50
51 /**
52  * GDK_PRIORITY_REDRAW:
53  *
54  * This is the priority that the idle handler processing window updates
55  * is given in the
56  * <link linkend="glib-The-Main-Event-Loop">GLib Main Loop</link>.
57  */
58 #define GDK_PRIORITY_REDRAW     (G_PRIORITY_HIGH_IDLE + 20)
59
60
61 typedef struct _GdkEventAny         GdkEventAny;
62 typedef struct _GdkEventExpose      GdkEventExpose;
63 typedef struct _GdkEventNoExpose    GdkEventNoExpose;
64 typedef struct _GdkEventVisibility  GdkEventVisibility;
65 typedef struct _GdkEventMotion      GdkEventMotion;
66 typedef struct _GdkEventButton      GdkEventButton;
67 typedef struct _GdkEventScroll      GdkEventScroll;  
68 typedef struct _GdkEventKey         GdkEventKey;
69 typedef struct _GdkEventFocus       GdkEventFocus;
70 typedef struct _GdkEventCrossing    GdkEventCrossing;
71 typedef struct _GdkEventConfigure   GdkEventConfigure;
72 typedef struct _GdkEventProperty    GdkEventProperty;
73 typedef struct _GdkEventSelection   GdkEventSelection;
74 typedef struct _GdkEventOwnerChange GdkEventOwnerChange;
75 typedef struct _GdkEventProximity   GdkEventProximity;
76 typedef struct _GdkEventClient      GdkEventClient;
77 typedef struct _GdkEventDND         GdkEventDND;
78 typedef struct _GdkEventWindowState GdkEventWindowState;
79 typedef struct _GdkEventSetting     GdkEventSetting;
80 typedef struct _GdkEventGrabBroken  GdkEventGrabBroken;
81
82 typedef union  _GdkEvent            GdkEvent;
83
84 /**
85  * GdkEventFunc:
86  * @event: the #GdkEvent to process.
87  * @data: user data set when the event handler was installed with
88  *   gdk_event_handler_set().
89  *
90  * Specifies the type of function passed to gdk_event_handler_set() to
91  * handle all GDK events.
92  */
93 typedef void (*GdkEventFunc) (GdkEvent *event,
94                               gpointer  data);
95
96 /* Event filtering */
97
98 /**
99  * GdkXEvent:
100  *
101  * Used to represent native events (<type>XEvent</type>s for the X11
102  * backend, <type>MSG</type>s for Win32).
103  */
104 typedef void GdkXEvent;   /* Can be cast to window system specific
105                            * even type, XEvent on X11, MSG on Win32.
106                            */
107
108 /**
109  * GdkFilterReturn:
110  * @GDK_FILTER_CONTINUE: event not handled, continue processing.
111  * @GDK_FILTER_TRANSLATE: native event translated into a GDK event and stored
112  *  in the <literal>event</literal> structure that was passed in.
113  * @GDK_FILTER_REMOVE: event handled, terminate processing.
114  *
115  * Specifies the result of applying a #GdkFilterFunc to a native event.
116  */
117 typedef enum {
118   GDK_FILTER_CONTINUE,    /* Event not handled, continue processesing */
119   GDK_FILTER_TRANSLATE,   /* Native event translated into a GDK event and
120                              stored in the "event" structure that was
121                              passed in */
122   GDK_FILTER_REMOVE       /* Terminate processing, removing event */
123 } GdkFilterReturn;
124
125 /**
126  * GdkFilterFunc:
127  * @xevent: the native event to filter.
128  * @event: the GDK event to which the X event will be translated.
129  * @data: user data set when the filter was installed.
130  *
131  * Specifies the type of function used to filter native events before they are
132  * converted to GDK events.
133  *
134  * When a filter is called, @event is unpopulated, except for
135  * <literal>event->window</literal>. The filter may translate the native
136  * event to a GDK event and store the result in @event, or handle it without
137  * translation. If the filter translates the event and processing should
138  * continue, it should return %GDK_FILTER_TRANSLATE.
139  *
140  * Returns: a #GdkFilterReturn value.
141  */
142 typedef GdkFilterReturn (*GdkFilterFunc) (GdkXEvent *xevent,
143                                           GdkEvent *event,
144                                           gpointer  data);
145
146
147 /**
148  * GdkEventType:
149  * @GDK_NOTHING: a special code to indicate a null event.
150  * @GDK_DELETE: the window manager has requested that the toplevel window be
151  *   hidden or destroyed, usually when the user clicks on a special icon in the
152  *   title bar.
153  * @GDK_DESTROY: the window has been destroyed.
154  * @GDK_EXPOSE: all or part of the window has become visible and needs to be
155  *   redrawn.
156  * @GDK_MOTION_NOTIFY: the pointer (usually a mouse) has moved.
157  * @GDK_BUTTON_PRESS: a mouse button has been pressed.
158  * @GDK_2BUTTON_PRESS: a mouse button has been double-clicked (clicked twice
159  *   within a short period of time). Note that each click also generates a
160  *   %GDK_BUTTON_PRESS event.
161  * @GDK_3BUTTON_PRESS: a mouse button has been clicked 3 times in a short period
162  *   of time. Note that each click also generates a %GDK_BUTTON_PRESS event.
163  * @GDK_BUTTON_RELEASE: a mouse button has been released.
164  * @GDK_KEY_PRESS: a key has been pressed.
165  * @GDK_KEY_RELEASE: a key has been released.
166  * @GDK_ENTER_NOTIFY: the pointer has entered the window.
167  * @GDK_LEAVE_NOTIFY: the pointer has left the window.
168  * @GDK_FOCUS_CHANGE: the keyboard focus has entered or left the window.
169  * @GDK_CONFIGURE: the size, position or stacking order of the window has changed.
170  *   Note that GTK+ discards these events for %GDK_WINDOW_CHILD windows.
171  * @GDK_MAP: the window has been mapped.
172  * @GDK_UNMAP: the window has been unmapped.
173  * @GDK_PROPERTY_NOTIFY: a property on the window has been changed or deleted.
174  * @GDK_SELECTION_CLEAR: the application has lost ownership of a selection.
175  * @GDK_SELECTION_REQUEST: another application has requested a selection.
176  * @GDK_SELECTION_NOTIFY: a selection has been received.
177  * @GDK_PROXIMITY_IN: an input device has moved into contact with a sensing
178  *   surface (e.g. a touchscreen or graphics tablet).
179  * @GDK_PROXIMITY_OUT: an input device has moved out of contact with a sensing
180  *   surface.
181  * @GDK_DRAG_ENTER: the mouse has entered the window while a drag is in progress.
182  * @GDK_DRAG_LEAVE: the mouse has left the window while a drag is in progress.
183  * @GDK_DRAG_MOTION: the mouse has moved in the window while a drag is in
184  *   progress.
185  * @GDK_DRAG_STATUS: the status of the drag operation initiated by the window
186  *   has changed.
187  * @GDK_DROP_START: a drop operation onto the window has started.
188  * @GDK_DROP_FINISHED: the drop operation initiated by the window has completed.
189  * @GDK_CLIENT_EVENT: a message has been received from another application.
190  * @GDK_VISIBILITY_NOTIFY: the window visibility status has changed.
191  * @GDK_NO_EXPOSE: indicates that the source region was completely available
192  *   when parts of a drawable were copied. This is not very useful.
193  * @GDK_SCROLL: the scroll wheel was turned
194  * @GDK_WINDOW_STATE: the state of a window has changed. See #GdkWindowState
195  *   for the possible window states
196  * @GDK_SETTING: a setting has been modified.
197  * @GDK_OWNER_CHANGE: the owner of a selection has changed. This event type
198  *   was added in 2.6
199  * @GDK_GRAB_BROKEN: a pointer or keyboard grab was broken. This event type
200  *   was added in 2.8.
201  * @GDK_DAMAGE: the content of the window has been changed. This event type
202  *   was added in 2.14.
203  * @GDK_EVENT_LAST: marks the end of the GdkEventType enumeration. Added in 2.18
204  *
205  * Specifies the type of the event.
206  *
207  * Do not confuse these events with the signals that GTK+ widgets emit.
208  * Although many of these events result in corresponding signals being emitted,
209  * the events are often transformed or filtered along the way.
210  */
211 typedef enum
212 {
213   GDK_NOTHING           = -1,
214   GDK_DELETE            = 0,
215   GDK_DESTROY           = 1,
216   GDK_EXPOSE            = 2,
217   GDK_MOTION_NOTIFY     = 3,
218   GDK_BUTTON_PRESS      = 4,
219   GDK_2BUTTON_PRESS     = 5,
220   GDK_3BUTTON_PRESS     = 6,
221   GDK_BUTTON_RELEASE    = 7,
222   GDK_KEY_PRESS         = 8,
223   GDK_KEY_RELEASE       = 9,
224   GDK_ENTER_NOTIFY      = 10,
225   GDK_LEAVE_NOTIFY      = 11,
226   GDK_FOCUS_CHANGE      = 12,
227   GDK_CONFIGURE         = 13,
228   GDK_MAP               = 14,
229   GDK_UNMAP             = 15,
230   GDK_PROPERTY_NOTIFY   = 16,
231   GDK_SELECTION_CLEAR   = 17,
232   GDK_SELECTION_REQUEST = 18,
233   GDK_SELECTION_NOTIFY  = 19,
234   GDK_PROXIMITY_IN      = 20,
235   GDK_PROXIMITY_OUT     = 21,
236   GDK_DRAG_ENTER        = 22,
237   GDK_DRAG_LEAVE        = 23,
238   GDK_DRAG_MOTION       = 24,
239   GDK_DRAG_STATUS       = 25,
240   GDK_DROP_START        = 26,
241   GDK_DROP_FINISHED     = 27,
242   GDK_CLIENT_EVENT      = 28,
243   GDK_VISIBILITY_NOTIFY = 29,
244   GDK_NO_EXPOSE         = 30,
245   GDK_SCROLL            = 31,
246   GDK_WINDOW_STATE      = 32,
247   GDK_SETTING           = 33,
248   GDK_OWNER_CHANGE      = 34,
249   GDK_GRAB_BROKEN       = 35,
250   GDK_DAMAGE            = 36,
251   GDK_EVENT_LAST        /* helper variable for decls */
252 } GdkEventType;
253
254 typedef enum
255 {
256   GDK_VISIBILITY_UNOBSCURED,
257   GDK_VISIBILITY_PARTIAL,
258   GDK_VISIBILITY_FULLY_OBSCURED
259 } GdkVisibilityState;
260
261 typedef enum
262 {
263   GDK_SCROLL_UP,
264   GDK_SCROLL_DOWN,
265   GDK_SCROLL_LEFT,
266   GDK_SCROLL_RIGHT
267 } GdkScrollDirection;
268
269 /* Types of enter/leave notifications.
270  *   Ancestor:
271  *   Virtual:
272  *   Inferior:
273  *   Nonlinear:
274  *   NonlinearVirtual:
275  *   Unknown: An unknown type of enter/leave event occurred.
276  */
277 typedef enum
278 {
279   GDK_NOTIFY_ANCESTOR           = 0,
280   GDK_NOTIFY_VIRTUAL            = 1,
281   GDK_NOTIFY_INFERIOR           = 2,
282   GDK_NOTIFY_NONLINEAR          = 3,
283   GDK_NOTIFY_NONLINEAR_VIRTUAL  = 4,
284   GDK_NOTIFY_UNKNOWN            = 5
285 } GdkNotifyType;
286
287 /* Enter/leave event modes.
288  *   NotifyNormal
289  *   NotifyGrab
290  *   NotifyUngrab
291  */
292 typedef enum
293 {
294   GDK_CROSSING_NORMAL,
295   GDK_CROSSING_GRAB,
296   GDK_CROSSING_UNGRAB,
297   GDK_CROSSING_GTK_GRAB,
298   GDK_CROSSING_GTK_UNGRAB,
299   GDK_CROSSING_STATE_CHANGED
300 } GdkCrossingMode;
301
302 typedef enum
303 {
304   GDK_PROPERTY_NEW_VALUE,
305   GDK_PROPERTY_DELETE
306 } GdkPropertyState;
307
308 typedef enum
309 {
310   GDK_WINDOW_STATE_WITHDRAWN  = 1 << 0,
311   GDK_WINDOW_STATE_ICONIFIED  = 1 << 1,
312   GDK_WINDOW_STATE_MAXIMIZED  = 1 << 2,
313   GDK_WINDOW_STATE_STICKY     = 1 << 3,
314   GDK_WINDOW_STATE_FULLSCREEN = 1 << 4,
315   GDK_WINDOW_STATE_ABOVE      = 1 << 5,
316   GDK_WINDOW_STATE_BELOW      = 1 << 6
317 } GdkWindowState;
318
319 typedef enum
320 {
321   GDK_SETTING_ACTION_NEW,
322   GDK_SETTING_ACTION_CHANGED,
323   GDK_SETTING_ACTION_DELETED
324 } GdkSettingAction;
325
326 typedef enum
327 {
328   GDK_OWNER_CHANGE_NEW_OWNER,
329   GDK_OWNER_CHANGE_DESTROY,
330   GDK_OWNER_CHANGE_CLOSE
331 } GdkOwnerChange;
332
333 struct _GdkEventAny
334 {
335   GdkEventType type;
336   GdkWindow *window;
337   gint8 send_event;
338 };
339
340 struct _GdkEventExpose
341 {
342   GdkEventType type;
343   GdkWindow *window;
344   gint8 send_event;
345   GdkRectangle area;
346   cairo_region_t *region;
347   gint count; /* If non-zero, how many more events follow. */
348 };
349
350 struct _GdkEventNoExpose
351 {
352   GdkEventType type;
353   GdkWindow *window;
354   gint8 send_event;
355 };
356
357 struct _GdkEventVisibility
358 {
359   GdkEventType type;
360   GdkWindow *window;
361   gint8 send_event;
362   GdkVisibilityState state;
363 };
364
365 struct _GdkEventMotion
366 {
367   GdkEventType type;
368   GdkWindow *window;
369   gint8 send_event;
370   guint32 time;
371   gdouble x;
372   gdouble y;
373   gdouble *axes;
374   guint state;
375   gint16 is_hint;
376   GdkDevice *device;
377   gdouble x_root, y_root;
378 };
379
380 struct _GdkEventButton
381 {
382   GdkEventType type;
383   GdkWindow *window;
384   gint8 send_event;
385   guint32 time;
386   gdouble x;
387   gdouble y;
388   gdouble *axes;
389   guint state;
390   guint button;
391   GdkDevice *device;
392   gdouble x_root, y_root;
393 };
394
395 struct _GdkEventScroll
396 {
397   GdkEventType type;
398   GdkWindow *window;
399   gint8 send_event;
400   guint32 time;
401   gdouble x;
402   gdouble y;
403   guint state;
404   GdkScrollDirection direction;
405   GdkDevice *device;
406   gdouble x_root, y_root;
407 };
408
409 struct _GdkEventKey
410 {
411   GdkEventType type;
412   GdkWindow *window;
413   gint8 send_event;
414   guint32 time;
415   guint state;
416   guint keyval;
417   gint length;
418   gchar *string;
419   guint16 hardware_keycode;
420   guint8 group;
421   guint is_modifier : 1;
422 };
423
424 struct _GdkEventCrossing
425 {
426   GdkEventType type;
427   GdkWindow *window;
428   gint8 send_event;
429   GdkWindow *subwindow;
430   guint32 time;
431   gdouble x;
432   gdouble y;
433   gdouble x_root;
434   gdouble y_root;
435   GdkCrossingMode mode;
436   GdkNotifyType detail;
437   gboolean focus;
438   guint state;
439 };
440
441 struct _GdkEventFocus
442 {
443   GdkEventType type;
444   GdkWindow *window;
445   gint8 send_event;
446   gint16 in;
447 };
448
449 struct _GdkEventConfigure
450 {
451   GdkEventType type;
452   GdkWindow *window;
453   gint8 send_event;
454   gint x, y;
455   gint width;
456   gint height;
457 };
458
459 struct _GdkEventProperty
460 {
461   GdkEventType type;
462   GdkWindow *window;
463   gint8 send_event;
464   GdkAtom atom;
465   guint32 time;
466   guint state;
467 };
468
469 struct _GdkEventSelection
470 {
471   GdkEventType type;
472   GdkWindow *window;
473   gint8 send_event;
474   GdkAtom selection;
475   GdkAtom target;
476   GdkAtom property;
477   guint32 time;
478   GdkNativeWindow requestor;
479 };
480
481 struct _GdkEventOwnerChange
482 {
483   GdkEventType type;
484   GdkWindow *window;
485   gint8 send_event;
486   GdkNativeWindow owner;
487   GdkOwnerChange reason;
488   GdkAtom selection;
489   guint32 time;
490   guint32 selection_time;
491 };
492
493 /* This event type will be used pretty rarely. It only is important
494    for XInput aware programs that are drawing their own cursor */
495
496 struct _GdkEventProximity
497 {
498   GdkEventType type;
499   GdkWindow *window;
500   gint8 send_event;
501   guint32 time;
502   GdkDevice *device;
503 };
504
505 struct _GdkEventClient
506 {
507   GdkEventType type;
508   GdkWindow *window;
509   gint8 send_event;
510   GdkAtom message_type;
511   gushort data_format;
512   union {
513     char b[20];
514     short s[10];
515     long l[5];
516   } data;
517 };
518
519 struct _GdkEventSetting
520 {
521   GdkEventType type;
522   GdkWindow *window;
523   gint8 send_event;
524   GdkSettingAction action;
525   char *name;
526 };
527
528 struct _GdkEventWindowState
529 {
530   GdkEventType type;
531   GdkWindow *window;
532   gint8 send_event;
533   GdkWindowState changed_mask;
534   GdkWindowState new_window_state;
535 };
536
537 struct _GdkEventGrabBroken {
538   GdkEventType type;
539   GdkWindow *window;
540   gint8 send_event;
541   gboolean keyboard;
542   gboolean implicit;
543   GdkWindow *grab_window;
544 };
545
546 /* Event types for DND */
547
548 struct _GdkEventDND {
549   GdkEventType type;
550   GdkWindow *window;
551   gint8 send_event;
552   GdkDragContext *context;
553
554   guint32 time;
555   gshort x_root, y_root;
556 };
557
558 union _GdkEvent
559 {
560   GdkEventType              type;
561   GdkEventAny               any;
562   GdkEventExpose            expose;
563   GdkEventNoExpose          no_expose;
564   GdkEventVisibility        visibility;
565   GdkEventMotion            motion;
566   GdkEventButton            button;
567   GdkEventScroll            scroll;
568   GdkEventKey               key;
569   GdkEventCrossing          crossing;
570   GdkEventFocus             focus_change;
571   GdkEventConfigure         configure;
572   GdkEventProperty          property;
573   GdkEventSelection         selection;
574   GdkEventOwnerChange       owner_change;
575   GdkEventProximity         proximity;
576   GdkEventClient            client;
577   GdkEventDND               dnd;
578   GdkEventWindowState       window_state;
579   GdkEventSetting           setting;
580   GdkEventGrabBroken        grab_broken;
581 };
582
583 GType     gdk_event_get_type            (void) G_GNUC_CONST;
584
585 gboolean  gdk_events_pending            (void);
586 GdkEvent* gdk_event_get                 (void);
587
588 GdkEvent* gdk_event_peek                (void);
589 void      gdk_event_put                 (const GdkEvent *event);
590
591 GdkEvent* gdk_event_new                 (GdkEventType    type);
592 GdkEvent* gdk_event_copy                (const GdkEvent *event);
593 void      gdk_event_free                (GdkEvent       *event);
594
595 guint32   gdk_event_get_time            (const GdkEvent  *event);
596 gboolean  gdk_event_get_state           (const GdkEvent  *event,
597                                          GdkModifierType *state);
598 gboolean  gdk_event_get_coords          (const GdkEvent  *event,
599                                          gdouble         *x_win,
600                                          gdouble         *y_win);
601 gboolean  gdk_event_get_root_coords     (const GdkEvent  *event,
602                                          gdouble         *x_root,
603                                          gdouble         *y_root);
604 gboolean  gdk_event_get_axis            (const GdkEvent  *event,
605                                          GdkAxisUse       axis_use,
606                                          gdouble         *value);
607 void       gdk_event_set_device         (GdkEvent        *event,
608                                          GdkDevice       *device);
609 GdkDevice* gdk_event_get_device         (const GdkEvent  *event);
610 void      gdk_event_request_motions     (const GdkEventMotion *event);
611
612 gboolean  gdk_events_get_distance       (GdkEvent        *event1,
613                                          GdkEvent        *event2,
614                                          gdouble         *distance);
615 gboolean  gdk_events_get_angle          (GdkEvent        *event1,
616                                          GdkEvent        *event2,
617                                          gdouble         *angle);
618 gboolean  gdk_events_get_center         (GdkEvent        *event1,
619                                          GdkEvent        *event2,
620                                          gdouble         *x,
621                                          gdouble         *y);
622
623 void      gdk_event_handler_set         (GdkEventFunc    func,
624                                          gpointer        data,
625                                          GDestroyNotify  notify);
626
627 void       gdk_event_set_screen         (GdkEvent        *event,
628                                          GdkScreen       *screen);
629 GdkScreen *gdk_event_get_screen         (const GdkEvent  *event);
630
631 void      gdk_set_show_events           (gboolean        show_events);
632 gboolean  gdk_get_show_events           (void);
633
634 #ifndef GDK_MULTIHEAD_SAFE
635
636 gboolean gdk_setting_get                           (const gchar *name,
637                                                     GValue          *value);
638 void gdk_add_client_message_filter                 (GdkAtom          message_type,
639                                                     GdkFilterFunc    func,
640                                                     gpointer         data);
641 gboolean gdk_event_send_client_message             (GdkEvent        *event,
642                                                     GdkNativeWindow  winid);
643 void     gdk_event_send_clientmessage_toall        (GdkEvent        *event);
644
645 #endif /* GDK_MULTIHEAD_SAFE */
646
647 gboolean gdk_event_send_client_message_for_display (GdkDisplay      *display,
648                                                     GdkEvent        *event,
649                                                     GdkNativeWindow  winid);
650
651 G_END_DECLS
652
653 #endif /* __GDK_EVENTS_H__ */