]> Pileus Git - ~andy/gtk/blob - gdk/gdkevents.h
Practically everything changed.
[~andy/gtk] / gdk / gdkevents.h
1 /* GDK - The GTK+ 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(GTK_DISABLE_SINGLE_INCLUDES) && !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/gdkinput.h>
38
39 G_BEGIN_DECLS
40
41 #define GDK_TYPE_EVENT          (gdk_event_get_type ())
42
43 #define GDK_PRIORITY_EVENTS     (G_PRIORITY_DEFAULT)
44 #define GDK_PRIORITY_REDRAW     (G_PRIORITY_HIGH_IDLE + 20)
45
46
47 typedef struct _GdkEventAny         GdkEventAny;
48 typedef struct _GdkEventExpose      GdkEventExpose;
49 typedef struct _GdkEventNoExpose    GdkEventNoExpose;
50 typedef struct _GdkEventVisibility  GdkEventVisibility;
51 typedef struct _GdkEventMotion      GdkEventMotion;
52 typedef struct _GdkEventButton      GdkEventButton;
53 typedef struct _GdkEventScroll      GdkEventScroll;  
54 typedef struct _GdkEventKey         GdkEventKey;
55 typedef struct _GdkEventFocus       GdkEventFocus;
56 typedef struct _GdkEventCrossing    GdkEventCrossing;
57 typedef struct _GdkEventConfigure   GdkEventConfigure;
58 typedef struct _GdkEventProperty    GdkEventProperty;
59 typedef struct _GdkEventSelection   GdkEventSelection;
60 typedef struct _GdkEventOwnerChange GdkEventOwnerChange;
61 typedef struct _GdkEventProximity   GdkEventProximity;
62 typedef struct _GdkEventClient      GdkEventClient;
63 typedef struct _GdkEventDND         GdkEventDND;
64 typedef struct _GdkEventWindowState GdkEventWindowState;
65 typedef struct _GdkEventSetting     GdkEventSetting;
66 typedef struct _GdkEventGrabBroken  GdkEventGrabBroken;
67
68 typedef union  _GdkEvent            GdkEvent;
69
70 typedef void (*GdkEventFunc) (GdkEvent *event,
71                               gpointer  data);
72
73 /* Event filtering */
74
75 typedef void GdkXEvent;   /* Can be cast to window system specific
76                            * even type, XEvent on X11, MSG on Win32.
77                            */
78
79 typedef enum {
80   GDK_FILTER_CONTINUE,    /* Event not handled, continue processesing */
81   GDK_FILTER_TRANSLATE,   /* Native event translated into a GDK event and
82                              stored in the "event" structure that was
83                              passed in */
84   GDK_FILTER_REMOVE       /* Terminate processing, removing event */
85 } GdkFilterReturn;
86
87 typedef GdkFilterReturn (*GdkFilterFunc) (GdkXEvent *xevent,
88                                           GdkEvent *event,
89                                           gpointer  data);
90
91
92 /* Event types.
93  *   Nothing: No event occurred.
94  *   Delete: A window delete event was sent by the window manager.
95  *           The specified window should be deleted.
96  *   Destroy: A window has been destroyed.
97  *   Expose: Part of a window has been uncovered.
98  *   NoExpose: Same as expose, but no expose event was generated.
99  *   VisibilityNotify: A window has become fully/partially/not obscured.
100  *   MotionNotify: The mouse has moved.
101  *   ButtonPress: A mouse button was pressed.
102  *   ButtonRelease: A mouse button was release.
103  *   KeyPress: A key was pressed.
104  *   KeyRelease: A key was released.
105  *   EnterNotify: A window was entered.
106  *   LeaveNotify: A window was exited.
107  *   FocusChange: The focus window has changed. (The focus window gets
108  *                keyboard events).
109  *   Resize: A window has been resized.
110  *   Map: A window has been mapped. (It is now visible on the screen).
111  *   Unmap: A window has been unmapped. (It is no longer visible on
112  *          the screen).
113  *   Scroll: A mouse wheel was scrolled either up or down.
114  */
115 typedef enum
116 {
117   GDK_NOTHING           = -1,
118   GDK_DELETE            = 0,
119   GDK_DESTROY           = 1,
120   GDK_EXPOSE            = 2,
121   GDK_MOTION_NOTIFY     = 3,
122   GDK_BUTTON_PRESS      = 4,
123   GDK_2BUTTON_PRESS     = 5,
124   GDK_3BUTTON_PRESS     = 6,
125   GDK_BUTTON_RELEASE    = 7,
126   GDK_KEY_PRESS         = 8,
127   GDK_KEY_RELEASE       = 9,
128   GDK_ENTER_NOTIFY      = 10,
129   GDK_LEAVE_NOTIFY      = 11,
130   GDK_FOCUS_CHANGE      = 12,
131   GDK_CONFIGURE         = 13,
132   GDK_MAP               = 14,
133   GDK_UNMAP             = 15,
134   GDK_PROPERTY_NOTIFY   = 16,
135   GDK_SELECTION_CLEAR   = 17,
136   GDK_SELECTION_REQUEST = 18,
137   GDK_SELECTION_NOTIFY  = 19,
138   GDK_PROXIMITY_IN      = 20,
139   GDK_PROXIMITY_OUT     = 21,
140   GDK_DRAG_ENTER        = 22,
141   GDK_DRAG_LEAVE        = 23,
142   GDK_DRAG_MOTION       = 24,
143   GDK_DRAG_STATUS       = 25,
144   GDK_DROP_START        = 26,
145   GDK_DROP_FINISHED     = 27,
146   GDK_CLIENT_EVENT      = 28,
147   GDK_VISIBILITY_NOTIFY = 29,
148   GDK_NO_EXPOSE         = 30,
149   GDK_SCROLL            = 31,
150   GDK_WINDOW_STATE      = 32,
151   GDK_SETTING           = 33,
152   GDK_OWNER_CHANGE      = 34,
153   GDK_GRAB_BROKEN       = 35,
154   GDK_DAMAGE            = 36
155 } GdkEventType;
156
157 /* Event masks. (Used to select what types of events a window
158  *  will receive).
159  */
160 typedef enum
161 {
162   GDK_EXPOSURE_MASK             = 1 << 1,
163   GDK_POINTER_MOTION_MASK       = 1 << 2,
164   GDK_POINTER_MOTION_HINT_MASK  = 1 << 3,
165   GDK_BUTTON_MOTION_MASK        = 1 << 4,
166   GDK_BUTTON1_MOTION_MASK       = 1 << 5,
167   GDK_BUTTON2_MOTION_MASK       = 1 << 6,
168   GDK_BUTTON3_MOTION_MASK       = 1 << 7,
169   GDK_BUTTON_PRESS_MASK         = 1 << 8,
170   GDK_BUTTON_RELEASE_MASK       = 1 << 9,
171   GDK_KEY_PRESS_MASK            = 1 << 10,
172   GDK_KEY_RELEASE_MASK          = 1 << 11,
173   GDK_ENTER_NOTIFY_MASK         = 1 << 12,
174   GDK_LEAVE_NOTIFY_MASK         = 1 << 13,
175   GDK_FOCUS_CHANGE_MASK         = 1 << 14,
176   GDK_STRUCTURE_MASK            = 1 << 15,
177   GDK_PROPERTY_CHANGE_MASK      = 1 << 16,
178   GDK_VISIBILITY_NOTIFY_MASK    = 1 << 17,
179   GDK_PROXIMITY_IN_MASK         = 1 << 18,
180   GDK_PROXIMITY_OUT_MASK        = 1 << 19,
181   GDK_SUBSTRUCTURE_MASK         = 1 << 20,
182   GDK_SCROLL_MASK               = 1 << 21,
183   GDK_ALL_EVENTS_MASK           = 0x3FFFFE
184 } GdkEventMask;
185
186 typedef enum
187 {
188   GDK_VISIBILITY_UNOBSCURED,
189   GDK_VISIBILITY_PARTIAL,
190   GDK_VISIBILITY_FULLY_OBSCURED
191 } GdkVisibilityState;
192
193 typedef enum
194 {
195   GDK_SCROLL_UP,
196   GDK_SCROLL_DOWN,
197   GDK_SCROLL_LEFT,
198   GDK_SCROLL_RIGHT
199 } GdkScrollDirection;
200
201 /* Types of enter/leave notifications.
202  *   Ancestor:
203  *   Virtual:
204  *   Inferior:
205  *   Nonlinear:
206  *   NonlinearVirtual:
207  *   Unknown: An unknown type of enter/leave event occurred.
208  */
209 typedef enum
210 {
211   GDK_NOTIFY_ANCESTOR           = 0,
212   GDK_NOTIFY_VIRTUAL            = 1,
213   GDK_NOTIFY_INFERIOR           = 2,
214   GDK_NOTIFY_NONLINEAR          = 3,
215   GDK_NOTIFY_NONLINEAR_VIRTUAL  = 4,
216   GDK_NOTIFY_UNKNOWN            = 5
217 } GdkNotifyType;
218
219 /* Enter/leave event modes.
220  *   NotifyNormal
221  *   NotifyGrab
222  *   NotifyUngrab
223  */
224 typedef enum
225 {
226   GDK_CROSSING_NORMAL,
227   GDK_CROSSING_GRAB,
228   GDK_CROSSING_UNGRAB
229 } GdkCrossingMode;
230
231 typedef enum
232 {
233   GDK_PROPERTY_NEW_VALUE,
234   GDK_PROPERTY_DELETE
235 } GdkPropertyState;
236
237 typedef enum
238 {
239   GDK_WINDOW_STATE_WITHDRAWN  = 1 << 0,
240   GDK_WINDOW_STATE_ICONIFIED  = 1 << 1,
241   GDK_WINDOW_STATE_MAXIMIZED  = 1 << 2,
242   GDK_WINDOW_STATE_STICKY     = 1 << 3,
243   GDK_WINDOW_STATE_FULLSCREEN = 1 << 4,
244   GDK_WINDOW_STATE_ABOVE      = 1 << 5,
245   GDK_WINDOW_STATE_BELOW      = 1 << 6
246 } GdkWindowState;
247
248 typedef enum
249 {
250   GDK_SETTING_ACTION_NEW,
251   GDK_SETTING_ACTION_CHANGED,
252   GDK_SETTING_ACTION_DELETED
253 } GdkSettingAction;
254
255 typedef enum
256 {
257   GDK_OWNER_CHANGE_NEW_OWNER,
258   GDK_OWNER_CHANGE_DESTROY,
259   GDK_OWNER_CHANGE_CLOSE
260 } GdkOwnerChange;
261
262 struct _GdkEventAny
263 {
264   GdkEventType type;
265   GdkWindow *window;
266   gint8 send_event;
267 };
268
269 struct _GdkEventExpose
270 {
271   GdkEventType type;
272   GdkWindow *window;
273   gint8 send_event;
274   GdkRectangle area;
275   GdkRegion *region;
276   gint count; /* If non-zero, how many more events follow. */
277 };
278
279 struct _GdkEventNoExpose
280 {
281   GdkEventType type;
282   GdkWindow *window;
283   gint8 send_event;
284 };
285
286 struct _GdkEventVisibility
287 {
288   GdkEventType type;
289   GdkWindow *window;
290   gint8 send_event;
291   GdkVisibilityState state;
292 };
293
294 struct _GdkEventMotion
295 {
296   GdkEventType type;
297   GdkWindow *window;
298   gint8 send_event;
299   guint32 time;
300   gdouble x;
301   gdouble y;
302   gdouble *axes;
303   guint state;
304   gint16 is_hint;
305   GdkDevice *device;
306   gdouble x_root, y_root;
307 };
308
309 struct _GdkEventButton
310 {
311   GdkEventType type;
312   GdkWindow *window;
313   gint8 send_event;
314   guint32 time;
315   gdouble x;
316   gdouble y;
317   gdouble *axes;
318   guint state;
319   guint button;
320   GdkDevice *device;
321   gdouble x_root, y_root;
322 };
323
324 struct _GdkEventScroll
325 {
326   GdkEventType type;
327   GdkWindow *window;
328   gint8 send_event;
329   guint32 time;
330   gdouble x;
331   gdouble y;
332   guint state;
333   GdkScrollDirection direction;
334   GdkDevice *device;
335   gdouble x_root, y_root;
336 };
337
338 struct _GdkEventKey
339 {
340   GdkEventType type;
341   GdkWindow *window;
342   gint8 send_event;
343   guint32 time;
344   guint state;
345   guint keyval;
346   gint length;
347   gchar *string;
348   guint16 hardware_keycode;
349   guint8 group;
350   guint is_modifier : 1;
351 };
352
353 struct _GdkEventCrossing
354 {
355   GdkEventType type;
356   GdkWindow *window;
357   gint8 send_event;
358   GdkWindow *subwindow;
359   guint32 time;
360   gdouble x;
361   gdouble y;
362   gdouble x_root;
363   gdouble y_root;
364   GdkCrossingMode mode;
365   GdkNotifyType detail;
366   gboolean focus;
367   guint state;
368 };
369
370 struct _GdkEventFocus
371 {
372   GdkEventType type;
373   GdkWindow *window;
374   gint8 send_event;
375   gint16 in;
376 };
377
378 struct _GdkEventConfigure
379 {
380   GdkEventType type;
381   GdkWindow *window;
382   gint8 send_event;
383   gint x, y;
384   gint width;
385   gint height;
386 };
387
388 struct _GdkEventProperty
389 {
390   GdkEventType type;
391   GdkWindow *window;
392   gint8 send_event;
393   GdkAtom atom;
394   guint32 time;
395   guint state;
396 };
397
398 struct _GdkEventSelection
399 {
400   GdkEventType type;
401   GdkWindow *window;
402   gint8 send_event;
403   GdkAtom selection;
404   GdkAtom target;
405   GdkAtom property;
406   guint32 time;
407   GdkNativeWindow requestor;
408 };
409
410 struct _GdkEventOwnerChange
411 {
412   GdkEventType type;
413   GdkWindow *window;
414   gint8 send_event;
415   GdkNativeWindow owner;
416   GdkOwnerChange reason;
417   GdkAtom selection;
418   guint32 time;
419   guint32 selection_time;
420 };
421
422 /* This event type will be used pretty rarely. It only is important
423    for XInput aware programs that are drawing their own cursor */
424
425 struct _GdkEventProximity
426 {
427   GdkEventType type;
428   GdkWindow *window;
429   gint8 send_event;
430   guint32 time;
431   GdkDevice *device;
432 };
433
434 struct _GdkEventClient
435 {
436   GdkEventType type;
437   GdkWindow *window;
438   gint8 send_event;
439   GdkAtom message_type;
440   gushort data_format;
441   union {
442     char b[20];
443     short s[10];
444     long l[5];
445   } data;
446 };
447
448 struct _GdkEventSetting
449 {
450   GdkEventType type;
451   GdkWindow *window;
452   gint8 send_event;
453   GdkSettingAction action;
454   char *name;
455 };
456
457 struct _GdkEventWindowState
458 {
459   GdkEventType type;
460   GdkWindow *window;
461   gint8 send_event;
462   GdkWindowState changed_mask;
463   GdkWindowState new_window_state;
464 };
465
466 struct _GdkEventGrabBroken {
467   GdkEventType type;
468   GdkWindow *window;
469   gint8 send_event;
470   gboolean keyboard;
471   gboolean implicit;
472   GdkWindow *grab_window;
473 };
474
475 /* Event types for DND */
476
477 struct _GdkEventDND {
478   GdkEventType type;
479   GdkWindow *window;
480   gint8 send_event;
481   GdkDragContext *context;
482
483   guint32 time;
484   gshort x_root, y_root;
485 };
486
487 union _GdkEvent
488 {
489   GdkEventType              type;
490   GdkEventAny               any;
491   GdkEventExpose            expose;
492   GdkEventNoExpose          no_expose;
493   GdkEventVisibility        visibility;
494   GdkEventMotion            motion;
495   GdkEventButton            button;
496   GdkEventScroll            scroll;
497   GdkEventKey               key;
498   GdkEventCrossing          crossing;
499   GdkEventFocus             focus_change;
500   GdkEventConfigure         configure;
501   GdkEventProperty          property;
502   GdkEventSelection         selection;
503   GdkEventOwnerChange       owner_change;
504   GdkEventProximity         proximity;
505   GdkEventClient            client;
506   GdkEventDND               dnd;
507   GdkEventWindowState       window_state;
508   GdkEventSetting           setting;
509   GdkEventGrabBroken        grab_broken;
510 };
511
512 GType     gdk_event_get_type            (void) G_GNUC_CONST;
513
514 gboolean  gdk_events_pending            (void);
515 GdkEvent* gdk_event_get                 (void);
516
517 GdkEvent* gdk_event_peek                (void);
518 GdkEvent* gdk_event_get_graphics_expose (GdkWindow      *window);
519 void      gdk_event_put                 (const GdkEvent *event);
520
521 GdkEvent* gdk_event_new                 (GdkEventType    type);
522 GdkEvent* gdk_event_copy                (const GdkEvent *event);
523 void      gdk_event_free                (GdkEvent       *event);
524
525 guint32   gdk_event_get_time            (const GdkEvent  *event);
526 gboolean  gdk_event_get_state           (const GdkEvent  *event,
527                                          GdkModifierType *state);
528 gboolean  gdk_event_get_coords          (const GdkEvent  *event,
529                                          gdouble         *x_win,
530                                          gdouble         *y_win);
531 gboolean  gdk_event_get_root_coords     (const GdkEvent  *event,
532                                          gdouble         *x_root,
533                                          gdouble         *y_root);
534 gboolean  gdk_event_get_axis            (const GdkEvent  *event,
535                                          GdkAxisUse       axis_use,
536                                          gdouble         *value);
537 void      gdk_event_request_motions     (const GdkEventMotion *event);
538 void      gdk_event_handler_set         (GdkEventFunc    func,
539                                          gpointer        data,
540                                          GDestroyNotify  notify);
541
542 void       gdk_event_set_screen         (GdkEvent        *event,
543                                          GdkScreen       *screen);
544 GdkScreen *gdk_event_get_screen         (const GdkEvent  *event);
545
546 void      gdk_set_show_events           (gboolean        show_events);
547 gboolean  gdk_get_show_events           (void);
548
549 #ifndef GDK_MULTIHEAD_SAFE
550 void gdk_add_client_message_filter (GdkAtom       message_type,
551                                     GdkFilterFunc func,
552                                     gpointer      data);
553
554 gboolean gdk_setting_get (const gchar *name,
555                           GValue      *value); 
556 #endif /* GDK_MULTIHEAD_SAFE */
557
558 G_END_DECLS
559
560 #endif /* __GDK_EVENTS_H__ */