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